public async Task AddSubscriberAsync(Guid remarkId, string userId) { var subsribers = await _repository.GetByIdAsync(remarkId); if (subsribers.HasNoValue) { Logger.Debug($"RemarkSubsribers not found for remarkId: {remarkId}. Creating new one."); subsribers = new RemarkSubscribers(remarkId); } subsribers.Value.AddSubscriber(userId); Logger.Debug($"Add subscriber. remarkId: {remarkId}, userId: {userId}"); await _repository.AddOrUpdateAsync(subsribers.Value); }
public static async Task AddOrUpdateAsync (this IMongoCollection <RemarkSubscribers> collection, RemarkSubscribers subscribers) => await collection.ReplaceOneAsync(x => x.RemarkId == subscribers.RemarkId, subscribers, new UpdateOptions { IsUpsert = true });
protected async Task <IEnumerable <UserNotificationSettings> > GetUsersAsync(RemarkSubscribers subscribers) => await _userNotificationSettingsService .BrowseSettingsAsync(subscribers.Users);
public async Task AddOrUpdateAsync(RemarkSubscribers subscribers) => await _database.RemarkSubscribers().AddOrUpdateAsync(subscribers);