public async Task RedirectsToReviewAccess_ForSharedUserEmail()
        {
            var model = new ChangeOwnerViewModel(this.notificationId);

            model.EmailAddress = externalUserEmail;

            A.CallTo(
                () =>
                mediator.SendAsync(A <ExternalUserExists> .That.Matches(p => p.EmailAddress == externalUserEmail.ToString())))
            .Returns(true);

            A.CallTo(
                () => mediator.SendAsync(A <GetSharedUsersByNotificationId> ._)).Returns(new List <NotificationSharedUser>
            {
                new NotificationSharedUser
                {
                    Id    = new Guid("4345FB05-F7DF-4E16-939C-C09FCA5C7D7B"),
                    Email = "test1.fake.com"
                },
                new NotificationSharedUser
                {
                    Id    = new Guid("29B0D09E-BA77-49FB-AF95-4171408C07C9"),
                    Email = externalUserEmail
                }
            });

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

            Assert.True(ViewModelValidator.ValidateViewModel(model).Count == 0);

            Assert.Equal("ReviewAccess", result.RouteValues["action"]);
        }
        public async Task <ActionResult> Index(ChangeOwnerViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var userExists = await mediator.SendAsync(new ExternalUserExists(model.EmailAddress));

            if (!userExists)
            {
                ModelState.AddModelError("EmailAddress",
                                         "The email address you have entered is not registered in IWS Online");
                return(View(model));
            }

            var existingSharedUsers = await mediator.SendAsync(new GetSharedUsersByNotificationId(model.NotificationId));

            if (existingSharedUsers.Count(p => p.Email == model.EmailAddress) > 0)
            {
                return(RedirectToAction("ReviewAccess", new { id = model.NotificationId }));
            }

            TempData["EmailAddress"] = model.EmailAddress;

            return(RedirectToAction("Confirm", new { id = model.NotificationId }));
        }
Exemplo n.º 3
0
        public static IMvvmBinder GetNewChangeOwnerView(object arg)
        {
            ////IDataContext dc = new UnitTextConnectionDataContext();
            IDataContext dc = new HVCC.Shell.Models.HVCCDataContext() as IDataContext;
            IViewModel   vm = new ChangeOwnerViewModel(dc, arg)
            {
                Caption = "Change Owner"
            };
            IView v = new HVCC.Shell.Views.ChangeOwnerView(vm);

            return(new MvvmBinder(dc, v, vm));
        }
        public async Task ThrowsError_ForInValidEmail()
        {
            var model = new ChangeOwnerViewModel(this.notificationId);

            model.EmailAddress = externalUserEmail;

            A.CallTo(
                () =>
                mediator.SendAsync(A <ExternalUserExists> .That.Matches(p => p.EmailAddress == externalUserEmail.ToString())))
            .Returns(false);
            var result = await changeOwnerController.Index(model) as ViewResult;

            Assert.True(result.ViewData.ModelState.Count == 1);
        }
        public ActionResult Index(Guid id)
        {
            var model = new ChangeOwnerViewModel(id);

            return(View(model));
        }