public IActionResult Post([FromBody] DeathDate deathDateNew) { if (deathDateNew.IsObjectNull()) { return(BadRequest(new { Message = "DeathDate object is null" })); } if (!ModelState.IsValid) { return(BadRequest(new { Message = "Invalid model object" })); } try { var secuence = this.deathDateBR.CreateDate(deathDateNew); if (!secuence) { return(BadRequest(new { Message = "DeathDate Object is not Created" })); } if (deathDateNew.IsEmptyObject()) { return(BadRequest(new { Message = "DeathDate Object is not Created" })); } return(CreatedAtRoute("DeathDateById", new { id = deathDateNew.Id }, deathDateNew)); } catch (Exception ex) { return(StatusCode(500, new { Message = $"Internal server error: {ex.Message}" })); } }
public IActionResult Put(Guid id, [FromBody] DeathDate deathDate) { try { if (id.Equals(Guid.Empty)) { return(BadRequest(new { Message = "Id is Empty" })); } if (deathDate.IsObjectNull()) { return(BadRequest(new { Message = "DeathDate Object is Null" })); } if (!ModelState.IsValid) { return(BadRequest(new { Message = "Invalid model object" })); } bool secuence = this.deathDateBR.UdpdateDate(id, deathDate); if (!secuence) { return(NotFound()); } return(Ok(deathDate)); } catch (Exception ex) { return(StatusCode(500, new { Message = $"Internal server error: {ex.Message}" })); } }