public IActionResult Post([FromBody] TaskWork taskWorkNew) { if (taskWorkNew.IsObjectNull()) { return(BadRequest(new { Message = "DeathDate object is null" })); } if (!ModelState.IsValid) { return(BadRequest(new { Message = "Invalid model object" })); } try { this.taskWorkBR.CreateTask(taskWorkNew); if (taskWorkNew.IsEmptyObject()) { return(BadRequest(new { Message = "Task Object is not Created" })); } return(CreatedAtRoute("TaskWorkById", new { id = taskWorkNew.Id }, taskWorkNew)); } catch (Exception ex) { return(StatusCode(500, new { Message = $"Internal server error: {ex.Message}" })); } }
public IActionResult Put(Guid id, [FromBody] TaskWork taskWork) { try { if (id.Equals(Guid.Empty)) { return(BadRequest(new { Message = "Id is Empty" })); } if (taskWork.IsObjectNull()) { return(BadRequest(new { Message = "Task Object is Null" })); } if (!ModelState.IsValid) { return(BadRequest(new { Message = "Invalid model object" })); } bool secuence = this.taskWorkBR.UdpdateTask(id, taskWork); if (!secuence) { return(NotFound()); } return(Ok(taskWork)); } catch (Exception ex) { return(StatusCode(500, new { Message = $"Internal server error: {ex.Message}" })); } }