public async Task<ActionResult> Index(Guid id, CustomWasteCodesViewModel model, bool backToOverview = false)
        {
            if (!ModelState.IsValid)
            {
                return View(model);
            }

            await
                mediator.SendAsync(new SetCustomWasteCodes(id,
                        model.ExportNationalCode,
                        model.ExportNationalCodeNotApplicable,
                        model.ImportNationalCode,
                        model.ImportNationalCodeNotApplicable,
                        model.CustomsCode,
                        model.CustomsCodeNotApplicable,
                        model.OtherCode,
                        model.OtherCodeNotApplicable));

            var notificationInfo = await mediator.SendAsync(new GetNotificationBasicInfo(id));

            if (notificationInfo.NotificationType == NotificationType.Recovery)
            {
                return (backToOverview) ? RedirectToAction("Index", "Home", new { id })
                    : RedirectToAction("Index", "WasteRecovery", new { id });
            }
            return RedirectToAction("Index", "Home", new { id });
        }
Exemple #2
0
        public async Task <ActionResult> Index(Guid id, CustomWasteCodesViewModel model, bool backToOverview = false)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var existingData = await mediator.SendAsync(
                new GetWasteCodeLookupAndNotificationDataByTypes(id, null, new[]
            {
                CodeType.ExportCode,
                CodeType.ImportCode,
                CodeType.CustomsCode,
                CodeType.OtherCode
            }));

            await
            mediator.SendAsync(new SetCustomWasteCodes(id,
                                                       model.ExportNationalCode,
                                                       model.ExportNationalCodeNotApplicable,
                                                       model.ImportNationalCode,
                                                       model.ImportNationalCodeNotApplicable,
                                                       model.CustomsCode,
                                                       model.CustomsCodeNotApplicable,
                                                       model.OtherCode,
                                                       model.OtherCodeNotApplicable));

            await this.auditService.AddAuditEntry(this.mediator,
                                                  id,
                                                  User.GetUserId(),
                                                  existingData.NotificationWasteCodeData[CodeType.ExportCode].Count() == 0?NotificationAuditType.Added : NotificationAuditType.Updated,
                                                  NotificationAuditScreenType.OtherCodes);

            var notificationInfo = await mediator.SendAsync(new GetNotificationBasicInfo(id));

            if (notificationInfo.NotificationType == NotificationType.Recovery)
            {
                return((backToOverview) ? RedirectToAction("Index", "Home", new { id })
                    : RedirectToAction("Index", "WasteRecovery", new { id }));
            }
            return(RedirectToAction("Index", "Home", new { id }));
        }