public ActionResult CreateAccount(User ac) { ResponseRegister rp = new ResponseRegister(); var unitOfWork = new UnitOfWork(new QLBHDienThoaiEntities()); var validAccount = unitOfWork.Account.ValidAccount(ac); switch (validAccount) { case -1: { rp.Acc = ac; rp.Status = false; rp.Message = "Email đã tồn tại"; return(View("Register", rp)); } case 0: { rp.Acc = ac; rp.Status = false; rp.Message = "Username đã tồn tại"; return(View("Register", rp)); } } var response = AccountUtils.SendEmail(ac); if (response.Status == true) { ac.Code = response.Code; ac.IsLocked = true; ac.Status = false; ac.EmailConfirmed = false; unitOfWork.Account.Add(ac); unitOfWork.Complete(); Session[SessionKey.RegUser] = unitOfWork.Account.GetAccountByUsername(ac.Username, ac.Password); return(View("ConfirmEmail")); } else { return(RedirectToAction("Register")); } }