Example #1
0
        public AddAccountProviderCommandHandlerTestsFixture()
        {
            Db       = new ProviderRelationshipsDbContext(new DbContextOptionsBuilder <ProviderRelationshipsDbContext>().UseInMemoryDatabase(Guid.NewGuid().ToString()).ConfigureWarnings(warnings => warnings.Throw(RelationalEventId.QueryClientEvaluationWarning)).Options);
            Account  = EntityActivator.CreateInstance <Account>().Set(a => a.Id, 1);
            User     = EntityActivator.CreateInstance <User>().Set(u => u.Ref, Guid.NewGuid());
            Provider = EntityActivator.CreateInstance <Provider>().Set(p => p.Ukprn, 12345678);

            Db.Accounts.Add(Account);
            Db.Users.Add(User);
            Db.Providers.Add(Provider);
            Db.SaveChanges();

            Command           = new AddAccountProviderCommand(Account.Id, Provider.Ukprn, User.Ref);
            Now               = DateTime.UtcNow;
            UnitOfWorkContext = new UnitOfWorkContext();
            Handler           = new AddAccountProviderCommandHandler(new Lazy <ProviderRelationshipsDbContext>(() => Db));
        }
Example #2
0
        public async Task <ActionResult> Add(AddAccountProviderViewModel model)
        {
            switch (model.Choice)
            {
            case "Confirm":
                var command           = new AddAccountProviderCommand(model.AccountId.Value, model.Ukprn.Value, model.UserRef.Value);
                var accountProviderId = await _mediator.Send(command);

                return(RedirectToAction("Added", new AddedAccountProviderRouteValues {
                    AccountProviderId = accountProviderId
                }));

            case "ReEnterUkprn":
                return(RedirectToAction("Find"));

            default:
                throw new ArgumentOutOfRangeException(nameof(model.Choice), model.Choice);
            }
        }