示例#1
0
        private async void getAllCountries()
        {
            CountryDataProvider cdp = new CountryDataProvider();

            try
            {
                countries = await cdp.getAllCountriesUrl();
            }
            catch
            {
                return;
            }
            CountryName.SelectedIndex = 0;
            var firstCounty = countries.OrderBy(kvp => kvp.Value.Name).First();

            CountryCode.Text    = firstCounty.Value.Alpha3;
            CountryId.Text      = firstCounty.Value.Id;
            CurrencyName.Text   = firstCounty.Value.CurrencyName;
            CurrencyId.Text     = firstCounty.Value.CurrencyId;
            CurrencySymbol.Text = firstCounty.Value.CurrencySymbol;

            ComboBoxItem countriesAll;

            foreach (var cur in countries.OrderBy(f => f.Value.Name))
            {
                countriesAll = new ComboBoxItem {
                    Content = cur.Value.Name
                };
                CountryName.Items.Add(countriesAll);
            }
        }
示例#2
0
        private async void getAllCurrencies()
        {
            CountryDataProvider cdp = new CountryDataProvider();

            try
            {
                allCountries = await cdp.getAllCountriesUrl();
            }
            catch
            {
                return;
            }
            ComboBoxItem currenciesNoDuplicates;
            string       lastCurrency = string.Empty;

            foreach (var cur in allCountries.OrderBy(f => f.Value.CurrencyName))
            {
                if (cur.Value.CurrencyName.ToLower() != lastCurrency.ToLower() && cur.Value.CurrencyName != "United States dollar")
                {
                    currenciesNoDuplicates = new ComboBoxItem {
                        Content = cur.Value.CurrencyName
                    };
                    CurrencyName.Items.Add(currenciesNoDuplicates);
                    lastCurrency = cur.Value.CurrencyName;
                }
            }
            CurrencyName.SelectedIndex = 44;
            getCountries();
        }
示例#3
0
        public void DispatchForEntity(VisitedPlaceDataObject entity, List <string> includes, IObjectsDataSet context, Dictionary <string, object> parameters, bool skipSecurity = false)
        {
            // Remember includes we've already dispatched so as to avoid multiple data fetches
            var dispatched = new HashSet <string>();

            // get (custom) prefetch list so we can skip the dispatch for stuff we already fetched
            var prefetches = PrefetchAssociations.Get("VisitedPlace", parameters);

            foreach (var include in includes)
            {
                string relation    = include.Split('.').First().ToLower();
                var    subincludes = DispatchPath.GetSubIncludes(relation, includes);

                if (relation.Contains(":"))
                {
                    relation = relation.Substring(relation.IndexOf(':') + 1);
                }

                if (dispatched.Contains(relation))
                {
                    continue;
                }

                dispatched.Add(relation);

                switch (relation)
                {
                case "userprofile":
                {
                    // custom code can implement IPrefetch<ORMVisitedPlace> and add prefetch info through PrefetchAssociations helper => if set, we skip the dispatch-fetch
                    if (prefetches.Contains("UserProfile"))
                    {
                        break;
                    }

                    try
                    {
                        var objectToFetch = UserProfileDataProvider.Get(new UserProfileDataObject(entity.UserProfileUri), null, subincludes, context, parameters, skipSecurity);
                        if (objectToFetch != null)
                        {
                            entity.ObjectsDataSet.Merge(objectToFetch.ObjectsDataSet);
                        }
                    }
                    catch (GOServerException e)
                    {
                        if (e.Reason != "accessDenied")
                        {
                            throw;
                        }
                    }
                    break;
                }

                case "country":
                {
                    // custom code can implement IPrefetch<ORMVisitedPlace> and add prefetch info through PrefetchAssociations helper => if set, we skip the dispatch-fetch
                    if (prefetches.Contains("Country"))
                    {
                        break;
                    }

                    if (entity.CountryURI != null)
                    {
                        try
                        {
                            var objectToFetch = CountryDataProvider.Get(new CountryDataObject((System.String)entity.CountryURI), null, subincludes, context, parameters, skipSecurity);
                            if (objectToFetch != null)
                            {
                                entity.ObjectsDataSet.Merge(objectToFetch.ObjectsDataSet);
                            }
                        }
                        catch (GOServerException e)
                        {
                            if (e.Reason != "accessDenied")
                            {
                                throw;
                            }
                        }
                    }
                    break;
                }

                case "place":
                {
                    // custom code can implement IPrefetch<ORMVisitedPlace> and add prefetch info through PrefetchAssociations helper => if set, we skip the dispatch-fetch
                    if (prefetches.Contains("Place"))
                    {
                        break;
                    }

                    if (entity.PlaceURI != null)
                    {
                        try
                        {
                            var objectToFetch = PlaceDataProvider.Get(new PlaceDataObject((System.String)entity.PlaceURI), null, subincludes, context, parameters, skipSecurity);
                            if (objectToFetch != null)
                            {
                                entity.ObjectsDataSet.Merge(objectToFetch.ObjectsDataSet);
                            }
                        }
                        catch (GOServerException e)
                        {
                            if (e.Reason != "accessDenied")
                            {
                                throw;
                            }
                        }
                    }
                    break;
                }

                default:
                    throw new ApplicationException("VisitedPlace Entity has no relation named " + relation);
                }
            }
        }
