public async Task <ActionResult> UpdateTodo([FromRoute] int id, [FromBody] TodoUpdateDTO todoUpdateDto) { var request = new UpdateTodoCommand(User.Identity?.Name, id, todoUpdateDto); var response = await _mediator.Send(request); return(response.Match <ActionResult>( ok => NoContent(), notFound => NotFound() )); }
public async Task <bool> UpdateTodo(TodoUpdateDTO dto) { var rao = _mapper.Map <TodoUpdateRAO>(dto); if (await _repository.UpdateTodo(rao)) { return(true); } throw new NotImplementedException(); }
public Todo UpdateTodo(int id, TodoUpdateDTO todo) { var existing = _dbContext.Todos.Find(id); if (existing != null) { if (!string.IsNullOrEmpty(todo.Description) && !todo.Description.Equals(existing.Description)) { existing.Description = todo.Description; } if (!string.IsNullOrEmpty(todo.Title) && !todo.Title.Equals(existing.Title)) { existing.Title = todo.Title; } _dbContext.Entry(existing).State = EntityState.Modified; _dbContext.SaveChanges(); } return(existing); }
public UpdateTodoCommand(string?userLogin, int id, TodoUpdateDTO updateDTO) : base(userLogin) { Id = id; UpdateDTO = updateDTO; }
public void Put(int todoId, [FromBody] TodoUpdateDTO todo) { _todoDataServices.UpdateTodo(todoId, todo); }