Esempio n. 1
0
        public void PopulateList(
            IEnumerable <City> cities,
            IEnumerable <District> districts,
            IEnumerable <Position> positions)
        {
            foreach (var city in cities)
            {
                Cities.Add(new SelectListItem {
                    Value = city.Id.ToString(), Text = city.Name
                });
            }

            foreach (var district in districts)
            {
                Districts.Add(new SelectListItem {
                    Value = district.Id.ToString(), Text = district.Name
                });
            }

            foreach (var position in positions)
            {
                if (Positions.All(p => p.Id != position.Id))
                {
                    Positions.Add(new PositionViewModel {
                        Id = position.Id, Name = position.Name, Selected = false
                    });
                }
            }
            Positions.Sort((x, y) => x.Id - y.Id);
        }
Esempio n. 2
0
        public void PopulateLocationList(IEnumerable <City> cities, IEnumerable <District> districts)
        {
            foreach (var city in cities)
            {
                Cities.Add(new SelectListItem {
                    Value = city.Id.ToString(), Text = city.Name
                });
            }

            foreach (var district in districts)
            {
                Districts.Add(new SelectListItem {
                    Value = district.Id.ToString(), Text = district.Name
                });
            }
        }
Esempio n. 3
0
        private async void GetDistrict()
        {
            var client = new RestClient("https://www.happybi.com.tw/api/district");

            var request = new RestRequest(Method.GET);

            request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
            request.AddHeader("Accept", "application/json");

            IRestResponse response = client.Execute(request);

            if (response.Content != null)
            {
                try
                {
                    List <District> districtList = JsonConvert.DeserializeObject <List <District> >(response.Content);

                    var districtDic = new Dictionary <int, string>();

                    Districts.Add(new District
                    {
                        id   = 0,
                        name = "所有地區",
                    });
                    foreach (var dis in districtList)
                    {
                        districtDic.Add(dis.id, dis.name);
                        Districts.Add(dis);
                    }

                    DistrictDictionary = districtDic;
                }
                catch (Exception ex)
                {
                    await App.Current.MainPage.DisplayAlert("Decode Problem", ex.ToString(), "OK");
                }
            }
        }
Esempio n. 4
0
        public void Add(District district)
        {
            Districts.Add(district);

            PlaceUtil.Add(this, district);
        }