Ejemplo n.º 1
0
        public async Task <ActionResult> Index(Guid id, BaselOecdCodeViewModel model, bool backToOverview = false)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var codeType = (model.GetCode().HasValue)
                ? model.WasteCodes.Single(wc => wc.Id == model.GetCode().Value).CodeType
                : CodeType.Basel;

            var existingData = await mediator.SendAsync(new GetWasteCodeLookupAndNotificationDataByTypes(id, RequiredCodeTypes, RequiredCodeTypes));

            await
            mediator.SendAsync(new SetBaselOecdCodeForNotification(id,
                                                                   codeType,
                                                                   model.NotListed,
                                                                   model.GetCode()));

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

            return(backToOverview ? RedirectToAction("Index", "Home", new { id })
                : RedirectToAction("Index", "EwcCode", new { id }));
        }
        public async Task<ActionResult> Index(Guid id, BaselOecdCodeViewModel model, bool backToOverview = false)
        {
            if (!ModelState.IsValid)
            {
                return View(model);
            }

            var codeType = (model.GetCode().HasValue)
                ? model.WasteCodes.Single(wc => wc.Id == model.GetCode().Value).CodeType
                : CodeType.Basel;

            await
                mediator.SendAsync(new SetBaselOecdCodeForNotification(id,
                        codeType,
                        model.NotListed,
                        model.GetCode()));

            return backToOverview ? RedirectToAction("Index", "Home", new { id })
                : RedirectToAction("Index", "EwcCode", new { id });
        }