public IHttpActionResult CreateDocumentary(DocumentaryDto documentaryDto) { if (!ModelState.IsValid) { return(BadRequest()); } var documentary = Mapper.Map <DocumentaryDto, Documentary>(documentaryDto); _context.Documentaries.Add(documentary); _context.SaveChanges(); documentaryDto.Id = documentary.Id; return(Created(new Uri(Request.RequestUri + "/" + documentary.Id), documentaryDto)); }
public IHttpActionResult UpdateDocumentary(int id, DocumentaryDto documentaryDto) { if (!ModelState.IsValid) { return(BadRequest()); } var documentaryInDb = _context.Documentaries.SingleOrDefault(d => d.Id == id); if (documentaryInDb == null) { return(NotFound()); } Mapper.Map(documentaryDto, documentaryInDb); _context.SaveChanges(); return(Ok()); }