public ActionResult Register(RegistreerModel model) { if (ModelState.IsValid) { bool isvalid = false; isvalid = accountRepository.CreateAccount(model); if (isvalid) { return(RedirectToAction("index", "home")); } else { ModelState.AddModelError("ExistError", "Email address already exists"); } } return(View(model)); }
public bool CreateAccount(RegistreerModel model) { Account account = db.Accounts.Where(a => a.EmailAddress == model.EmailAddress).FirstOrDefault(); if (account == null) { account = new Account(); account.Name = model.Name; account.PhoneNumber = model.PhoneNumber; account.EmailAddress = model.EmailAddress; account.Password = model.Password; db.Accounts.Add(account); db.SaveChanges(); return(true); } else { return(false); } }