protected override async Task<ActionResult> ContinueAction(Guid id, BaseWasteCodeViewModel viewModel, bool backToOverview) { await Mediator.SendAsync(new SetUNNumbers(id, viewModel.EnterWasteCodesViewModel.SelectedWasteCodes, viewModel.EnterWasteCodesViewModel.IsNotApplicable)); return (backToOverview) ? BackToOverviewResult(id) : RedirectToAction("Index", "CustomWasteCode", new { id }); }
protected bool CodeBeenAdded(BaseWasteCodeViewModel model, WasteCodeDataAndNotificationData existingData) { foreach (var code in model.EnterWasteCodesViewModel.SelectedWasteCodes) { if (existingData.NotificationWasteCodeData[this.codeType].Count(p => p.Id == code) == 0) { return(true); } } return(false); }
protected override async Task <ActionResult> ContinueAction(Guid id, BaseWasteCodeViewModel viewModel, bool backToOverview = false) { var existingData = await Mediator.SendAsync(new GetWasteCodeLookupAndNotificationDataByTypes(id, ewcCodeTypes, ewcCodeTypes)); await Mediator.SendAsync(new UpdateEwcCode(id, viewModel.EnterWasteCodesViewModel.SelectedWasteCodes)); await this.AddAuditEntries(existingData, viewModel, id, NotificationAuditScreenType.EwcCodes); return(RedirectToAction("Index", "Overview")); }
protected override async Task <ActionResult> ContinueAction(Guid id, BaseWasteCodeViewModel viewModel, bool backToOverview) { var existingData = await Mediator.SendAsync(new GetWasteCodeLookupAndNotificationDataByTypes(id, RequiredCodeTypes, RequiredCodeTypes)); await Mediator.SendAsync(new EditHCodes(id, viewModel.EnterWasteCodesViewModel.SelectedWasteCodes, viewModel.EnterWasteCodesViewModel.IsNotApplicable)); await AddAuditEntries(existingData, viewModel, id, NotificationAuditScreenType.HorHpCodes); return(RedirectToAction("Index", "Overview")); }
protected override async Task <ActionResult> ContinueAction(Guid id, BaseWasteCodeViewModel viewModel, bool backToOverview) { var existingData = await Mediator.SendAsync(new GetWasteCodeLookupAndNotificationDataByTypes(id, codeTypes, codeTypes)); await Mediator.SendAsync(new SetUNClasses(id, viewModel.EnterWasteCodesViewModel.SelectedWasteCodes, viewModel.EnterWasteCodesViewModel.IsNotApplicable)); await this.AddAuditEntries(existingData, viewModel, id, NotificationAuditScreenType.UnClasses); return((backToOverview) ? BackToOverviewResult(id) : RedirectToAction("Index", "UnNumber", new { id })); }
private void AddCodeToViewModel(BaseWasteCodeViewModel viewModel) { if (viewModel.EnterWasteCodesViewModel.SelectedWasteCodes == null) { viewModel.EnterWasteCodesViewModel.SelectedWasteCodes = new List <Guid>(); } if (viewModel.EnterWasteCodesViewModel.SelectedWasteCodes .Contains(viewModel.EnterWasteCodesViewModel.SelectedCode.Value)) { return; } viewModel.EnterWasteCodesViewModel.SelectedWasteCodes.Add(viewModel.EnterWasteCodesViewModel.SelectedCode.Value); }
protected virtual async Task RebindModel(Guid id, BaseWasteCodeViewModel viewModel) { var result = await Mediator.SendAsync(new GetWasteCodeLookupAndNotificationDataByTypes(id, new[] { codeType })); viewModel.EnterWasteCodesViewModel.WasteCodes = result.LookupWasteCodeData[codeType].Select(wc => new WasteCodeViewModel { Id = wc.Id, CodeType = wc.CodeType, Description = wc.Description, Name = wc.Code }).ToList(); }
public async Task <ActionResult> Post(Guid id, BaseWasteCodeViewModel viewModel, string command, string remove, bool backToOverview) { await RebindModel(id, viewModel); if (!string.IsNullOrWhiteSpace(remove)) { ModelState.Clear(); viewModel.EnterWasteCodesViewModel.SelectedWasteCodes.RemoveAll(c => c.ToString().Equals(remove)); return(RemoveAction(viewModel)); } if (string.IsNullOrWhiteSpace(command) && string.IsNullOrWhiteSpace(remove)) { throw new InvalidOperationException(); } if (!ModelState.IsValid || (command.Equals(AddCode) && !HasASelectedCode(viewModel))) { return(View(viewModel)); } if (command.Equals(AddCode) && HasASelectedCode(viewModel)) { AddCodeToViewModel(viewModel); viewModel.EnterWasteCodesViewModel.SelectedCode = null; ModelState.Remove("EnterWasteCodesViewModel.SelectedCode"); return(AddAction(viewModel)); } if (command.Equals(Continue)) { if (HasASelectedCode(viewModel)) { AddCodeToViewModel(viewModel); } return(await ContinueAction(id, viewModel, backToOverview)); } throw new InvalidOperationException(); }
public async Task<ActionResult> Post(Guid id, BaseWasteCodeViewModel viewModel, string command, string remove, bool backToOverview) { await RebindModel(id, viewModel); if (!string.IsNullOrWhiteSpace(remove)) { ModelState.Clear(); viewModel.EnterWasteCodesViewModel.SelectedWasteCodes.RemoveAll(c => c.ToString().Equals(remove)); return RemoveAction(viewModel); } if (string.IsNullOrWhiteSpace(command) && string.IsNullOrWhiteSpace(remove)) { throw new InvalidOperationException(); } if (!ModelState.IsValid || (command.Equals(AddCode) && !HasASelectedCode(viewModel))) { return View(viewModel); } if (command.Equals(AddCode) && HasASelectedCode(viewModel)) { AddCodeToViewModel(viewModel); viewModel.EnterWasteCodesViewModel.SelectedCode = null; ModelState.Remove("EnterWasteCodesViewModel.SelectedCode"); return AddAction(viewModel); } if (command.Equals(Continue)) { if (HasASelectedCode(viewModel)) { AddCodeToViewModel(viewModel); } return await ContinueAction(id, viewModel, backToOverview); } throw new InvalidOperationException(); }
protected override Task <ActionResult> ContinueAction(Guid id, BaseWasteCodeViewModel viewModel, bool backtoOverview = false) { IsContinueCalled = true; return(Task.FromResult(View() as ActionResult)); }
private bool HasASelectedCode(BaseWasteCodeViewModel viewModel) { return viewModel.EnterWasteCodesViewModel.SelectedCode.HasValue; }
protected abstract Task<ActionResult> ContinueAction(Guid id, BaseWasteCodeViewModel viewModel, bool backToOverview);
protected abstract Task <ActionResult> ContinueAction(Guid id, BaseWasteCodeViewModel viewModel, bool backToOverview);
protected virtual ActionResult AddAction(BaseWasteCodeViewModel viewModel) { return View(viewModel); }
protected override Task<ActionResult> ContinueAction(Guid id, BaseWasteCodeViewModel viewModel, bool backtoOverview = false) { IsContinueCalled = true; return Task.FromResult(View() as ActionResult); }
protected override Task RebindModel(Guid id, BaseWasteCodeViewModel viewModel) { IsRebindCalled = true; return Task.FromResult(0); }
protected override ActionResult RemoveAction(BaseWasteCodeViewModel viewModel) { IsRemoveCalled = true; return base.RemoveAction(viewModel); }
private bool HasASelectedCode(BaseWasteCodeViewModel viewModel) { return(viewModel.EnterWasteCodesViewModel.SelectedCode.HasValue); }
protected async Task AddAuditEntries(WasteCodeDataAndNotificationData existingData, BaseWasteCodeViewModel viewModel, Guid id, NotificationAuditScreenType screenType) { if (!existingData.NotificationWasteCodeData[codeType].Any()) { await AuditService.AddAuditEntry(Mediator, id, User.GetUserId(), NotificationAuditType.Added, screenType); } else { if (CodeBeenRemoved(viewModel, existingData)) { await AuditService.AddAuditEntry(Mediator, id, User.GetUserId(), NotificationAuditType.Deleted, screenType); } if (CodeBeenAdded(viewModel, existingData)) { await AuditService.AddAuditEntry(Mediator, id, User.GetUserId(), NotificationAuditType.Updated, screenType); } } }
protected override ActionResult AddAction(BaseWasteCodeViewModel viewModel) { IsAddCalled = true; return(base.AddAction(viewModel)); }
protected override ActionResult RemoveAction(BaseWasteCodeViewModel viewModel) { IsRemoveCalled = true; return(base.RemoveAction(viewModel)); }
private void AddCodeToViewModel(BaseWasteCodeViewModel viewModel) { if (viewModel.EnterWasteCodesViewModel.SelectedWasteCodes == null) { viewModel.EnterWasteCodesViewModel.SelectedWasteCodes = new List<Guid>(); } if (viewModel.EnterWasteCodesViewModel.SelectedWasteCodes .Contains(viewModel.EnterWasteCodesViewModel.SelectedCode.Value)) { return; } viewModel.EnterWasteCodesViewModel.SelectedWasteCodes.Add(viewModel.EnterWasteCodesViewModel.SelectedCode.Value); }
protected override Task RebindModel(Guid id, BaseWasteCodeViewModel viewModel) { IsRebindCalled = true; return(Task.FromResult(0)); }
protected override ActionResult AddAction(BaseWasteCodeViewModel viewModel) { IsAddCalled = true; return base.AddAction(viewModel); }
protected virtual ActionResult AddAction(BaseWasteCodeViewModel viewModel) { return(View(viewModel)); }