public IActionResult PostSubTask([FromBody] SubTask subTaskModel) { try { if (subTaskModel != null && subTaskModel.TaskId != 0) { _subTaskRepository.Add(subTaskModel); UpdateTask(subTaskModel.TaskId); return(StatusCode(StatusCodes.Status201Created)); } else { if (subTaskModel.TaskId == 0) { _logger.LogWarning("Subtask must have a parent task ID"); return(StatusCode(StatusCodes.Status206PartialContent)); } else { _logger.LogWarning("Empty sub task Object passed as a parameter"); } return(StatusCode(StatusCodes.Status204NoContent)); } } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, ex)); } }
public bool Add(SubTask subtask) { var mainTask = _mainTaskRepository.FindBy(subtask.MainTaskId); if (mainTask == null) { return(false); } return(_subTaskRepository.Add(subtask) > 0); }
private async void AddSubTask() { string[] subTasks = SubTaskText.Split( new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None); foreach (string item in subTasks) { await subTaskRepository.Add(new SubTask { ProjectTaskId = ProjectTaskId, Name = item, IsComplete = false }); } subTaskText = null; Close(); }
public IActionResult Post(SubTask subTask) { _subTaskRepo.Add(subTask); return(CreatedAtAction("Get", new { id = subTask.Id }, subTask)); }