private AnalyticInfo GetOrCreateAnalyticInfo(string itemKey) { AnalyticInfo dataset = (from info in _context.AnalyticInfo where info.RowKey == itemKey select info).FirstOrDefault(); 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, }; _context.AddObject(DatasetInfoDataContext.AnalyticInfoTableName, dataset); _context.SaveChanges(); return(dataset); }
private AnalyticInfo GetOrCreateAnalyticInfo(string itemKey) { AnalyticInfo dataset = (from info in _context.AnalyticInfo where info.RowKey == itemKey select info).FirstOrDefault(); 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, }; _context.AddObject(DatasetInfoDataContext.AnalyticInfoTableName, dataset); _context.SaveChanges(); return dataset; }