using System.Data.Common;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services;
using System.Collections.Generic;
using System.Text;
using System;
using System.Linq;
using System.Data.SqlClient;
using System.Configuration;
using System.Web;
using Telerik.Web.UI;

namespace Telerik.GridExamplesCSharp.Client.DataBinding
{
	public partial class DefaultCS : Page
	{
        [WebMethod]
        public static int GetCount(List<GridFilterExpression> filterExpressions)
        {
            NWDataContext nw = new NWDataContext();
            return nw.Employees.Count();
        }
      
        [WebMethod]
        public static List<Employee> GetData(int startIndex, int maximumRows,
            string sortExpressions, List<GridFilterExpression> filterExpressions)
        {

            NWDataContext nw = new NWDataContext();
            var result = nw.Employees.Skip(startIndex * maximumRows).Take(10).ToList();
            List<Employee> list = new List<Employee>();
            result.ForEach(e => list.Add(new Employee
            {
                EmployeeID = e.EmployeeID,
                FirstName = e.FirstName,
                LastName = e.LastName,
                Title = e.Title,
                TitleOfCourtesy = e.TitleOfCourtesy,
                BirthDate = e.BirthDate
            }));
            return list;
        }

        public class Employee
        {
            private int _EmployeeID;
            private string _LastName;
            private string _FirstName;
            private string _Title;
            private string _TitleOfCourtesy;
            private System.Nullable<System.DateTime> _BirthDate;

            public Employee()
            {

            }

            public int EmployeeID
            {
                get
                {
                    return this._EmployeeID;
                }
                set
                {
                    if ((this._EmployeeID != value))
                    {
                        this._EmployeeID = value;
                    }
                }
            }

            public string LastName
            {
                get
                {
                    return this._LastName;
                }
                set
                {
                    if ((this._LastName != value))
                    {
                        this._LastName = value;
                    }
                }
            }

            public string FirstName
            {
                get
                {
                    return this._FirstName;
                }
                set
                {
                    if ((this._FirstName != value))
                    {
                        this._FirstName = value;
                    }
                }
            }

            public string Title
            {
                get
                {
                    return this._Title;
                }
                set
                {
                    if ((this._Title != value))
                    {
                        this._Title = value;
                    }
                }
            }

            public string TitleOfCourtesy
            {
                get
                {
                    return this._TitleOfCourtesy;
                }
                set
                {
                    if ((this._TitleOfCourtesy != value))
                    {
                        this._TitleOfCourtesy = value;
                    }
                }
            }

            public System.Nullable<System.DateTime> BirthDate
            {
                get
                {
                    return this._BirthDate;
                }
                set
                {
                    if ((this._BirthDate != value))
                    {
                        this._BirthDate = value;
                    }
                }
            }
        }
	}
}
