public ActionResult Add([Required][FromBody] AddAuthorVM author) { if (string.IsNullOrEmpty(author.Trigram)) { return(BadRequest()); } UnitOfWork.AuthorRepository.Add(new Author { LastName = author.LastName, FirstName = author.FirstName, Trigram = author.Trigram.ToUpper() }); return(Ok()); }
public ActionResult Update([Required][FromBody] AddAuthorVM author) { if (string.IsNullOrEmpty(author.Trigram)) { return(BadRequest()); } var existingAuthor = UnitOfWork.AuthorRepository.Get(x => x.Trigram.ToLower().Equals(author.Trigram.ToLower()), null); if (existingAuthor == null) { return(BadRequest()); } existingAuthor.FirstName = author.FirstName; existingAuthor.LastName = author.LastName; UnitOfWork.AuthorRepository.Update(existingAuthor); return(Ok()); }