public virtual async Task SubscribeAsync(SubscriptionsGetByNameDto subscriptionsGetByName) { var isSubscribed = await _userSubscribeRepository .UserSubscribeExistsAysnc(subscriptionsGetByName.NotificationName, CurrentUser.GetId()); if (!isSubscribed) { UserSubscribe userSubscribe = new UserSubscribe( subscriptionsGetByName.NotificationName, CurrentUser.GetId(), CurrentUser.UserName, CurrentTenant.Id); await _userSubscribeRepository.InsertAsync(userSubscribe, true); } }
public virtual async Task InsertUserSubscriptionAsync( Guid?tenantId, UserIdentifier identifier, string notificationName, CancellationToken cancellationToken = default) { using (var unitOfWork = _unitOfWorkManager.Begin()) using (_currentTenant.Change(tenantId)) { var userSubscription = new UserSubscribe(notificationName, identifier.UserId, identifier.UserName, tenantId) { CreationTime = _clock.Now }; await _userSubscribeRepository .InsertAsync(userSubscription, cancellationToken : cancellationToken); await unitOfWork.SaveChangesAsync(cancellationToken); } }