public async Task <string> Handle(GetFeedRequest request, CancellationToken cancellationToken) { var userFeed = await _userFeedRepository.FindByIdentifierAsync(request.FeedIdentifier); if (userFeed == null) { _logger.LogInformation($"No user feed found with identifier: {request.FeedIdentifier}"); return(null); } var user = await _userAccountRepository.GetAsync(userFeed.UserAccountId); if (user == null) { _logger.LogInformation($"No user account found, associated with feed identifier: {request.FeedIdentifier}"); return(null); } var(items, _, _) = await _userItemRepository.GetItemsAsync(user, null, new UserItemFilter { DueToday = userFeed.FeedType == UserFeedType.Due, Overdue = true }); var itemHash = GenerateHash(items.Select(i => i.UserItemId).Append(DateTime.Today.GetHashCode())); if (userFeed.ItemHash != itemHash) { userFeed.ItemHash = itemHash; await _userFeedRepository.SaveAsync(userFeed); } return(_feedGenerator.GenerateFeed(request.BaseUri, userFeed.LastUpdateDateTime ?? userFeed.CreatedDateTime, items, userFeed).ToXmlString()); }
public async Task <bool> Handle(DeleteFeedRequest request, CancellationToken cancellationToken) { var user = await _userAccountRepository.GetUserAccountAsync(request.User); var userFeed = await _userFeedRepository.GetAsync(request.UserFeedId); if (userFeed == null || userFeed.UserAccountId != user.UserAccountId) { return(false); } userFeed.DeletedDateTime = DateTime.UtcNow; await _userFeedRepository.SaveAsync(userFeed); return(true); }