public async Task<ActionResult> Index(ReasonForExportViewModel model, bool? backToOverview = null)
        {
            if (!ModelState.IsValid)
            {
                return View(model);
            }

            try
            {
                await
                    mediator.SendAsync(new SetReasonForExport(model.NotificationId, model.ReasonForExport));

                if (backToOverview.GetValueOrDefault())
                {
                    return RedirectToAction("Index", "Home", new { id = model.NotificationId });
                }

                return RedirectToAction("List", "Carrier", new { id = model.NotificationId });
            }
            catch (ApiBadRequestException ex)
            {
                this.HandleBadRequest(ex);
                if (ModelState.IsValid)
                {
                    throw;
                }
            }
            return View(model);
        }
        public void InvalidReasonOfExport_ValidationError()
        {
            var viewModel = new ReasonForExportViewModel {
                ReasonForExport = invalidReasonOfExport
            };

            Assert.True(ViewModelValidator.ValidateViewModel(viewModel).Count > 0);
        }
        public void ValidReasonOfExport_NoValidationError()
        {
            var viewModel = new ReasonForExportViewModel {
                ReasonForExport = "valid value"
            };

            Assert.True(ViewModelValidator.ValidateViewModel(viewModel).Count == 0);
        }
Beispiel #4
0
        public async Task ReasonForExport_Post_BackToOverviewNull_RedirectsToCarrierList()
        {
            var model = new ReasonForExportViewModel();

            var result = await reasonForExportController.Index(model, null) as RedirectToRouteResult;

            RouteAssert.RoutesTo(result.RouteValues, "List", "Carrier");
        }
Beispiel #5
0
        public async Task ReasonForExport_Post_BackToOverviewTrue_RedirectsToOverview()
        {
            var model = new ReasonForExportViewModel();

            var result = await reasonForExportController.Index(model, true) as RedirectToRouteResult;

            RouteAssert.RoutesTo(result.RouteValues, "Index", "Home");
        }
        public async Task ReasonForExport_Post_BackToOverviewNull_RedirectsToCarrierList()
        {
            var model = new ReasonForExportViewModel();

            var result = await reasonForExportController.Index(model, null) as RedirectToRouteResult;

            RouteAssert.RoutesTo(result.RouteValues, "List", "Carrier");
        }
        public async Task ReasonForExport_Post_BackToOverviewTrue_RedirectsToOverview()
        {
            var model = new ReasonForExportViewModel();

            var result = await reasonForExportController.Index(model, true) as RedirectToRouteResult;

            RouteAssert.RoutesTo(result.RouteValues, "Index", "Home");
        }
        public async Task<ActionResult> Index(Guid id, bool? backToOverview = null)
        {
            var reasonForExport = await mediator.SendAsync(new GetReasonForExport(id));

            var model = new ReasonForExportViewModel
            {
                NotificationId = id,
                ReasonForExport = reasonForExport
            };
            return View(model);
        }
Beispiel #9
0
        public async Task <ActionResult> Index(Guid id, bool?backToOverview = null)
        {
            var reasonForExport = await mediator.SendAsync(new GetReasonForExport(id));

            var model = new ReasonForExportViewModel
            {
                NotificationId  = id,
                ReasonForExport = reasonForExport
            };

            return(View(model));
        }
Beispiel #10
0
        public async Task <ActionResult> Index(ReasonForExportViewModel model, bool?backToOverview = null)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            try
            {
                var existingReasonForExport = await mediator.SendAsync(new GetReasonForExport(model.NotificationId));

                await
                mediator.SendAsync(new SetReasonForExport(model.NotificationId, model.ReasonForExport));

                await this.auditService.AddAuditEntry(this.mediator,
                                                      model.NotificationId,
                                                      User.GetUserId(),
                                                      existingReasonForExport == null?NotificationAuditType.Added : NotificationAuditType.Updated,
                                                      NotificationAuditScreenType.ReasonForExport);

                if (backToOverview.GetValueOrDefault())
                {
                    return(RedirectToAction("Index", "Home", new { id = model.NotificationId }));
                }

                return(RedirectToAction("List", "Carrier", new { id = model.NotificationId }));
            }
            catch (ApiBadRequestException ex)
            {
                this.HandleBadRequest(ex);
                if (ModelState.IsValid)
                {
                    throw;
                }
            }
            return(View(model));
        }
        public void InvalidReasonOfExport_ValidationError()
        {
            var viewModel = new ReasonForExportViewModel { ReasonForExport = invalidReasonOfExport };

            Assert.True(ViewModelValidator.ValidateViewModel(viewModel).Count > 0);
        }
        public void ValidReasonOfExport_NoValidationError()
        {
            var viewModel = new ReasonForExportViewModel { ReasonForExport = "valid value" };

            Assert.True(ViewModelValidator.ValidateViewModel(viewModel).Count == 0);
        }