public ActionResult Index(string author) { // Author newAuthor = new Author(author); // newAuthor.Save(); List <Author> allAuthors = Author.GetAll(); return(View(allAuthors)); }
public static Author CheckDuplicate(Author checkAuthor) { List <Author> allAuthors = Author.GetAll(); bool isInDB = false; foreach (Author author in allAuthors) { if (author.GetFirstName() == checkAuthor.GetFirstName() && author.GetLastName() == checkAuthor.GetLastName()) { isInDB = true; checkAuthor.SetId(author.GetId()); } } if (!isInDB) { checkAuthor.Save(); } return(checkAuthor); }