Beispiel #1
0
        /// <summary>
        /// Get campaign store by campaign id
        /// </summary>
        /// <param name="channelId"></param>
        /// <returns></returns>
        public List <ChannelStore> GetChannelStoreById(int channelId)
        {
            var metaData         = new LinqMetaData();
            var channelStoreList = metaData.ChannelStore.Where(e => e.ChannelId == channelId);
            var channelStoreSet  = new List <ChannelStore>();

            foreach (var item in channelStoreList)
            {
                var channelStore = new ChannelStore
                {
                    ChannelStoreId = item.ChannelStoreId,
                    CampaignId     = item.CampaignId,
                    ChannelId      = channelId,
                    StoreId        = item.StoreId,
                    DateAdded      = item.DateAdded,
                    IsSelected     = false
                };
                if (item.IsSelected == 1)
                {
                    channelStore.IsSelected = true;
                }
                channelStoreSet.Add(channelStore);
            }
            return(channelStoreSet);
        }
        public async Task DeleteChannelClearsEpisodes()
        {
            var channel = new Channel("link")
            {
                Id = 1
            };

            ChannelStore.GetAllAsync().Returns(new List <Channel>
            {
                channel
            });
            ChannelStore.Remove(Arg.Is(channel)).Returns(1);

            await PodcastViewModel.InitChannels();

            PodcastViewModel.Channels.Should().NotBeEmpty();
            PodcastViewModel.EpisodeList.MonitorEvents();

            await PodcastViewModel.DeleteChannel(channel);

            PodcastViewModel.EpisodeList.ShouldRaise("CollectionChanged")
            .WithSender(PodcastViewModel.EpisodeList)
            .WithArgs <NotifyCollectionChangedEventArgs>(args => args.Action == NotifyCollectionChangedAction.Reset);

            PodcastViewModel.Channels.Should().BeEmpty("the channel was deleted");
        }
Beispiel #3
0
        /// <summary>
        /// Get campaign store by channel id and store id.
        /// </summary>
        /// <param name="channelId"></param>
        /// <param name="storeId"></param>
        /// <returns></returns>
        public ChannelStore GetChannelStoreByStoreIdAndChannelId(int channelId, int storeId)
        {
            var metaData = new LinqMetaData();
            var store    = metaData.ChannelStore.FirstOrDefault(e => e.ChannelId == channelId && e.StoreId == storeId);

            if (store == null)
            {
                return(null);
            }

            var channelStore = new ChannelStore
            {
                ChannelStoreId = store.ChannelStoreId,
                ChannelId      = channelId,
                CampaignId     = store.CampaignId,
                StoreId        = storeId,
                DateAdded      = store.DateAdded,
                IsSelected     = false
            };

            if (store.IsSelected == 1)
            {
                channelStore.IsSelected = true;
            }

            return(channelStore);
        }
Beispiel #4
0
        internal void SetChannel(string server, string channel)
        {
            if (currentChannel != null && currentServer != null && ChannelLoaded)
            {
                IrcHandler.connectedServers[currentServer].channelBuffers[currentChannel].CollectionChanged -= ChannelView_CollectionChanged;
                store.TopicSetEvent -= ChannelView_TopicSetEvent;
            }

            var servers = IrcHandler.connectedServers;

            if (!servers.ContainsKey(server) || !servers[server].channelBuffers.ContainsKey(channel))
            {
                return;
            }

            currentServer  = server;
            currentChannel = channel;

            messagesView.ItemsSource = null;

            messagesView.ItemsSource = IrcHandler.connectedServers[currentServer].channelBuffers[currentChannel];

            store = IrcHandler.connectedServers[currentServer].channelStore[currentChannel];
            store.TopicSetEvent += ChannelView_TopicSetEvent;

            topicText.Text = store.Topic;

            IrcHandler.connectedServers[currentServer].channelBuffers[currentChannel].CollectionChanged += ChannelView_CollectionChanged;

            ScrollToBottom();
            ChannelLoaded = true;
            UpdateUi();
        }
