public ActionResult Index(ReportDepartmentAndResourceRightsOptions options) { if (!_reportSecurityService.CanReadDepartmentAndResourcePermissions()) { return(RedirectToAction("ForbiddenError", "Home")); } return(View(new ReportDepartmentAndResourceRightsViewModel { Resources = _reportService.GetResources(), Departments = _reportService.GetAllDepartments(), Options = options })); }
public ActionResult GetDataTable(ReportDepartmentAndResourceRightsOptions options) { if (options.Date == null || options.IdResource == null) { return(PartialView("DataTable", null)); } if (!_reportSecurityService.CanReadDepartmentAndResourcePermissions()) { return(PartialView("DataTable", null)); } if (options.SortField == null) { options.SortField = "RequestUserSnp"; } return(PartialView("DataTable", new ReportDepartmentAndResourceRightsViewModel { Options = options, Rights = _reportService.GetDepartmentAndResourceRightsOnDate(options) })); }
public IEnumerable <ResourceUserRightModel> GetDepartmentAndResourceRightsOnDate(ReportDepartmentAndResourceRightsOptions options) { if (options.Date == null || options.Department == null || options.IdResource == null) { return(null); } if (options.Date < _minSqlDateTimeValue) { options.Date = _minSqlDateTimeValue; } if (!_reportRepository.GetResources().Select(r => r.IdResource). Contains(options.IdResource.Value)) { return(null); } var department = options.Department; string unit = null; if (options.Department.Contains("//")) { department = options.Department.Split(new[] { "//" }, StringSplitOptions.None)[0]; unit = options.Department.Split(new[] { "//" }, StringSplitOptions.None)[1]; } if (!_reportRepository.GetDepartments().Select(r => r.Name). Contains(department)) { return(null); } var rights = _reportSecurityService.FilterResourceRights( _rightService.GetDepartmentAndResourceRightsOnDate(options.Date.Value, department, unit, options.IdResource)); if (options.ReportDisplayStyle == ReportDisplayStyle.Cards) { return(rights .OrderBy(r => r.RequestUserSnp) .ThenBy(r => r.ResourceRightName)); } return(rights.AsQueryable().OrderBy(options.SortDirection, options.SortField)); }