public static Microdistrict[] GetMicrodistricts(Borough borough)
 {
     return(new Microdistrict[]
     {
         new Microdistrict("Взлетка"),
         new Microdistrict("Северный")
     });
 }
示例#2
0
        public List <IEntity> GetMicrodistricts(Borough borough)
        {
            List <IEntity> res  = new List <IEntity>();
            List <IEntity> temp = GetReferencedEntities("Microdistricts", "BoroughID", borough.ID);

            foreach (SimpleEntity se in temp)
            {
                res.Add(new Microdistrict(se.Name)
                {
                    ID = se.ID
                });
            }

            return(res);
        }
        public void AddItem(object o)
        {
            // FIX: check if contains

            if (CurrentItem == null)
            {
                return;
            }

            CurrentItem.IsExpanded = true;
            string newItemName = (o as string).Trim();

            if (String.IsNullOrEmpty(newItemName))
            {
                return;
            }

            int     newRecordId;
            IEntity newEntity;

            if (CurrentItem is CountryGroupViewModel)
            {
                newEntity    = new Country(newItemName);
                newRecordId  = RegionsDatabaseDirectory.Insert(newEntity, null);
                newEntity.ID = newRecordId;
                CurrentItem.Children.Add(new CountryViewModel(newEntity as Country));
            }

            else if (CurrentItem is CountryViewModel)
            {
                newEntity    = new Region(newItemName);
                newRecordId  = RegionsDatabaseDirectory.Insert(newEntity, CurrentItem.Entity);
                newEntity.ID = newRecordId;
                CurrentItem.Children.Add(new RegionViewModel(newEntity as Region, CurrentItem as CountryViewModel));
            }

            else if (CurrentItem is RegionViewModel)
            {
                newEntity    = new District(newItemName);
                newRecordId  = RegionsDatabaseDirectory.Insert(newEntity, CurrentItem.Entity);
                newEntity.ID = newRecordId;
                CurrentItem.Children.Add(new DistrictViewModel(newEntity as District, CurrentItem as RegionViewModel));
            }

            else if (CurrentItem is DistrictViewModel)
            {
                newEntity    = new City(newItemName);
                newRecordId  = RegionsDatabaseDirectory.Insert(newEntity, CurrentItem.Entity);
                newEntity.ID = newRecordId;
                CurrentItem.Children.Add(new CityViewModel(newEntity as City, CurrentItem as DistrictViewModel));
            }

            else if (CurrentItem is CityGroupViewModel)
            {
                CityGroupViewModel ci = CurrentItem as CityGroupViewModel;
                switch (ci.Name)
                {
                case "Улицы":
                    newEntity    = new Street(newItemName);
                    newRecordId  = RegionsDatabaseDirectory.Insert(newEntity, CurrentItem.Parent.Entity);
                    newEntity.ID = newRecordId;
                    CurrentItem.Children.Add(new StreetViewModel(newEntity as Street, ci.Parent as CityViewModel));
                    break;

                case "Районы города":
                    newEntity    = new Borough(newItemName);
                    newRecordId  = RegionsDatabaseDirectory.Insert(newEntity, CurrentItem.Parent.Entity);
                    newEntity.ID = newRecordId;
                    CurrentItem.Children.Add(new BoroughViewModel(newEntity as Borough, ci.Parent as CityViewModel));
                    break;
                }
            }

            else if (CurrentItem is BoroughViewModel)
            {
                newEntity    = new Microdistrict(newItemName);
                newRecordId  = RegionsDatabaseDirectory.Insert(newEntity, CurrentItem.Entity);
                newEntity.ID = newRecordId;

                CurrentItem.Children.Add(new MicrodistrictViewModel(newEntity as Microdistrict, CurrentItem as BoroughViewModel));
            }
        }
 public BoroughViewModel(Borough borough, CityViewModel parentCity)
     : base(parentCity, true)
 {
     _entity = borough;
 }
示例#5
0
 public static List <IEntity> GetMicrodistricts(Borough b)
 {
     return(Instance._regionsModel.GetMicrodistricts(b));
 }