public ActionResult EditOrCreate(int?id) { AuthorsDTO author = new AuthorsDTO(); if (id != null) { author = authorService.GetAuthor(id); } return(View(author)); }
public void MakeAuthor(AuthorsDTO authorDto) { Authors author = new Authors { FirstName = authorDto.FirstName, LastName = authorDto.LastName, }; db.Authors.Create(author); db.Save(); }
public ActionResult EditOrCreate(Authors author) { if (author.Id != 0) { var tempAuthor = authorService.GetAuthor(author.Id); tempAuthor.FirstName = author.FirstName; tempAuthor.LastName = author.LastName; authorService.SaveUpdate(author); } else { var authorDto = new AuthorsDTO { LastName = author.LastName, FirstName = author.FirstName }; authorService.MakeAuthor(authorDto); } return(RedirectToActionPermanent("Index", "Author")); }