public IActionResult Post([FromBody] PublisherDTO DTO) { if (DTO == null) { return(BadRequest()); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var itemToCreate = Mapper.Map <Publisher>(DTO); _rep.Add(itemToCreate); if (!_rep.Save()) { return(StatusCode(500, "A problem occurred while handling your request.")); } var createdDTO = Mapper.Map <PublisherDTO>(itemToCreate); return(CreatedAtRoute("GetGenericPublisher", new { id = createdDTO.Id }, createdDTO)); }
public IActionResult Delete(int id) { if (!_rep.Exists <Cart>(id)) { return(NotFound()); } var entityToDelete = _rep.Get <Cart>(id); _rep.Delete(entityToDelete); if (!_rep.Save()) { return(StatusCode(500, "A problem occurred while handling your request.")); } return(NoContent()); }