public async Task <IActionResult> Index() { var model = new UnitsIndexView(); model.Department = await _departmentsService.GetDepartmentByIdAsync(DepartmentId); model.CanUserAddUnit = await _limitsService.CanDepartmentAddNewUnit(DepartmentId); model.Groups = await _departmentGroupsService.GetAllGroupsForDepartmentAsync(DepartmentId); model.Units = await _unitsService.GetUnitsForDepartmentAsync(DepartmentId); model.States = await _unitsService.GetAllLatestStatusForUnitsByDepartmentIdAsync(DepartmentId); model.UnitStatuses = await _customStateService.GetAllActiveUnitStatesForDepartmentAsync(DepartmentId); model.UnitCustomStates = new Dictionary <int, CustomState>(); foreach (var unit in model.Units) { var type = await _unitsService.GetUnitTypeByNameAsync(DepartmentId, unit.Type); if (type != null && type.CustomStatesId.HasValue) { var customStates = await _customStateService.GetCustomSateByIdAsync(type.CustomStatesId.Value); if (customStates != null) { model.UnitCustomStates.Add(unit.UnitId, customStates); } } } return(View(model)); }
public IActionResult Index() { var model = new UnitsIndexView(); model.CanUserAddUnit = _limitsService.CanDepartentAddNewUnit(DepartmentId); return(View(model)); }