public ActionResult SignUp(Author author) { var authorInDb = db.Authors .Where(a => a.Name == author.Name || a.LastName == author.LastName) .ToList() .Count; try { if (authorInDb == 0) { // TODO: Add insert logic here db.Authors.Add(author); db.SaveChanges(); var model = new ArticleAuthorViewModel { Author = author }; return(View("LoginSuccess", model)); } return(View("SignUp")); } catch { return(View("SignUp")); } }
public ActionResult LogIn(Author author) { var model = db.Authors.ToList().SingleOrDefault(a => a.Name == author.Name || a.LastName == author.LastName); if (model != null) { ArticleAuthorViewModel viewmodel = new ArticleAuthorViewModel { Author = model }; Session["id"] = model.Id; Session["authorname"] = model.Name; return(View("LoginSuccess", viewmodel)); } return(View("Login")); }