public bool UpdateWriter(WriterEdit model) { var entity = _context.Writers .Single(e => e.Id == model.Id && e.AuthorId == _authorId); entity.Name = model.Name; entity.Id = model.Id; return(_context.SaveChanges() == 1); }
public IHttpActionResult Put(WriterEdit writer) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateWriterService(); if (!service.UpdateWriter(writer)) { return(InternalServerError()); } return(Ok()); }