public IActionResult Put(int id, [FromBody] PublisherUpdateDTO publisher) { if (publisher == null) { return(BadRequest()); } if (publisher.Established < 1534 || publisher.Established > DateTime.Now.Year) { ModelState.AddModelError("Established", "Первое издательское агенство было основано в 1534 г."); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var publisherExists = _rep.PublisherExists(id); if (!publisherExists) { return(NotFound()); } _rep.UpdatePublisher(id, publisher); _rep.Save(); return(NoContent()); }
public IActionResult Put(int id, [FromBody] PublisherUpdateDTO publisher) { if (publisher == null) { return(BadRequest()); } if (publisher.Established < 1534) { ModelState.AddModelError("Established", "The first publishing house was founded in 1534."); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var publisherExists = _rep.PublisherExists(id); if (!publisherExists) { return(NotFound()); } _rep.UpdatePublisher(id, publisher); _rep.Save(); return(NoContent()); }