public IActionResult Delete([FromBody] Task task) { if (task.Id > 0) { return(Ok(_unitOfWork.Task.Delete(task ))); } else { return(BadRequest()); } }
public IActionResult Put([FromBody] Task task) { try { if (ModelState.IsValid && _unitOfWork.Task.Update(task)) { return(Ok(new { Message = "La tarea se ha actualizado" })); } else { return(BadRequest()); } } catch (Exception ex) { return(StatusCode(500, "Internal server error: " + ex.Message)); } }
public IActionResult Post([FromBody] Task task) { try { if (!ModelState.IsValid) { return(BadRequest()); } int idTask = _unitOfWork.Task.Insert(task); //Debemos insertar en ManagementTask ManagementTask mt = new ManagementTask { IdManagement = task.IdManagement, IdTask = idTask }; return(Ok(_unitOfWork.ManagementTask.Insert(mt))); } catch (Exception ex) { return(StatusCode(500, "Internal server error: " + ex.Message)); } }