public ActionResult Register(UserAccount user) { if (ModelState.IsValid) { var isExist = IsEmailExist(user.Email); if (isExist) { ModelState.AddModelError("EmailExist", "Email already exist"); return(View(user)); } using (OurContext db = new OurContext()) { db.users.Add(user); db.SaveChanges(); } ModelState.Clear(); ViewBag.Message = user.Email + " successfully registered."; } else { ModelState.AddModelError("", "Some error occurred"); } return(View()); }
public virtual bool Add(T entity) { ourContext.Set <T>().Add(entity); return(ourContext.SaveChanges() > 0); }