public ActionResult <Task <TodoDTO> > Put([FromQuery] string TodoId, [FromBody] UpdateTodoDTO todo) { try { _todoService.UpdateAsync(TodoId, todo); } catch (TodoValidationException todoValidationEx) when(todoValidationEx.InnerException is NotFoundUserException) { return(NotFound(todoValidationEx.InnerException.Message)); } catch (TodoDIException diEx) { return(Problem(diEx.Message)); } return(NoContent()); }
public async Task <UpdateTodoDTO> UpdateAsync(string TodoId, UpdateTodoDTO todo) { var existingTodo = _todoRepository.FindById(TodoId); if (existingTodo == null) { return(await Task.FromResult(todo)); } try { var mappingTest = _mapper.Map <UpdateTodoDTO, Todo>(todo); await _todoRepository.ReplaceOneAsync(mappingTest); // await _unitOfWork.CompleteAsync(); return(await Task.FromResult(todo)); } catch (Exception ex) { // return new ProductResponse($"An error occurred when updating the product: {ex.Message}"); return(await Task.FromResult(todo)); } }
public async Task <Todo> Update(UpdateTodoDTO dto) { //TODO: wire this up. throw new NotImplementedException(); }