protected override async Task Handle(EditItem request, CancellationToken cancellationToken) { var accountPlan = await _accountPlanRepository.FindAccountPlanByAccountIdAsync(request.AccountId); var plan = await _planRepository.FindPlanByIdAsync(accountPlan.PlanId); var accountPlanAuthorization = new AccountPlanAuthorizationValidator(accountPlan, plan); var list = await _todoListRepository.FindTodoListIdByIdAsync(request.ListId); var item = await _todoListItemRepository.FindToDoListItemByIdAsync(request.ItemId); var todoListAuthorizationValidator = new TodoListAuthorizationValidator(list.Contributors, request.Email); if (todoListAuthorizationValidator.IsUserAuthorized()) { var dueDate = accountPlanAuthorization.CanAddDueDate() ? request.DueDate : null; item.Name = request.Name; item.Notes = request.Notes; item.DueDate = dueDate; item.EditItem(item); await _todoListItemRepository.SaveChangesAsync(); } }
protected async override Task Handle(MarkItemAsImportant request, CancellationToken cancellationToken) { var item = await _itemRepository.FindToDoListItemByIdAsync(request.ItemId); item.Important = request.Important; await _itemRepository.SaveChangesAsync(); }
protected override async Task Handle(TrashItem request, CancellationToken cancellationToken) { var item = await _listItemRepository.FindToDoListItemByIdAsync(request.ItemId); item.MoveToTrash(); await _listItemRepository.SaveChangesAsync(); }
public async Task Handle(SubItemCreated notification, CancellationToken cancellationToken) { var itemId = notification.SubItem.ListItemId.GetValueOrDefault(); var item = await _todoListItemRepository.FindToDoListItemByIdAsync(itemId); item.SetHasSubItems(true); await _todoListItemRepository.SaveChangesAsync(); }
public async Task Handle(SubItemMovedToTrash notification, CancellationToken cancellationToken) { var item = await _todoListItemRepository.FindToDoListItemByIdAsync(notification.ItemId.GetValueOrDefault()); var subItems = await _subItemRepository.FindAllSubItemsByListItemIdAsync(item.Id); item.SetHasSubItems(subItems.Count > 0); await _todoListItemRepository.SaveChangesAsync(); }
public async Task Handle(SubItemCreated notification, CancellationToken cancellationToken) { var item = await _todoListItem.FindToDoListItemByIdAsync(notification.SubItem.ListItemId.GetValueOrDefault()); var list = await _todoList.FindTodoListIdByIdAsync(item.ListId.GetValueOrDefault()); var contributorExceptYou = RemoveSelfFromContributorSignalRHelper.RemoveContributor(list, _httpContextAccessor.HttpContext.User.FindFirst(c => c.Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress").Value); await _hub.Clients.Users(contributorExceptYou).SendAsync("SubItemCreated", notification.SubItem); }
public async Task Handle(SubItemCreated notification, CancellationToken cancellationToken) { var subItems = await _subItemRepository.FindAllSubItemsByListItemIdAsync(notification.SubItem.ListItemId.GetValueOrDefault()); var listItem = await _listItemRepository.FindToDoListItemByIdAsync(notification.SubItem.ListItemId.GetValueOrDefault()); listItem.SetCompleted(subItems); await _listItemRepository.SaveChangesAsync(); }
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(ItemCompletedState request, CancellationToken cancellationToken) { var subItemCount = await _listItemRepository.GetSubItemCountAsync(request.ItemId); if (subItemCount > 0) { return; } var item = await _listItemRepository.FindToDoListItemByIdAsync(request.ItemId); if (request.Completed == true) { item.SetCompleted(); } else if (request.Completed == false) { item.SetNotCompleted(); } await _listItemRepository.SaveChangesAsync(); }