public IActionResult Post(string id, [FromBody] Models.bankslip value) { if (!ModelState.IsValid) { return(UnprocessableEntity("Invalid bankslip provided.The possible reasons are: A field of the provided bankslip was null or with invalid values")); } try { if (value.Equals(null)) { return(BadRequest("Bankslip not provided in the request body")); } var model = _bankslipService.Pay(id, value); if (model == null) { return(NotFound("Bankslip not found with the specified id")); } return(StatusCode(204)); } catch (Exception) { return(UnprocessableEntity("Invalid bankslip provided.The possible reasons are: A field of the provided bankslip was null or with invalid values")); } }
public IActionResult Post([FromBody] Models.bankslip value) { if (!ModelState.IsValid) { return(UnprocessableEntity("Invalid bankslip provided.The possible reasons are: A field of the provided bankslip was null or with invalid values")); } try { if (value.Equals(null)) { return(BadRequest("Bankslip not provided in the request body")); } var newModel = _bankslipService.Add(value); //HttpContext.Response.StatusCode = Convert.ToInt16(HttpStatusCode.Created); return(StatusCode(201, newModel)); } catch (Exception ex) { return(UnprocessableEntity("Invalid bankslip provided.The possible reasons are: A field of the provided bankslip was null or with invalid values")); } }