public IActionResult Index() { var model = new UnitsIndexView(); model.Department = _departmentsService.GetDepartmentById(DepartmentId); model.CanUserAddUnit = _limitsService.CanDepartentAddNewUnit(DepartmentId); model.Groups = _departmentGroupsService.GetAllGroupsForDepartment(DepartmentId); model.Units = _unitsService.GetUnitsForDepartment(DepartmentId); model.States = _unitsService.GetAllLatestStatusForUnitsByDepartmentId(DepartmentId); model.UnitStatuses = _customStateService.GetAllActiveUnitStatesForDepartment(DepartmentId); model.UnitCustomStates = new Dictionary <int, CustomState>(); foreach (var unit in model.Units) { var type = _unitsService.GetUnitTypeByName(DepartmentId, unit.Type); if (type != null && type.CustomStatesId.HasValue) { var customStates = _customStateService.GetCustomSateById(type.CustomStatesId.Value); if (customStates != null) { model.UnitCustomStates.Add(unit.UnitId, customStates); } } } return(View(model)); }
public IActionResult NewUnit() { var model = new NewUnitView(); model.Unit = new Unit(); model.Types = _unitsService.GetUnitTypesForDepartment(DepartmentId); var states = new List <CustomState>(); states.Add(new CustomState { Name = "Standard Actions" }); states.AddRange(_customStateService.GetAllActiveUnitStatesForDepartment(DepartmentId)); model.States = states; var groups = new List <DepartmentGroup>(); groups.Add(new DepartmentGroup { Name = "No Station" }); groups.AddRange(_departmentGroupsService.GetAllStationGroupsForDepartment(DepartmentId)); model.Stations = groups; return(View(model)); }
public IActionResult EditUnitType(int unitTypeId) { var model = new EditUnitTypeView(); model.UnitType = _unitsService.GetUnitTypeById(unitTypeId); var states = new List <CustomState>(); states.Add(new CustomState { Name = "Standard Actions" }); states.AddRange(_customStateService.GetAllActiveUnitStatesForDepartment(DepartmentId)); model.States = states; model.UnitCustomStatesId = model.UnitType.CustomStatesId.GetValueOrDefault(); return(View(model)); }
public IActionResult GetUnitStatusesLevelsForDepartmentCombined(bool includeAny) { List <PersonnelStatusJson> personnelStauses = new List <PersonnelStatusJson>(); var customStates = _customStateService.GetAllActiveUnitStatesForDepartment(DepartmentId); if (includeAny) { personnelStauses.Add(new PersonnelStatusJson() { Id = -1, Name = "Any" }); } if (customStates != null && customStates.Any()) { foreach (var customState in customStates) { foreach (var detail in customState.GetActiveDetails()) { var status = new PersonnelStatusJson(); status.Id = detail.CustomStateDetailId; status.Name = $"{customState.Name}:{detail.ButtonText}"; personnelStauses.Add(status); } } } else { personnelStauses.Add(new PersonnelStatusJson() { Id = 0, Name = "Available" }); personnelStauses.Add(new PersonnelStatusJson() { Id = 1, Name = "Delayed" }); personnelStauses.Add(new PersonnelStatusJson() { Id = 2, Name = "Unavailable" }); personnelStauses.Add(new PersonnelStatusJson() { Id = 3, Name = "Committed" }); personnelStauses.Add(new PersonnelStatusJson() { Id = 4, Name = "Out Of Service" }); personnelStauses.Add(new PersonnelStatusJson() { Id = 5, Name = "Responding" }); personnelStauses.Add(new PersonnelStatusJson() { Id = 6, Name = "On Scene" }); personnelStauses.Add(new PersonnelStatusJson() { Id = 7, Name = "Staging" }); personnelStauses.Add(new PersonnelStatusJson() { Id = 8, Name = "Returning" }); personnelStauses.Add(new PersonnelStatusJson() { Id = 9, Name = "Cancelled" }); personnelStauses.Add(new PersonnelStatusJson() { Id = 10, Name = "Released" }); personnelStauses.Add(new PersonnelStatusJson() { Id = 11, Name = "Manual" }); personnelStauses.Add(new PersonnelStatusJson() { Id = 12, Name = "Enroute" }); } return(Json(personnelStauses)); }