コード例 #1
0
ファイル: UnitTest1.cs プロジェクト: Lvdzandt/Webshop-S2
        public void CheckEmailTakenTest()
        {
            //arrange
            IAccountContext context = new TestDateContext();
            AccountLogic    logic   = new AccountLogic();
            string          email   = "*****@*****.**";

            //act
            bool checkAccountTaken = logic.CheckAccountTaken(context, email);

            //assert
            Assert.IsTrue(checkAccountTaken);
        }
コード例 #2
0
 public IActionResult Register(RegisterViewModel model)
 {
     if (!_accountLogic.CheckAccountTaken(model.Email))
     {
         if (model.Password.Length >= 8)
         {
             User user = new User(model.Email, model.Username, model.Birthday, model.Password, false);
             _accountLogic.RegisterAccount(user);
             return(RedirectToAction("Index", "Home"));
         }
         ModelState.AddModelError("", "Password is too short, it has to be at least 8 characters");
     }
     else
     {
         ModelState.AddModelError("", "Email has already been taken");
     }
     return(View(model));
 }