public async Task <IActionResult> Add([FromBody] TodoCreateDto newTodo) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } string email = Helper.GetEmail(HttpContext); var isSuccesful = await _repo.CreateTodo(newTodo, email); if (isSuccesful) { return(Ok("Todo added succesful")); } return(StatusCode(500)); }
public ActionResult CreateTodo(Todo todo) { _repository.CreateTodo(todo); return(CreatedAtRoute(nameof(GetTodoById), new { Id = todo.Id }, todo)); }