public async override Task <bool> LoadDataAsync()
        {
            if (this.MyLocation.Longitude == 0 && this.MyLocation.Latitude == 0)
            {
                return(false);
            }

            dynamic apiDTO = await ApiMashInvoke.InvokeAsync <ExpandoObject>(
                ApiMashInvoke.ApiEndPointUriBuilder(ApiResources.EVENT_SEARCH,
                                                    new KeyValuePair <string, string>("app_key", ApiResources.APP_KEY),
                                                    new KeyValuePair <string, string>("longitude", this.MyLocation.Longitude.ToString()),
                                                    new KeyValuePair <string, string>("latitude", this.MyLocation.Latitude.ToString()),
                                                    new KeyValuePair <string, string>("max", "20"),
                                                    new KeyValuePair <string, string>("within", "1"),
                                                    new KeyValuePair <string, string>("category", this.Name.ToString())
                                                    ));



            var first = true;

            EventsInCategory.Clear();
            foreach (dynamic evnt in apiDTO.events)
            {
                //As per the data model the first item in the event collection is a summary object, I am skipping it...
                if (!first)
                {
                    var targetEvt = new EventViewModel()
                    {
                        MyLocation = this.MyLocation
                    };

                    targetEvt.LoadDataFromEventDTO(evnt.@event);

                    EventsInCategory.Add(targetEvt);
                }

                first = false;
            }


            this.IsDataLoaded = true;
            return(true);
        }
        public async override Task <bool> LoadDataAsync()
        {
            if (this.HasErrors)
            {
                return(false);
            }

            dynamic apiResult = await ApiMashInvoke.InvokeAsync <ExpandoObject>(
                ApiMashInvoke.ApiEndPointUriBuilder(ApiResources.EVENT_GET,
                                                    new KeyValuePair <string, string>("app_key", ApiResources.APP_KEY),
                                                    new KeyValuePair <string, string>("id", this.Id.ToString())));


            this.Locations.Clear();

            LoadDataFromEventDTO(apiResult.@event);

            this.IsDataLoaded = await this.MyLocation.LoadDataAsync();

            return(this.IsDataLoaded);
        }
示例#3
0
        private async Task <bool> LoadEventsFromCategories(string[] cat)
        {
            if (cat == null)
            {
                throw new ArgumentNullException();
            }


            dynamic apiResult = await ApiMashInvoke.InvokeAsync <ExpandoObject>(
                ApiMashInvoke.ApiEndPointUriBuilder(ApiResources.EVENT_SEARCH,
                                                    new KeyValuePair <string, string>("app_key", ApiResources.APP_KEY),
                                                    new KeyValuePair <string, string>("longitude", this.MyLocation.Longitude.ToString()),
                                                    new KeyValuePair <string, string>("latitude", this.MyLocation.Latitude.ToString()),
                                                    new KeyValuePair <string, string>("max", MAX_EVENTSPERCATEGORY.ToString()),
                                                    new KeyValuePair <string, string>("within", "1"),
                                                    new KeyValuePair <string, string>("category", string.Join(",", cat))
                                                    ));

            var first = true;

            foreach (dynamic evnt in apiResult.events)
            {
                //As per the data model the first item in the event collection is a summary object, I am skipping it...
                if (!first)
                {
                    var targetEvt = new EventViewModel();

                    targetEvt.LoadDataFromEventDTO(evnt.@event);

                    AddEventToCategory(targetEvt);
                }

                first = false;
            }

            return(true);
        }