public static void Update(string baseUri, AnalyticInfo value)
 {
     var fmt = new NumberFormatInfo() { NumberDecimalSeparator = "." };
     var uri = new Uri(
         baseUri + "AnalyticInfo/?" +
         "update=" + value.RowKey + "&" +
         "views_total=" + value.views_total + "&" +
         "views_today=" + value.views_today + "&" +
         "views_average=" + value.views_average.ToString(fmt) + "&" +
         "last_viewed=" + value.last_viewed.ToString("yyyy-MM-dd HH:mm:ss") + "&" +
         "positive_votes=" + value.PositiveVotes + "&" +
         "negative_votes=" + value.NegativeVotes
         );
     var webRequest = HttpWebRequest.Create(uri);
     var response = webRequest.GetResponse();
     var responseStream = response.GetResponseStream();
 }
 public static IQueryable<AnalyticInfo> GetAllAnalyticInfos(string baseUri)
 {
     var uri = new Uri(baseUri + "AnalyticInfo");
     var webRequest = HttpWebRequest.Create(uri);
     var response = webRequest.GetResponse();
     var responseStream = response.GetResponseStream();
     var feed = XElement.Load(XmlReader.Create(responseStream));
     var qlist = feed.Elements("entityset");
     var list = new List<AnalyticInfo>();
     foreach (var el in qlist)
     {
         var ai = new AnalyticInfo(XAttrToStr(el.Attribute("name")));
         ai.views_total = XAttrToInt(el.Attribute("views_total"));
         ai.views_today = XAttrToInt(el.Attribute("views_today"));
         ai.views_average = XAttrToInt(el.Attribute("views_average"));
         ai.last_viewed = XAttrToDateTime(el.Attribute("last_viewed"));
         ai.PositiveVotes = XAttrToInt(el.Attribute("positive_votes"));
         ai.NegativeVotes = XAttrToInt(el.Attribute("negative_votes"));
         list.Add(ai);
     }
     return list.AsQueryable<AnalyticInfo>();
 }
        private AnalyticInfo GetOrCreateAnalyticInfo(string itemKey)
        {
            AnalyticInfo dataset = AnalyticInfoStorage.GetAnalyticInfo(_context.BaseUri.OriginalString, itemKey);

            if (dataset != null)
            {
                return(dataset);
            }

            var initialViewCount = new Random().Next(3, 12); // This is to attract users.

            dataset = new AnalyticInfo(itemKey)
            {
                last_viewed   = DateTime.Now,
                views_today   = initialViewCount,
                views_total   = initialViewCount,
                views_average = initialViewCount,
                NegativeVotes = 0,
                PositiveVotes = 0,
            };

            AnalyticInfoStorage.AddAnalyticInfo(_context.BaseUri.OriginalString, itemKey);
            return(dataset);
        }
        private AnalyticInfo GetOrCreateAnalyticInfo(string itemKey)
        {
            AnalyticInfo dataset = AnalyticInfoStorage.GetAnalyticInfo(_context.BaseUri.OriginalString, itemKey);

            if (dataset != null)
                return dataset;

            var initialViewCount = new Random().Next(3, 12); // This is to attract users.
            dataset = new AnalyticInfo(itemKey)
                        {
                            last_viewed = DateTime.Now,
                            views_today = initialViewCount,
                            views_total = initialViewCount,
                            views_average = initialViewCount,
                            NegativeVotes = 0,
                            PositiveVotes = 0,
                        };

            AnalyticInfoStorage.AddAnalyticInfo(_context.BaseUri.OriginalString, itemKey);
            return dataset;
        }