public IActionResult GetAllReports() { var reports = new List <ReportModel>(); _reportFacade.GetAll().ToList().ForEach(r => reports.Add(new ReportModel(r.ReportId, r.SenderName, r.SuspectedName, r.Reason, r.Description))); var response = new AllReportsResponse(reports); return(Ok(response)); }
public IActionResult LoadDataForTable() { var draw = HttpContext.Request.Form["draw"].FirstOrDefault(); // Skiping number of Rows count var start = Request.Form["start"].FirstOrDefault(); // Paging Length 10,20 var length = Request.Form["length"].FirstOrDefault(); // Sort Column Name var sortColumn = Request.Form["columns[" + Request.Form["order[0][column]"].FirstOrDefault() + "][name]"].FirstOrDefault(); // Sort Column Direction ( asc ,desc) var sortColumnDirection = Request.Form["order[0][dir]"].FirstOrDefault(); // Search Value from (Search box) var searchValue = Request.Form["search[value]"].FirstOrDefault(); //Paging Size (10,20,50,100) int pageSize = length != null?Convert.ToInt32(length) : 0; int skip = start != null?Convert.ToInt32(start) : 0; int recordsTotal = 0; var model = _reportFacade.GetAll(); if (!string.IsNullOrEmpty(searchValue)) { model = model.Where(m => m.ProjectName.StartsWith(searchValue) || m.ClientOrg.StartsWith(searchValue) || m.ContractorOrg.StartsWith(searchValue) || m.SiteName.StartsWith(searchValue) ); } //total number of rows count recordsTotal = model.Count(); //Paging var data = model.Skip(skip).Take(pageSize).ToList(); //Returning Json Data return(Json(new { draw = draw, recordsFiltered = recordsTotal, recordsTotal = recordsTotal, data = data })); }