コード例 #1
0
        public WebResult<List<Item>> GetFeedItems(string connectionKey, Channel feed)
        {
            if (feed == null)
                return new WebResult<List<Item>>(WebResult.ErrorCodeList.INVALID_PARAMETER);

            EntityFramwork.User user = _sessionWrapper.GetUser(connectionKey);
            if (user == null) return new WebResult<List<Item>>(WebResult.ErrorCodeList.NOT_LOGUED);

            List<Item> items = new List<Item>();

            var dbItems = (from item in db.Items where item.id_channel == feed.Id select item).OrderByDescending(item => item.pubDate);
            foreach (var dbItem in dbItems)
            {
                if (items.Count() > 50) // totalement arbitraire
                    break;
                items.Add(new Item(dbItem, user));
            }

            return new WebResult<List<Item>>(items);
        }
コード例 #2
0
        public WebResult UnfollowFeed(string connectionKey, Channel feed)
        {
            EntityFramwork.User user = _sessionWrapper.GetUser(connectionKey);
            if (user == null) return new WebResult(WebResult.ErrorCodeList.NOT_LOGUED);

            var cxu = from item in db.ChannelXUsers where item.User == user && item.id_channel == feed.Id select item;

            if (cxu != null)
            {
                db.ChannelXUsers.DeleteAllOnSubmit(cxu);
                db.SubmitChanges();
                return new WebResult();
            }

            return new WebResult(WebResult.ErrorCodeList.CANNOT_GET_FEED);
        }
コード例 #3
0
        public WebResult RefreshFeed(Channel feed)
        {
            var chanToUpdate = (from chan in db.Channels where chan.id == feed.Id select chan).SingleOrDefault();

            if (chanToUpdate == null)
                return new WebResult(WebResult.ErrorCodeList.CANNOT_GET_FEED);
            RssFeedConverter.UpdateDBChannel(chanToUpdate);
            return new WebResult();
        }