public SubscriptionSourceEntity AddSubscription(IVideoContentProvider video)
        {
            var owner = _nicoVideoOwnerRepository.Get(video.ProviderId);

            if (owner == null)
            {
                throw new Models.Infrastructure.HohoemaExpception("cannot resolve name for video provider from local DB.");
            }

            if (video.ProviderType == OwnerType.Channel)
            {
                return(AddSubscription_Internal(new SubscriptionSourceEntity()
                {
                    Label = owner.ScreenName, SourceParameter = video.ProviderId, SourceType = SubscriptionSourceType.Channel
                }));
            }
            else if (video.ProviderType == OwnerType.User)
            {
                return(AddSubscription_Internal(new SubscriptionSourceEntity()
                {
                    Label = owner.ScreenName, SourceParameter = video.ProviderId, SourceType = SubscriptionSourceType.User
                }));
            }
            else
            {
                throw new NotSupportedException(video.ProviderType.ToString());
            }
        }
Beispiel #2
0
 protected override async void Execute(object parameter)
 {
     (string id, SubscriptionSourceType sourceType, string label)result = parameter switch
     {
         IVideoContentProvider videoContent => videoContent.ProviderType switch
         {
             OwnerType.User => (id : videoContent.ProviderId, sourceType : SubscriptionSourceType.User, default(string)),
             OwnerType.Channel => (id : videoContent.ProviderId, sourceType : SubscriptionSourceType.Channel, default(string)),
             _ => throw new NotSupportedException()
         },