Exemplo n.º 1
0
        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()
                       ));
        }
Exemplo n.º 2
0
        public async Task <bool> UpdateTodo(TodoUpdateDTO dto)
        {
            var rao = _mapper.Map <TodoUpdateRAO>(dto);

            if (await _repository.UpdateTodo(rao))
            {
                return(true);
            }


            throw new NotImplementedException();
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
 public UpdateTodoCommand(string?userLogin, int id, TodoUpdateDTO updateDTO) : base(userLogin)
 {
     Id        = id;
     UpdateDTO = updateDTO;
 }
Exemplo n.º 5
0
 public void Put(int todoId, [FromBody] TodoUpdateDTO todo)
 {
     _todoDataServices.UpdateTodo(todoId, todo);
 }