예제 #1
0
        public JsonResult GetResolvedChecks([ModelBinder(typeof(DataTablesBinder))] IDataTablesRequest requestModel)
        {
            IQueryable <CheckViewModel> query = CheckManager.GetResolvedChecksAsQueryable();
            var totalCount = query.Count();

            // Apply filters for searching
            if (requestModel.Search.Value != string.Empty)
            {
                var value = requestModel.Search.Value.Trim();
                query = query.Where(p => p.Name.Contains(value) ||
                                    p.sRecordID.Contains(value) ||
                                    p.sInterviewRecordID.Contains(value) ||
                                    p.sNum.Contains(value) ||
                                    p.sDate.Contains(value) ||
                                    p.Service.Contains(value) ||
                                    p.Disposition.Contains(value)
                                    );
            }

            var filteredCount = query.Count();

            query = query.OrderBy("Name asc");

            // Paging
            query = query.Skip(requestModel.Start).Take(requestModel.Length);

            var data = query.Select(rcheck => new
            {
                sRecordID          = rcheck.sRecordID,
                sInterviewRecordID = rcheck.sInterviewRecordID,
                Name        = rcheck.Name,
                sNum        = rcheck.sNum,
                sDate       = rcheck.sDate,
                Service     = rcheck.Service,
                Disposition = rcheck.Disposition
            }).ToList();

            return(Json(new DataTablesResponse(requestModel.Draw, data, filteredCount, totalCount), JsonRequestBehavior.AllowGet));
        }