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 });
        }
示例#2
0
 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);
 }
示例#3
0
        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"));
        }
示例#4
0
        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"));
        }
示例#5
0
        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 }));
        }
示例#6
0
        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);
        }
示例#7
0
        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();
        }
        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();
        }
示例#9
0
        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();
        }
示例#11
0
 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);
示例#14
0
 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);
 }
示例#19
0
 private bool HasASelectedCode(BaseWasteCodeViewModel viewModel)
 {
     return(viewModel.EnterWasteCodesViewModel.SelectedCode.HasValue);
 }
示例#20
0
        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);
                }
            }
        }
示例#21
0
 protected override ActionResult AddAction(BaseWasteCodeViewModel viewModel)
 {
     IsAddCalled = true;
     return(base.AddAction(viewModel));
 }
示例#22
0
 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);
        }
示例#24
0
 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);
 }
示例#26
0
 protected virtual ActionResult AddAction(BaseWasteCodeViewModel viewModel)
 {
     return(View(viewModel));
 }