Ejemplo n.º 1
0
        public async Task <ActionResult> RecoveryPreconsent(Guid id, TrueFalseViewModel model,
                                                            bool?backToOverview = null)
        {
            if (!ModelState.IsValid || !model.Value.HasValue)
            {
                ViewBag.NotificationId = id;
                return(View(model));
            }

            var preconsentedFacilityData = await mediator.SendAsync(new GetIsPreconsentedRecoveryFacility(id));

            var isPreconsented = model.Value.Value;

            await mediator.SendAsync(new SetPreconsentedRecoveryFacility(id, isPreconsented));

            await this.auditService.AddAuditEntry(this.mediator,
                                                  id,
                                                  User.GetUserId(),
                                                  preconsentedFacilityData.IsPreconsentedRecoveryFacility == null?NotificationAuditType.Added : NotificationAuditType.Updated,
                                                  NotificationAuditScreenType.PreConsentedFacility);

            if (backToOverview.GetValueOrDefault())
            {
                return(RedirectToAction("Index", "Home", new { id }));
            }
            return(RedirectToAction("OperationCodes", "WasteOperations", new { id }));
        }
Ejemplo n.º 2
0
        public async Task RecoveryPreconsent_Post_BackToOverviewNull_RedirectToOperationCodes()
        {
            var model = new TrueFalseViewModel {
                Value = true
            };

            var result = await facilityController.RecoveryPreconsent(notificationId, model, null) as RedirectToRouteResult;

            RouteAssert.RoutesTo(result.RouteValues, "OperationCodes", "WasteOperations");
        }
Ejemplo n.º 3
0
        public async Task RecoveryPreconsent_Post_BackToOverviewTrue_RedirectsToOverview()
        {
            var model = new TrueFalseViewModel {
                Value = true
            };

            var result = await facilityController.RecoveryPreconsent(notificationId, model, true) as RedirectToRouteResult;

            RouteAssert.RoutesTo(result.RouteValues, "Index", "Home");
        }
Ejemplo n.º 4
0
        public async Task RecoveryPreconsent_PostInvalidModel_ReturnsView()
        {
            var model = new TrueFalseViewModel();

            facilityController.ModelState.AddModelError("Test", "Error");

            var result = await facilityController.RecoveryPreconsent(notificationId, model) as ViewResult;

            Assert.Equal(string.Empty, result.ViewName);
        }
Ejemplo n.º 5
0
        public async Task RecoveryPreconsent_PostValidModel_SetsPreconsentedFacility()
        {
            var model = new TrueFalseViewModel {
                Value = true
            };

            await facilityController.RecoveryPreconsent(notificationId, model);

            A.CallTo(
                () =>
                mediator.SendAsync(A <SetPreconsentedRecoveryFacility> .That.Matches(
                                       p => p.NotificationId == notificationId && p.IsPreconsentedRecoveryFacility)))
            .MustHaveHappened(Repeated.Exactly.Once);
        }
Ejemplo n.º 6
0
        public async Task <ActionResult> RecoveryPreconsent(Guid id, bool?backToOverview = null)
        {
            var preconsentedFacilityData =
                await mediator.SendAsync(new GetIsPreconsentedRecoveryFacility(id));

            if (preconsentedFacilityData.NotificationType == NotificationType.Disposal)
            {
                return(RedirectToAction("OperationCodes", "WasteOperations", new { id }));
            }

            var model = new TrueFalseViewModel {
                Value = preconsentedFacilityData.IsPreconsentedRecoveryFacility
            };

            return(View(model));
        }
        public async Task RecoveryPreconsent_Post_BackToOverviewNull_RedirectToOperationCodes()
        {
            var model = new TrueFalseViewModel { Value = true };

            var result = await facilityController.RecoveryPreconsent(notificationId, model, null) as RedirectToRouteResult;

            RouteAssert.RoutesTo(result.RouteValues, "OperationCodes", "WasteOperations");
        }
        public async Task RecoveryPreconsent_Post_BackToOverviewTrue_RedirectsToOverview()
        {
            var model = new TrueFalseViewModel { Value = true };

            var result = await facilityController.RecoveryPreconsent(notificationId, model, true) as RedirectToRouteResult;

            RouteAssert.RoutesTo(result.RouteValues, "Index", "Home");
        }
        public async Task RecoveryPreconsent_PostValidModel_SetsPreconsentedFacility()
        {
            var model = new TrueFalseViewModel { Value = true };

            await facilityController.RecoveryPreconsent(notificationId, model);

            A.CallTo(
                () =>
                    mediator.SendAsync(A<SetPreconsentedRecoveryFacility>.That.Matches(
                            p => p.NotificationId == notificationId && p.IsPreconsentedRecoveryFacility)))
                            .MustHaveHappened(Repeated.Exactly.Once);
        }
        public async Task RecoveryPreconsent_PostInvalidModel_ReturnsView()
        {
            var model = new TrueFalseViewModel();
            facilityController.ModelState.AddModelError("Test", "Error");

            var result = await facilityController.RecoveryPreconsent(notificationId, model) as ViewResult;

            Assert.Equal(string.Empty, result.ViewName);
        }
        public async Task<ActionResult> RecoveryPreconsent(Guid id, TrueFalseViewModel model,
            bool? backToOverview = null)
        {
            if (!ModelState.IsValid || !model.Value.HasValue)
            {
                ViewBag.NotificationId = id;
                return View(model);
            }

            var isPreconsented = model.Value.Value;

            await mediator.SendAsync(new SetPreconsentedRecoveryFacility(id, isPreconsented));

            if (backToOverview.GetValueOrDefault())
            {
                return RedirectToAction("Index", "Home", new { id });
            }
            return RedirectToAction("OperationCodes", "WasteOperations", new { id });
        }
        public async Task<ActionResult> RecoveryPreconsent(Guid id, bool? backToOverview = null)
        {
            var preconsentedFacilityData =
                await mediator.SendAsync(new GetIsPreconsentedRecoveryFacility(id));

            if (preconsentedFacilityData.NotificationType == NotificationType.Disposal)
            {
                return RedirectToAction("OperationCodes", "WasteOperations", new { id });
            }

            var model = new TrueFalseViewModel { Value = preconsentedFacilityData.IsPreconsentedRecoveryFacility };

            return View(model);
        }