Пример #1
0
        public JsonResult GetDUs(string sidx, string sord, int page, int rows)  //Gets the todo Lists.
        {
            #region MyRegion
            int pageIndex = Convert.ToInt32(page) - 1;
            int pageSize  = rows;
            // FinanceToolEntities2 db = new FinanceToolEntities2();
            var duResults = db.Usp_GetDUMasterDetails().Select(
                du => new
            {
                du.DUID,
                du.DUName,
                du.DUHeadID,
                du.DUHeadName,
                du.AMName,
                du.AMID,
                du.SDUID,
                du.SDUName,
                du.Createdby,
                du.Createddate,
                du.Modifiedby,
                du.ModifiedDate
            }).ToList();
            int totalRecords     = duResults.Count();
            var totalPages       = (int)Math.Ceiling((float)totalRecords / (float)rows);
            var customerResults2 = duResults.OrderByDescending(s => s.DUName);
            var customerResults3 = customerResults2.Skip(pageIndex * pageSize).Take(pageSize);
            var jsonData         = new
            {
                total = totalPages,
                page,
                records = totalRecords,
                rows    = customerResults3
            };
            return(Json(jsonData, JsonRequestBehavior.AllowGet));

            #endregion
        }