Пример #1
0
 public ActionResult Create(AccountCreationModel model)
 {
     if (!ModelState.IsValid)
         return View(model);
     var account = _accountRepository.Get.ByEmailAddress(model.EmailAddress);
     if (account != null && account.EmailAddress == model.EmailAddress)
     {
         //add a better message here...
         ModelState.AddModelErrorFor<AccountCreationModel, string>(m => m.EmailAddress,
                                                               "Email address already used, please specify another one.");
         return View(model);
     }
     var player = new Account
                      {
                          FirstName = model.FirstName,
                          LastName = model.LastName,
                          Password = model.Password,
                          EmailAddress = model.EmailAddress
                      };
     _accountRepository.Save(player);
     //TODO: Enable email activation
     return this.RedirectToAction<GameController>(m => m.Start());
 }
Пример #2
0
 public void SetUp()
 {
     var mother = new ObjectMother();
     _model = mother.GetValidAccount();
     _existingAccount = mother.GetAccountByEmailAddress(_model.EmailAddress);
     _newModel = mother.GetValidAccount();
     _newModel.EmailAddress = "*****@*****.**";
     _accountRepository = new InMemoryRepository<Account>(_existingAccount);
     _formsService = MockRepository.GenerateMock<IFormsService>();
     _playerRepository = MockRepository.GenerateMock<IRepository<Player>>();
     _controller = new AccountController(_accountRepository, _playerRepository, _formsService);
 }