public async Task <Unit> Handle(EditSubItem request, CancellationToken cancellationToken) { var subItem = await _subItemRepository.FindByIdAsync(request.SubItemId); subItem.Name = request.Name; subItem.EditSubItem(subItem); await _subItemRepository.SaveChangesAsync(); return(Unit.Value); }
public async Task <SubItem> Handle(CreateSubItem request, CancellationToken cancellationToken) { var item = await _listItems.FindToDoListItemByIdAsync(request.ListItemId); var subItem = item.CreateSubItem(request.Name); subItem.Id = _subItems.NextId(); _subItems.Add(subItem); await _subItems.SaveChangesAsync(); return(subItem); }
protected override async Task Handle(SubItemCompletedState request, CancellationToken cancellationToken) { var subItem = await _subItems.FindByIdAsync(request.SubItemId); if (request.Completed) { subItem.SetCompleted(); } else { subItem.SetNotCompleted(); } await _subItems.SaveChangesAsync(); }