Пример #1
0
        public async Task <IActionResult> CreateTodo(TodoDetailedDto todoDetailedDto)
        {
            var todo = _mapper.Map <TodoItem>(todoDetailedDto);

            _repo.Add(todo);

            if (await _repo.SaveAll())
            {
                return(StatusCode(201));
            }

            throw new Exception("Creating todo {id} failed on save!");
        }
Пример #2
0
        public async Task <IActionResult> UpdateTodo(string id, TodoDetailedDto todoDetailedDto)
        {
            var todo = await _repo.GetTodo(id);

            if (todo == null)
            {
                return(NotFound());
            }

            _mapper.Map(todoDetailedDto, todo);

            if (await _repo.SaveAll())
            {
                return(NoContent());
            }

            throw new Exception("Updating user {id} failed on save!");
        }