Exemplo n.º 1
0
        public async Task <List <BandEventBase> > GetUserActivity(int?topCount = null, DateTime?startDate = null, DateTime?endDate = null)
        {
            var url      = GET_USER_ACTIVITY_URL + GenerateEventsQuery(topCount, startDate, endDate, "TimeOfDay");
            var response = await AuthenticatedRequest(url);

            var rv = new List <BandEventBase>();

            dynamic json = JObject.Parse(response);

            var curDay = DateTime.MinValue;
            UserDailyActivity curActivity = null;

            foreach (var rawUserActivity in json.value)
            {
                if (curDay.Date != rawUserActivity.TimeOfDay.Value.Date)
                {
                    if (curActivity != null)
                    {
                        rv.Add(curActivity);
                    }

                    curActivity = UserDailyActivity.Create(rawUserActivity);

                    curDay = rawUserActivity.TimeOfDay.Value;
                }
                else
                {
                    curActivity.AddSegment(rawUserActivity);
                }
            }

            return(rv);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns a UserActivity object that tracks a User's activity across a given day
        /// </summary>
        /// <param name="json"></param>
        /// <returns></returns>
        public static UserDailyActivity Create(JObject json)
        {
            var activity = new UserDailyActivity(json);

            activity.Segments = new List<BandEventBase>();

            // add this as the first segment of the day
            activity.AddSegment(json);

            return activity;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Returns a UserActivity object that tracks a User's activity across a given day
        /// </summary>
        /// <param name="json"></param>
        /// <returns></returns>
        public static UserDailyActivity Create(JObject json)
        {
            var activity = new UserDailyActivity(json);

            activity.Segments = new List <BandEventBase>();

            // add this as the first segment of the day
            activity.AddSegment(json);

            return(activity);
        }