/// <summary>
        /// Fetches employees page vise on the basis of page number and page size provided.
        /// </summary>
        /// <param name="paging"></param>
        /// <returns></returns>
        public IEnumerable <EmployeeModel> GetEmployeePageVise([FromUri] PagingModal paging)
        {
            //OrganisationContext oc = new OrganisationContext();
            var employee = oc.Employees.Select(emp => new EmployeeModel()
            {
                Id      = emp.Id,
                EmpName = emp.EmpName,
                Email   = emp.Email,
                Salary  = emp.Salary,
                DeptId  = emp.DeptId,
            }).OrderBy(e => e.Id);
            int count = employee.Count();

            int CurrentPage = paging.PageNumber;

            int PageSize = paging.PageSize;

            int TotalCount = count;

            int TotalPages = (int)Math.Ceiling(count / (double)PageSize);

            var employeeList = employee.Skip((CurrentPage - 1) * PageSize).Take(PageSize).ToList();

            return(employeeList);
        }
示例#2
0
        public IEnumerable <EmployeeModel> Get([FromUri] PagingModal paging)
        {
            DBOperations dbo = new DBOperations();

            return(dbo.GetEmployeePageVise(paging));
        }