Exemplo n.º 1
0
        public async Task <IDataResult <TodoOutput> > Add(TodoAddInput addInput)
        {
            var todo = MapsterTool.Map <TodoAddInput, Todo>(addInput);

            todo.TodoItems.ToList().ForEach(t => t.Id = Guid.NewGuid());
            await _todoDal.Add(todo);

            var todoOutput = MapsterTool.Map <Todo, TodoOutput>(todo);

            return(new SuccessDataResult <TodoOutput>(todoOutput, Messages.Successfully));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Add([FromBody] TodoAddInput addInput)
        {
            var result = await _todoService.Add(addInput);

            if (!result.Success)
            {
                return(BadRequest(result.Message));
            }

            return(CreatedAtAction("GetTodo", new { todoId = result.Data.Id }, result.Data));
        }