コード例 #1
0
ファイル: Startup.cs プロジェクト: szymonworld/PZPP_RSS
        protected void CheckAndAddNews(List <Channel> news)
        {
            ChannelsContext                 con          = new ChannelsContext();
            RepositoryService <Channel>     channels     = new RepositoryService <Channel>(con);
            RepositoryService <ChannelItem> channelItems = new RepositoryService <ChannelItem>(con);

            foreach (var item in channelItems.GetAll())
            {
                item.State = false;
                channelItems.Edit(item);
            }

            channelItems.Save();

            foreach (var item in news)
            {
                bool found = false;

                foreach (var item2 in channels.GetAll())
                {
                    if (item2.Link == item.Link)
                    {
                        found = true;
                    }
                }

                if (!found)
                {
                    channels.Add(item);
                }
            }
        }