Exemplo n.º 1
0
        private async Task LoadAsync()
        {
            IsLoading = true;
            TimelineListResponse response = await Api.GetTimelineListAsync(offset);

            Entries.AddRange(response.Entries);
            HasMore   = response.HasMore;
            offset    = Entries.Count;
            IsLoading = false;

            StateHasChanged();
        }
        //
        // GET: /Root/

        public ActionResult Index()
        {
            if (!Initialize())
            {
                return(Redirect(Url.Action("StartAuth", "Auth")));
            }

            IndexModel rootData = new IndexModel()
            {
                Message = Session["message"] as String
            };

            Session.Remove("message");

            var listRequest = Service.Timeline.List();

            listRequest.MaxResults = 3;
            TimelineListResponse items = listRequest.Fetch();

            rootData.TimelineItems = items.Items;

            try
            {
                Contact dotnetContact = Service.Contacts.Get(".NET Quick Start").Fetch();
                rootData.HasContact = dotnetContact != null;
            }
            catch (GoogleApiRequestException e)
            {
                // 404 on this request is an acceptable error, all the rest should be handled.
                if (e.RequestError.Code != (int)HttpStatusCode.NotFound)
                {
                    throw e;
                }
            }

            SubscriptionsListResponse subscriptions = Service.Subscriptions.List().Fetch();

            rootData.HasTimelineSubscription =
                subscriptions.Items.Any(x => x.Collection == "timeline");
            rootData.HasLocationSubscription =
                subscriptions.Items.Any(x => x.Collection == "locations");

            var location = Service.Locations.Get("latest").Fetch();

            rootData.Location     = string.Format("Latitude: {0}  Longitude: {1}  Time stamp: {2}", location.Latitude, location.Longitude, location.Timestamp);
            rootData.LocationLink = string.Format("http://maps.google.com/maps?z=12&t=m&q=loc:{0}+{1}", location.Latitude, location.Longitude);
            return(View(rootData));
        }
Exemplo n.º 3
0
        //
        // GET: /Root/

        public ActionResult Index()
        {
            if (!Initialize())
            {
                return(Redirect(Url.Action("StartAuth", "Auth")));
            }

            IndexModel rootData = new IndexModel()
            {
                Message = Session["message"] as String
            };

            Session.Remove("message");

            var listRequest = Service.Timeline.List();
            //listRequest.MaxResults = 3;

            TimelineListResponse items = listRequest.Fetch();

            rootData.TimelineItems = items.Items;


            /*
             * try
             * {
             *  Contact dotnetContact = Service.Contacts.Get("add_a_cat").Fetch();
             *  rootData.HasContact = dotnetContact != null;
             * }
             * catch (GoogleApiRequestException e)
             * {
             *  // 404 on this request is an acceptable error, all the rest should be handled.
             *  if (e.RequestError.Code != (int)HttpStatusCode.NotFound)
             *  {
             *      //throw e;
             *  }
             * }
             *
             * //TODO : Call to GG
             * SubscriptionsListResponse subscriptions = Service.Subscriptions.List().Fetch();
             *
             * rootData.HasTimelineSubscription =
             *  subscriptions.Items.Any(x => x.Collection == "timeline");
             * rootData.HasLocationSubscription =
             *  subscriptions.Items.Any(x => x.Collection == "locations");
             */

            return(View(rootData));
        }