Esempio n. 1
0
        public async Task <TodoListModel> AddTodoList(long projectId, TodoListCreateModel todoList)
        {
            if (await _todoListRepository.ExistsByTitleAsync(projectId, todoList.Title))
            {
                throw new ModelValidationException(_titleExistMessage, nameof(todoList.Title));
            }

            var entity = new Entities.Todo.TodoList()
            {
                ProjectId = projectId,
                Title     = todoList.Title
            };

            _todoListRepository.Insert(entity);

            await _todoUnitOfWork.SaveChanges();

            return(_mapper.Map <TodoListModel>(entity));
        }
Esempio n. 2
0
        public async Task <IActionResult> CreateTodoList(long projectId, [FromBody] TodoListCreateModel value)
        {
            var result = await _todoService.AddTodoList(projectId, value);

            return(CreatedAtAction(nameof(GetTodoList), new { projectId, id = result.Id }, result));
        }