Beispiel #5
0
 private void Unload()
 {
     if (ChannelLoaded)
     {
         messagesView.ItemsSource = null;
         store.TopicSetEvent     -= ChannelView_TopicSetEvent;
         store          = null;
         topicText.Text = "";
     }
 }
 public CacheClient(string prefix)
 {
     Prefix           = prefix;
     Channels         = new ChannelStore(this);
     EditableMessages = new EditableMessagesStore(this);
     Emojis           = new EmojiStore(this);
     Guilds           = new GuildStore(this);
     Members          = new MemberStore(this);
     Messages         = new MessageStore(this);
     Roles            = new RoleStore(this);
     Users            = new UserStore(this);
     VoiceStates      = new VoiceStateStore(this);
 }
 internal CacheClient(IClient client, string prefix)
 {
     Prefix           = prefix;
     Client           = client;
     Channels         = new ChannelStore(this);
     GuildChannels    = new GuildChannelStore(this);
     EditableMessages = new EditableMessagesStore(this);
     GuildEmojis      = new GuildEmojiStore(this);
     Guilds           = new GuildStore(this);
     GuildMembers     = new GuildMemberStore(this);
     Messages         = new MessageStore(this);
     GuildRoles       = new GuildRoleStore(this);
     Users            = new UserStore(this);
     VoiceStates      = new VoiceStateStore(this);
 }
        public async Task UpdateChannelsSavesEpisodes()
        {
            // channel
            var channel = new Channel("dummyLink");

            var newEpisode = new Episode
            {
                Title = "new episode"
            };
            var channels = new List <Channel>
            {
                channel
            };

            ChannelStore.GetAllAsync().Returns(channels);
            ChannelStore.GetChannelInfos().Returns(channels.Select(_ => new ChannelInfo
            {
                Id           = _.Id,
                FeedUrl      = _.Link,
                ImageUrl     = _.ImageUrl,
                EpisodeInfos = _.Episodes.Select(x => new EpisodeInfo
                {
                    Id   = x.Guid,
                    Date = x.Date
                })
            }));

            await PodcastViewModel.InitChannels();

            PodcastViewModel.FeedParser.LoadFeed(Arg.Any <string>()).Returns(new ItunesFeed());
            PodcastViewModel.FeedParser.ParseItems(Arg.Any <IEnumerable <ItunesItem> >(), Arg.Any <ChannelInfo>())
            .Returns(new[]
            {
                newEpisode
            });

            PodcastViewModel.UpdateCancelToken = new CancellationTokenSource();
            await PodcastViewModel.UpdateChannelsCommand.Execute();

            // assert
            await ChannelStore.Received(1).SaveEpisodes(Arg.Is <IEnumerable <Episode> >(_ => _.Contains(newEpisode)));

            //Repository.All<Episode>().Should().Contain(newEpisode);

            //await DbContext.Received(1).SaveChangesAsync();
        }
Beispiel #9
0
        /// <summary>
        ///     Load all channel stores from the database.
        /// </summary>
        /// <returns></returns>
        private ChannelStoreSet LoadChannelStoreSet()
        {
            var channelStoreSet = new ChannelStoreSet();

            // Get the collection from the ORM data layer
            var metaData = new LinqMetaData();
            IQueryable <ChannelStoreEntity> channelStores = from c in metaData.ChannelStore select c;

            var channelStoreCollection = ((ILLBLGenProQuery)channelStores).Execute <ChannelStoreCollection>();

            if (channelStoreCollection.Count > 0)
            {
                foreach (var channelStoreEntity in channelStoreCollection)
                {
                    var channelStore = new ChannelStore(channelStoreEntity);
                    channelStoreSet.Add(channelStore);
                }
            }
            return(channelStoreSet);
        }
        public async Task ChannelMoveTriggersReorder()
        {
            var channel1 = new Channel("DummyLink1")
            {
                OrderNumber = 1
            };

            var channel2 = new Channel("DummyLink2")
            {
                OrderNumber = 2
            };

            var channels = new List <Channel>
            {
                channel1,
                channel2
            };

            ChannelStore.GetAllAsync().Returns(channels);
            ChannelStore.ChangeOrderAsync(Arg.Is(channel1), Arg.Is(2)).Returns(Task.FromResult(2)).AndDoes(_ =>
            {
                channel1.OrderNumber = 2;
                channel2.OrderNumber = 1;
            });

            await PodcastViewModel.InitChannels();

            // move channel1 to second position (i.e. index 1)
            PodcastViewModel.Channels.Should().HaveCount(2);
            await PodcastViewModel.MoveItemToIndex(channel1, 2);

            // channel 2 is now in first position
            PodcastViewModel.ChannelView.First().Should().Be(channel2);
            // channel 1 is now in second position
            PodcastViewModel.ChannelView.Skip(1).First().Should().Be(channel1);
        }
        public async Task LoadChannelFromUrlParsesFeed()
        {
            PodcastViewModel.FeedParser = new FeedParser();

            ChannelStore.Add(Arg.Any <Channel>()).Returns(1);

            var testFeedPath = Path.GetFullPath(@"..\..\Assets\feed.xml");

            await PodcastViewModel.LoadChannelFromUrlCommand.Execute(testFeedPath);

            PodcastViewModel.Channels.Should().NotBeEmpty("channel was added");

            var channel = PodcastViewModel.Channels.First();

            channel.Description.Should().NotBeEmpty();
            channel.Title.Should().NotBeEmpty();
            channel.ImageUrl.Should().NotBeEmpty();
            channel.LastUpdated.Should().Should().NotBeNull();
            channel.Link.Should().NotBeEmpty();
            channel.Episodes.Should().NotBeEmpty();
            channel.ImageUrl.Should().NotBeEmpty();

            channel.Episodes.Should().NotBeEmpty();
        }
Beispiel #12
0
 /// <summary>
 /// Update a channel store object and persist changes into the database
 /// </summary>
 /// <param name="channelStore"></param>
 public void UpdateChannelStore(ChannelStore channelStore)
 {
     channelStore.Save();
 }
Beispiel #13
0
 /// <summary>
 /// Create a new channel store object and persist it into the database.
 /// </summary>
 /// <param name="channelStore">The channel item object</param>
 public ChannelStore AddChannelStore(ChannelStore channelStore)
 {
     channelStore.Save();
     return(channelStore);
 }