Ejemplo n.º 1
0
        public async Task SendsRequestWithNotificationIdAndSelectedMovements()
        {
            CancelMovementsViewModel model = new CancelMovementsViewModel();

            model.NotificationId     = Guid.Empty;
            model.SubmittedMovements = new List <SubmittedMovement>
            {
                new SubmittedMovement {
                    IsSelected = true, MovementId = Guid.Empty, Number = 1
                },
                new SubmittedMovement {
                    IsSelected = false, MovementId = Guid.Empty, Number = 2
                },
                new SubmittedMovement {
                    IsSelected = true, MovementId = Guid.Empty, Number = 3
                }
            };

            var result = await controller.Index(model) as RedirectToRouteResult;

            Assert.NotNull(result);
            Assert.Equal("Confirm", result.RouteValues["action"]);
            Assert.Equal("CancelMovement", result.RouteValues["controller"]);
            Assert.Equal(model.NotificationId, result.RouteValues["notificationId"]);
        }
        public async Task<ActionResult> Index(Guid notificationId)
        {
            var result = await mediator.SendAsync(new GetSubmittedMovements(notificationId));

            var model = new CancelMovementsViewModel(notificationId, result);

            return View(model);
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> Index(Guid notificationId)
        {
            var result = await mediator.SendAsync(new GetSubmittedMovements(notificationId));

            var model = new CancelMovementsViewModel(notificationId, result);

            return(View(model));
        }
        public async Task<ActionResult> Index(CancelMovementsViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return await Index(model.NotificationId);
            }

            var selectedMovements = model.SubmittedMovements
                .Where(m => m.IsSelected)
                .Select(p => new MovementData { Id = p.MovementId, Number = p.Number })
                .ToList();

            TempData[SubmittedMovementListKey] = selectedMovements;

            return RedirectToAction("Confirm", "CancelMovement", new { notificationId = model.NotificationId });
        }
        public async Task WithoutSelectingMovements_NotValid()
        {
            CancelMovementsViewModel model = new CancelMovementsViewModel();
            model.NotificationId = Guid.Empty;
            model.SubmittedMovements = new List<SubmittedMovement>
            {
                new SubmittedMovement{ IsSelected = false, Number = 1},
                new SubmittedMovement{ IsSelected = false, Number = 2},
                new SubmittedMovement{ IsSelected = false, Number = 3}
            };

            controller.ModelState.AddModelError("test", "test");
            var result = await controller.Index(model) as ViewResult;
            Assert.False(controller.ModelState.IsValid);
            Assert.Equal(string.Empty, result.ViewName);
        }
        public async Task SendsRequestWithNotificationIdAndSelectedMovements()
        {
            CancelMovementsViewModel model = new CancelMovementsViewModel();
            model.NotificationId = Guid.Empty;
            model.SubmittedMovements = new List<SubmittedMovement>
            {
                new SubmittedMovement{ IsSelected = true, MovementId = Guid.Empty, Number = 1},
                new SubmittedMovement{ IsSelected = false, MovementId = Guid.Empty, Number = 2},
                new SubmittedMovement{ IsSelected = true, MovementId = Guid.Empty, Number = 3}
            };

            var result = await controller.Index(model) as RedirectToRouteResult;

            Assert.NotNull(result);
            Assert.Equal("Confirm", result.RouteValues["action"]);
            Assert.Equal("CancelMovement", result.RouteValues["controller"]);
            Assert.Equal(model.NotificationId, result.RouteValues["notificationId"]);
        }
Ejemplo n.º 7
0
        public async Task <ActionResult> Index(CancelMovementsViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(await Index(model.NotificationId));
            }

            var selectedMovements = model.SubmittedMovements
                                    .Where(m => m.IsSelected)
                                    .Select(p => new MovementData {
                Id = p.MovementId, Number = p.Number
            })
                                    .ToList();

            TempData[SubmittedMovementListKey] = selectedMovements;

            return(RedirectToAction("Confirm", "CancelMovement", new { notificationId = model.NotificationId }));
        }
Ejemplo n.º 8
0
        public async Task WithoutSelectingMovements_NotValid()
        {
            CancelMovementsViewModel model = new CancelMovementsViewModel();

            model.NotificationId     = Guid.Empty;
            model.SubmittedMovements = new List <SubmittedMovement>
            {
                new SubmittedMovement {
                    IsSelected = false, Number = 1
                },
                new SubmittedMovement {
                    IsSelected = false, Number = 2
                },
                new SubmittedMovement {
                    IsSelected = false, Number = 3
                }
            };

            controller.ModelState.AddModelError("test", "test");
            var result = await controller.Index(model) as ViewResult;

            Assert.False(controller.ModelState.IsValid);
            Assert.Equal(string.Empty, result.ViewName);
        }