public ActionResult Index(ReportDepartmentRightsOptions options) { if (!_reportSecurityService.CanReadDepartmentPermissions()) { return(RedirectToAction("ForbiddenError", "Home")); } return(View(new ReportDepartmentRightsViewModel { Departments = _reportService.GetAllowedDepartments(), Options = options })); }
public ActionResult GetDataTable(ReportDepartmentRightsOptions options) { if (options.Date == null || options.Department == null) { return(PartialView("DataTable", null)); } if (!_reportSecurityService.CanReadDepartmentPermissions()) { return(PartialView("DataTable", null)); } if (options.SortField == null) { options.SortField = "RequestUserSnp"; } return(PartialView("DataTable", new ReportDepartmentRightsViewModel { Options = options, Rights = _reportService.GetDepartmentRightsOnDate(options) })); }
public IEnumerable <ResourceUserRightModel> GetDepartmentRightsOnDate(ReportDepartmentRightsOptions options) { if (options.Date == null) { return(null); } if (options.Date < _minSqlDateTimeValue) { options.Date = _minSqlDateTimeValue; } if (options.Department == null) { 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.GetDepartmentRightsOnDate(options.Date.Value, department, unit)); if (options.ReportDisplayStyle == ReportDisplayStyle.Cards) { return(rights .OrderBy(r => r.RequestUserSnp) .ThenBy(r => r.ResourceRightName)); } return(rights.AsQueryable().OrderBy(options.SortDirection, options.SortField)); }