Example #1
0
        public List<Activity> GetActivities(HashSet<string> ids, string appId, HashSet<String> fields, CollectionOptions options)
        {
            var activityList = new List<ActivityRow>();
            using (var db = new AzureRayaDataContext())
            {
                foreach (var id in ids)
                {
                    if (string.IsNullOrEmpty(appId))
                    {
                        var activities = db.activities
                            .Where(x => x.PartitionKey == id);
                        foreach (var row in activities)
                        {
                            activityList.Add(row);
                        }

                    }
                    else
                    {
                        var activities = db.activities
                            .Where(x => x.PartitionKey == id && x.app_id == appId);
                        foreach (var row in activities)
                        {
                            activityList.Add(row);
                        }
                    }

                }
            }
            
            IEnumerable<ActivityRow> ordered = activityList.OrderByDescending(x => x.id);
            int first = options.getFirst();
            int max = options.getMax();
            if (first != 0)
            {
                ordered = ordered.Skip(first);
            }
            if (max != 0)
            {
                ordered = ordered.Take(max);
            }
            List<Activity> actList = new List<Activity>();
            foreach (var row in ordered)
            {
                actList.Add(ConvertToActivity(row));
            }
            return actList;
        }
Example #2
0
        public List<Activity> GetActivities(HashSet<string> ids, string appId, HashSet<String> fields, CollectionOptions options) 
        {
            var activities = db.activities
                .OrderByDescending(x => x.id)
                .Where(x => ids.AsEnumerable().Contains(x.person_id.ToString()) && (string.IsNullOrEmpty(appId)?true:x.app_id.ToString() == appId));

            int first = options.getFirst();
            int max = options.getMax();
            if (first != 0)
            {
                activities = activities.Skip(first);
            }
            if (max != 0)
            {
                activities = activities.Take(max);
            }
            List<Activity> actList = new List<Activity>();
            foreach (var row in activities)
            {
                var act = new Activity(row.id.ToString(), row.person_id.ToString());
                act.streamTitle = "activities";
                act.title = row.title;
                act.body = row.body;
                act.postedTime = row.created;
                act.mediaItems = GetMediaItems(row.id.ToString());
                actList.Add(act);
            }
            return actList;
        }