public CustomStateDetail SaveDetail(CustomStateDetail customStateDetail) { _customStateDetailRepository.SaveOrUpdate(customStateDetail); _eventAggregator.SendMessage <DepartmentSettingsUpdateEvent>(new DepartmentSettingsUpdateEvent() { DepartmentId = customStateDetail.CustomState.DepartmentId }); return(customStateDetail); }
public async Task <CustomStateDetail> SaveDetailAsync(CustomStateDetail customStateDetail, CancellationToken cancellationToken = default(CancellationToken)) { var saved = await _customStateDetailRepository.SaveOrUpdateAsync(customStateDetail, cancellationToken); _eventAggregator.SendMessage <DepartmentSettingsUpdateEvent>(new DepartmentSettingsUpdateEvent() { DepartmentId = customStateDetail.CustomState.DepartmentId }); return(saved); }
public IActionResult Edit(EditStatusView model, IFormCollection form) { if (ModelState.IsValid) { List <int> options = (from object key in form.Keys where key.ToString().StartsWith("buttonText_") select int.Parse(key.ToString().Replace("buttonText_", ""))).ToList(); var details = new List <CustomStateDetail>(); var state = _customStateService.GetCustomSateById(model.State.CustomStateId); state.Name = model.State.Name; state.Description = model.State.Description; foreach (var i in options) { if (form.ContainsKey("buttonText_" + i)) { var text = form["buttonText_" + i]; var color = form["buttonColor_" + i]; var textColor = form["textColor_" + i]; var order = form["order_" + i]; bool gps = false; var gpsValue = form["requireGps_" + i]; if (gpsValue == "on") { gps = true; } var noteType = int.Parse(form["noteType_" + i]); var detailType = int.Parse(form["detailType_" + i]); var detail = new CustomStateDetail(); detail.ButtonText = text; detail.ButtonColor = color; detail.GpsRequired = gps; detail.NoteType = noteType; detail.DetailType = detailType; detail.TextColor = textColor; detail.Order = int.Parse(order); details.Add(detail); } } _customStateService.Update(state, details); return(RedirectToAction("Index")); } return(View(model)); }
public async Task <CustomStateDetail> GetCustomUnitStateAsync(UnitState state) { if (state.State <= 25) { var detail = new CustomStateDetail(); detail.ButtonText = state.GetStatusText(); detail.ButtonColor = state.GetStatusCss(); if (string.IsNullOrWhiteSpace(detail.ButtonColor)) { detail.ButtonColor = "label-default"; } return(detail); } else { var stateDetail = await GetCustomDetailForDepartmentAsync(state.Unit.DepartmentId, state.State); return(stateDetail); } }
public async Task <CustomStateDetail> GetCustomPersonnelStatusAsync(int departmentId, ActionLog state) { if (state.ActionTypeId <= 25) { var detail = new CustomStateDetail(); detail.ButtonText = state.GetActionText(); detail.ButtonColor = state.GetActionCss(); if (string.IsNullOrWhiteSpace(detail.ButtonColor)) { detail.ButtonColor = "label-default"; } return(detail); } else { var stateDetail = await GetCustomDetailForDepartmentAsync(departmentId, state.ActionTypeId); return(stateDetail); } }
public CustomStateDetail GetCustomPersonnelStaffing(int departmentId, UserState state) { if (state.State <= 25) { var detail = new CustomStateDetail(); detail.ButtonText = state.GetStaffingText(); detail.ButtonColor = state.GetStaffingCss(); if (string.IsNullOrWhiteSpace(detail.ButtonColor)) { detail.ButtonColor = "label-default"; } return(detail); } else { var stateDetail = GetCustomDetailForDepartment(departmentId, state.State); return(stateDetail); } }
public static CustomStateDetail GetCustomUnitState(UnitState state) { if (state.State <= 25) { var detail = new CustomStateDetail(); detail.ButtonText = state.ToStateDisplayText(); detail.ButtonColor = state.ToStateCss(); if (string.IsNullOrWhiteSpace(detail.ButtonColor)) { detail.ButtonColor = "label-default"; } return(detail); } else { var customStateService = WebBootstrapper.GetKernel().Resolve <ICustomStateService>(); var stateDetail = customStateService.GetCustomDetailForDepartment(state.Unit.DepartmentId, state.State); return(stateDetail); } }
public static CustomStateDetail GetCustomPersonnelStatus(int departmentId, ActionLog state) { if (state.ActionTypeId <= 25) { var detail = new CustomStateDetail(); detail.ButtonText = state.GetActionText(); detail.ButtonColor = state.GetActionCss(); if (string.IsNullOrWhiteSpace(detail.ButtonColor)) { detail.ButtonColor = "label-default"; } return(detail); } else { var customStateService = WebBootstrapper.GetKernel().Resolve <ICustomStateService>(); var stateDetail = customStateService.GetCustomDetailForDepartment(departmentId, state.ActionTypeId); return(stateDetail); } }
public static async Task <CustomStateDetail> GetCustomUnitState(UnitState state) { if (state.State <= 25) { var detail = new CustomStateDetail(); detail.ButtonText = state.ToStateDisplayText(); detail.ButtonColor = state.ToStateCss(); if (string.IsNullOrWhiteSpace(detail.ButtonColor)) { detail.ButtonColor = "label-default"; } return(detail); } else { var customStateService = ServiceLocator.Current.GetInstance <ICustomStateService>(); var stateDetail = await customStateService.GetCustomDetailForDepartmentAsync(state.Unit.DepartmentId, state.State); return(stateDetail); } }
public async Task <CustomStateDetail> DeleteDetailAsync(CustomStateDetail detail, CancellationToken cancellationToken = default(CancellationToken)) { detail.IsDeleted = true; return(await _customStateDetailRepository.SaveOrUpdateAsync(detail, cancellationToken)); }
public void DeleteDetail(CustomStateDetail detail) { detail.IsDeleted = true; _customStateDetailRepository.SaveOrUpdate(detail); }
public IActionResult New(NewCustomStateView model, IFormCollection form) { List <int> options = (from object key in form.Keys where key.ToString().StartsWith("buttonText_") select int.Parse(key.ToString().Replace("buttonText_", ""))).ToList(); if (options == null || !options.Any()) { ModelState.AddModelError("Detail", "You must supply options (which turn into the buttons) for personnel to act on before creating your custom statuses."); } if (ModelState.IsValid) { if (options.Count > 0) { model.State.Details = new Collection <CustomStateDetail>(); } model.State.DepartmentId = DepartmentId; model.State.Type = (int)model.Type; foreach (var i in options) { if (form.ContainsKey("buttonText_" + i)) { var text = form["buttonText_" + i]; var color = form["buttonColor_" + i]; var textColor = form["textColor_" + i]; var order = form["order_" + i]; bool gps = false; var gpsValue = form["requireGps_" + i]; if (gpsValue == "on") { gps = true; } var noteType = int.Parse(form["noteType_" + i]); var detailType = int.Parse(form["detailType_" + i]); var detail = new CustomStateDetail(); detail.ButtonText = text; detail.ButtonColor = color; detail.GpsRequired = gps; detail.NoteType = noteType; detail.DetailType = detailType; detail.TextColor = textColor; detail.Order = int.Parse(order); model.State.Details.Add(detail); } } _customStateService.Save(model.State); return(RedirectToAction("Index")); } return(View(model)); }