public ActionResult Create(UserNewViewModel userViewModel)
        {
            if (ModelState.IsValid)
            {
                var domainUser = new User();
                domainUser.Id       = Guid.NewGuid();
                domainUser.Name     = userViewModel.Name;
                domainUser.Email    = userViewModel.Email;
                domainUser.Password = userViewModel.Password;

                using (var uow = context.CreateUnitOfWork())
                {
                    userRepo.Create(domainUser);

                    uow.SaveChanges();
                }

                return(RedirectToAction("Index"));
            }
            return(View(userViewModel));
        }
Ejemplo n.º 2
0
        public void CommandWithoutTransaction()
        {
            var factory        = Substitute.For <IConnectionFactory>();
            var connectionMock = Substitute.For <IDbConnection>();
            var command        = Substitute.For <IDbCommand>();

            connectionMock.CreateCommand().Returns(command);
            var transaction = Substitute.For <IDbTransaction>();

            connectionMock.BeginTransaction().Returns(transaction);
            factory.Create().Returns(connectionMock);

            var context = new AdoNetContext(factory);

            context.CreateUnitOfWork().Dispose();
            var cmd = context.CreateCommand();

            Assert.NotSame(transaction, cmd.Transaction);
        }