private RssSubscriptionIndexViewModel GetPersonSubscriptionIndexViewModel(long subscriptionId, ShowReadEntries showReadEntries)
        {
            var currentUserId = this.sessionProvider.GetCurrentUserId();

            if (!this.usersSubscriptionRepository.DoesUserOwnsSubscription(subscriptionId, currentUserId))
            {
                var ci = new ChannelInformationViewModel
                {
                    Title   = "You are not subscribed to this user",
                    Created = DateTime.MaxValue
                };

                var rssSubscriptionIndexViewModel =
                    new RssSubscriptionIndexViewModel(subscriptionId,
                                                      ci,
                                                      new List <RssEntryToReadViewModel>(),
                                                      StreamType.Person);
                return(rssSubscriptionIndexViewModel);
            }

            List <UserSubscriptionEntryToRead> loadAllUnreadEntriesFromSubscription;

            if (showReadEntries != ShowReadEntries.Show)
            {
                loadAllUnreadEntriesFromSubscription = this.usersSubscriptionRepository
                                                       .LoadAllUnreadEntriesFromSubscription(subscriptionId);
            }
            else
            {
                loadAllUnreadEntriesFromSubscription = this.usersSubscriptionRepository
                                                       .LoadAllEntriesFromSubscription(subscriptionId);
            }

            var channelInformation =
                this.usersSubscriptionRepository
                .LoadChannelInformation(subscriptionId);

            var channelInformationViewModel = new ChannelInformationViewModel
            {
                Title   = channelInformation.Title,
                Created = channelInformation.Created
            };

            var rssEntryToReadViewModels = this.mapper.Map <List <RssEntryToReadViewModel> >(loadAllUnreadEntriesFromSubscription);

            var viewModel = new RssSubscriptionIndexViewModel(
                subscriptionId,
                channelInformationViewModel,
                rssEntryToReadViewModels,
                StreamType.Person);

            return(viewModel);
        }
Exemplo n.º 2
0
        private RssSubscriptionIndexViewModel GetRssSubscriptionIndexViewModel(long subscriptionId, ShowReadEntries showReadEntries)
        {
            var currentUserId = this.sessionProvider.GetCurrentUserId();

            if (!this.rssSubscriptionsRepository.DoesUserOwnsSubscription(subscriptionId, currentUserId))
            {
                var ci = new ChannelInformationViewModel
                {
                    Title   = "You are not subscribed to this channel",
                    Created = DateTime.MaxValue
                };
                var rssSubscriptionIndexViewModel = new RssSubscriptionIndexViewModel(
                    subscriptionId,
                    ci,
                    new List <RssEntryToReadViewModel>(),
                    StreamType.Rss);
                return(rssSubscriptionIndexViewModel);
            }

            var loadAllRssEntriesForUserAndChannel = showReadEntries != ShowReadEntries.Show
                                                          ? this.rssToReadRepository.LoadAllUnreadEntriesFromSubscription(subscriptionId)
                                                          : this.rssToReadRepository.LoadAllEntriesFromSubscription(subscriptionId);

            var channelInformation          = this.rssSubscriptionsRepository.LoadChannelInformation(subscriptionId);
            var channelInformationViewModel = new ChannelInformationViewModel
            {
                Title   = channelInformation.Title,
                Created = channelInformation.Created
            };

            var rssEntryToReadViewModels = this.mapper.Map <List <RssEntryToReadViewModel> >(loadAllRssEntriesForUserAndChannel);

            var viewModel = new RssSubscriptionIndexViewModel(
                subscriptionId,
                channelInformationViewModel,
                rssEntryToReadViewModels,
                StreamType.Rss);

            viewModel.SubscriptionId = subscriptionId;
            return(viewModel);
        }