Пример #1
0
        public JsonResult IndexDataTable(CC.Web.Models.AgencyReportingIndexModel model)
        {
            var all = model.GetAgencyReportingData(db, Permissions);

            if (User.IsInRole("RegionReadOnly"))
            {
                model.SelectedRegionId = db.Users.Where(f => f.UserName == User.Identity.Name).Select(f => f.RegionId).SingleOrDefault();
            }
            var filtered = model.ApplyFilter(all);

            if (!string.IsNullOrEmpty(model.sSearch))
            {
                filtered = filtered.Where(f => f.AgencyGroupName.Contains(model.sSearch) || f.AgencyName.Contains(model.sSearch) ||
                                          f.ServiceTypeName.Contains(model.sSearch) || f.ServiceName.Contains(model.sSearch));
            }
            var sorted = model.ApplySort(filtered);

            var data = new CC.Web.Models.jQueryDataTableResult()
            {
                sEcho = model.sEcho,
                iTotalDisplayRecords = filtered.Count(),
                iTotalRecords        = all.Count(),
                aaData = sorted.Skip(model.iDisplayStart).Take(model.iDisplayLength)
            };

            return(MyJsonResult(data));
        }
Пример #2
0
        public ActionResult Export(CC.Web.Models.AgencyReportingIndexModel model)
        {
            var all = model.GetAgencyReportingData(db, Permissions);

            if (User.IsInRole("RegionReadOnly"))
            {
                model.SelectedRegionId = db.Users.Where(f => f.UserName == User.Identity.Name).Select(f => f.RegionId).SingleOrDefault();
            }
            var filtered = model.ApplyFilter(all);

            if (!string.IsNullOrEmpty(model.sSearch))
            {
                filtered = filtered.Where(f => f.AgencyGroupName.Contains(model.sSearch) || f.AgencyName.Contains(model.sSearch) ||
                                          f.ServiceTypeName.Contains(model.sSearch) || f.ServiceName.Contains(model.sSearch));
            }
            var sorted = model.ApplySort(filtered);

            return(this.Excel("AgencyReportingFinancialReportRecap", "Data", sorted));
        }