public IActionResult Post([FromBody] ProductBasicInfoPostDTO newProduct) { // Se añade un registro y se obtiene el id con el que se registró. int id = new ProductSC().AddNewProduct(newProduct); return(Created("GET " + Request.Path.Value + "/" + id, new { Id = id })); }
public IActionResult Post([FromBody] ProductBasicInfoPostDTO newProduct) { int id; try { id = new ProductSC().AddNewProduct(newProduct); } catch (Exception ex) when(ExceptionTypes.IsSqlException(ex)) { string message = SqlExceptionMessages.GetCustomSqlExceptionMessage(ex.InnerException as SqlException); if (message != null) { return(Conflict(message)); } throw; } return(Created("GET " + Request.Path.Value + "/" + id, id)); }