示例#1
0
        public ActionResult LoadExpenseData()
        {
            try
            {
                var draw          = Request.Form.GetValues("draw").FirstOrDefault();
                var start         = Request.Form.GetValues("start").FirstOrDefault();
                var length        = Request.Form.GetValues("length").FirstOrDefault();
                var sortColumn    = Request.Form.GetValues("columns[" + Request.Form.GetValues("order[0][column]").FirstOrDefault() + "][name]").FirstOrDefault();
                var sortColumnDir = Request.Form.GetValues("order[0][dir]").FirstOrDefault();
                var searchValue   = Request.Form.GetValues("search[value]").FirstOrDefault();
                int pageSize      = length != null?Convert.ToInt32(length) : 0;

                int skip = start != null?Convert.ToInt32(start) : 0;

                int recordsTotal = 0;

                var expensedata = _IExpense.ShowAllExpense(sortColumn, sortColumnDir, searchValue, Convert.ToInt32(Session["AdminUser"]));
                recordsTotal = expensedata.Count();
                var data = expensedata.Skip(skip).Take(pageSize).ToList();

                return(Json(new { draw = draw, recordsFiltered = recordsTotal, recordsTotal = recordsTotal, data = data }));
            }
            catch (Exception)
            {
                throw;
            }
        }