示例#4
0
        public void DispatchForEntityCollection(IEnumerable <VisitedPlaceDataObject> entities, List <string> includes, IObjectsDataSet context, Dictionary <string, object> parameters, bool skipSecurity = false)
        {
            // Remember includes we've already dispatched so as to avoid multiple data fetches
            var dispatched = new HashSet <string>();

            // get (custom) prefetch list so we can skip the dispatch for stuff we already fetched
            var prefetches = PrefetchAssociations.Get("VisitedPlace", parameters);

            foreach (var include in includes)
            {
                string relation    = include.Split('.').First().ToLower();
                var    subincludes = DispatchPath.GetSubIncludes(relation, includes);

                if (relation.Contains(":"))
                {
                    relation = relation.Substring(relation.IndexOf(':') + 1);
                }

                if (dispatched.Contains(relation))
                {
                    continue;
                }

                dispatched.Add(relation);

                switch (relation)
                {
                case "userprofile":
                {
                    // custom code can implement IPrefetch<ORMVisitedPlace> and add prefetch info through PrefetchAssociations helper => if set, we skip the dispatch-fetch
                    if (prefetches.Contains("UserProfile"))
                    {
                        break;
                    }

                    var filterparameters = new object[] { entities.Select(e => e.UserProfileUri).Distinct().ToArray() };
                    try
                    {
                        entities.First().ObjectsDataSet.Merge(UserProfileDataProvider.GetCollection(null, "(@0.Contains(outerIt.Uri))", filterparameters, null, 0, 0, subincludes, context, parameters, skipSecurity).ObjectsDataSet);
                    }
                    catch (GOServerException e)
                    {
                        if (e.Reason != "accessDenied")
                        {
                            throw;
                        }
                    }
                    break;
                }

                case "country":
                {
                    // custom code can implement IPrefetch<ORMVisitedPlace> and add prefetch info through PrefetchAssociations helper => if set, we skip the dispatch-fetch
                    if (prefetches.Contains("Country"))
                    {
                        break;
                    }

                    var filterparameters = new object[] { entities.Where(e => e.CountryURI != null).Select(e => (System.String)e.CountryURI).Distinct().ToArray() };
                    try
                    {
                        entities.First().ObjectsDataSet.Merge(CountryDataProvider.GetCollection(null, "(@0.Contains(outerIt.URI))", filterparameters, null, 0, 0, subincludes, context, parameters, skipSecurity).ObjectsDataSet);
                    }
                    catch (GOServerException e)
                    {
                        if (e.Reason != "accessDenied")
                        {
                            throw;
                        }
                    }
                    break;
                }

                case "place":
                {
                    // custom code can implement IPrefetch<ORMVisitedPlace> and add prefetch info through PrefetchAssociations helper => if set, we skip the dispatch-fetch
                    if (prefetches.Contains("Place"))
                    {
                        break;
                    }

                    var filterparameters = new object[] { entities.Where(e => e.PlaceURI != null).Select(e => (System.String)e.PlaceURI).Distinct().ToArray() };
                    try
                    {
                        entities.First().ObjectsDataSet.Merge(PlaceDataProvider.GetCollection(null, "(@0.Contains(outerIt.URI))", filterparameters, null, 0, 0, subincludes, context, parameters, skipSecurity).ObjectsDataSet);
                    }
                    catch (GOServerException e)
                    {
                        if (e.Reason != "accessDenied")
                        {
                            throw;
                        }
                    }
                    break;
                }

                default:
                    throw new ApplicationException("VisitedPlace Entity has no relation named " + relation);
                }
            }
        }