Beispiel #1
0
        public async Task <ActionResult> Add([FromBody] ToDoItemAddDTO itemDto)
        {
            var item = new ToDoItem()
            {
                Name = itemDto.Name
            };
            await _todoRepository.AddAsync(item);

            return(Ok(item));
        }
        /// <summary>
        /// Handler which processes the command when create ToDoItem
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        public async Task <bool> Handle(CreateToDoItemCommand command, CancellationToken cancellationToken)
        {
            _logger.CreateLogger <CreateToDoItemCommand>().LogTrace("Create todo item start ......");

            var item = new ToDoItem(command.Title, command.Description);
            await _todoRepository.AddAsync(item);

            return(await Task.FromResult(true));

            //return await _todoRepository.UnitOfWork.SaveEntitiesAsync(cancellationToken);
        }