public IActionResult Post([FromBody] CustomerContactInfoPostDTO newCustomer) { // Se añade un registro y se obtiene el id con el que se registró. string id = new CustomerSC().AddNewCustomer(newCustomer); return(Created("GET " + Request.Path.Value + "/" + id, new { Id = id })); }
public IActionResult Post([FromBody] CustomerContactInfoPostDTO newCustomer) { string id; try { id = new CustomerSC().AddNewCustomer(newCustomer); } 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)); }