public IActionResult Create(Author author) { if (ModelState.IsValid) { _context.Author.Add(author); _context.SaveChanges(); return RedirectToAction("Index"); } return View(author); }
private Author GetOrCreateAuthor(string authorName) { var author = this.bookStoreDbContext.Authors .FirstOrDefault(a => a.Name == authorName); if (author == null) { author = new Author() { Name = authorName }; } return author; }