Exemple #1
0
        /// <summary>
        /// Gets the suburbs.
        /// </summary>
        /// <returns></returns>
        public static async Task <List <EntitySuburb> > GetSuburbs()
        {
            if (_suburbList == null || _suburbList.Count == 0)
            {
                _suburbList = new List <EntitySuburb>();

                foreach (var town in _townList)
                {
                    _suburbList.Add(new EntitySuburb()
                    {
                        Name   = "Pinelands",
                        TownId = town.Id,
                    });

                    _suburbList.Add(new EntitySuburb()
                    {
                        Name   = "Claremont",
                        TownId = town.Id,
                    });

                    _suburbList.Add(new EntitySuburb()
                    {
                        Name   = "Centurion",
                        TownId = town.Id,
                    });

                    _suburbList.Add(new EntitySuburb()
                    {
                        Name   = "Newtown",
                        TownId = town.Id,
                    });

                    _suburbList.Add(new EntitySuburb()
                    {
                        Name   = "Sandton",
                        TownId = town.Id,
                    });
                }

                using (var db = new MancobaLocalDataApi(ConnectionFactory, PlatformCapabilities))
                {
                    var response = await db.SaveTown(_townList);
                }
            }

            return(_suburbList.OrderBy(c => c.Name).ToList());
        }
Exemple #2
0
        /// <summary>
        /// Gets the streets.
        /// </summary>
        /// <returns></returns>
        public static async Task <List <EntityStreet> > GetStreets()
        {
            if (_streetList == null || _streetList.Count == 0)
            {
                _streetList = new List <EntityStreet>();

                foreach (var sub in _suburbList)
                {
                    string txt = UtilsService.RandomNumber(1, 100) > 50 ? "Road" : "Street";
                    _streetList.Add(new EntityStreet()
                    {
                        Name     = $"Main {txt}",
                        SuburbId = sub.Id,
                    });

                    txt = UtilsService.RandomNumber(1, 100) > 50 ? "Road" : "Street";
                    _streetList.Add(new EntityStreet()
                    {
                        Name     = $"Voortrekker {txt}",
                        SuburbId = sub.Id,
                    });

                    int road = UtilsService.RandomNumber(1, 9);
                    _streetList.Add(new EntityStreet()
                    {
                        Name     = $"M {road}",
                        SuburbId = sub.Id,
                    });
                }


                using (var db = new MancobaLocalDataApi(ConnectionFactory, PlatformCapabilities))
                {
                    var response = await db.SaveTown(_townList);
                }
            }

            return(_streetList.OrderBy(c => c.Name).ToList());
        }
Exemple #3
0
        /// <summary>
        /// Gets the towns.
        /// </summary>
        /// <returns></returns>
        public static async Task <List <EntityTown> > GetTowns()
        {
            if (_townList == null || _townList.Count == 0)
            {
                _townList = new List <EntityTown>();

                for (int i = 0; i < _provinceList.Count; i++)
                {
                    var province = _provinceList[i];

                    if (i == 0)                     //  Name = "Eastern Cape"
                    {
                        _townList.Add(new EntityTown()
                        {
                            Id         = UtilsService.GenerateId(),
                            Name       = "Port Elizabeth",
                            ProvinceId = province.Id,
                        });
                        _townList.Add(new EntityTown()
                        {
                            Id         = UtilsService.GenerateId(),
                            Name       = "East London",
                            ProvinceId = province.Id,
                        });
                    }
                    if (i == 1)                     //  Name = "Free State"
                    {
                        _townList.Add(new EntityTown()
                        {
                            Id         = UtilsService.GenerateId(),
                            Name       = "Bloemfontein",
                            ProvinceId = province.Id,
                        });
                        _townList.Add(new EntityTown()
                        {
                            Id         = UtilsService.GenerateId(),
                            Name       = "Welkom",
                            ProvinceId = province.Id,
                        });
                    }
                    if (i == 2)                     //  Name = "Gauteng"
                    {
                        _townList.Add(new EntityTown()
                        {
                            Id         = UtilsService.GenerateId(),
                            Name       = "Pretoria",
                            ProvinceId = province.Id,
                        });
                        _townList.Add(new EntityTown()
                        {
                            Id         = UtilsService.GenerateId(),
                            Name       = "Johannesburg",
                            ProvinceId = province.Id,
                        });
                    }

                    if (i == 3)                     //  Name = "KwaZulu-Natal"
                    {
                        _townList.Add(new EntityTown()
                        {
                            Id         = UtilsService.GenerateId(),
                            Name       = "Durban",
                            ProvinceId = province.Id,
                        });
                        _townList.Add(new EntityTown()
                        {
                            Id         = UtilsService.GenerateId(),
                            Name       = "Pietermaritzburg",
                            ProvinceId = province.Id,
                        });
                    }

                    if (i == 4)                     //  Name = "Limpopo"
                    {
                        _townList.Add(new EntityTown()
                        {
                            Id         = UtilsService.GenerateId(),
                            Name       = "Mokopane",
                            ProvinceId = province.Id,
                        });
                        _townList.Add(new EntityTown()
                        {
                            Id         = UtilsService.GenerateId(),
                            Name       = "Polokwane",
                            ProvinceId = province.Id,
                        });
                    }

                    if (i == 5)                     //  Name = "Mpumalanga"
                    {
                        _townList.Add(new EntityTown()
                        {
                            Id         = UtilsService.GenerateId(),
                            Name       = "Ermelo",
                            ProvinceId = province.Id,
                        });
                        _townList.Add(new EntityTown()
                        {
                            Id         = UtilsService.GenerateId(),
                            Name       = "Nelspruit",
                            ProvinceId = province.Id,
                        });
                    }

                    if (i == 6)                     //  Name = "Northern Cape"
                    {
                        _townList.Add(new EntityTown()
                        {
                            Id         = UtilsService.GenerateId(),
                            Name       = "Kimberley",
                            ProvinceId = province.Id,
                        });
                        _townList.Add(new EntityTown()
                        {
                            Id         = UtilsService.GenerateId(),
                            Name       = "Upington",
                            ProvinceId = province.Id,
                        });
                    }

                    if (i == 7)                     //  Name = "North West"
                    {
                        _townList.Add(new EntityTown()
                        {
                            Id         = UtilsService.GenerateId(),
                            Name       = "Rustenburg",
                            ProvinceId = province.Id,
                        });
                        _townList.Add(new EntityTown()
                        {
                            Id         = UtilsService.GenerateId(),
                            Name       = "Potchefstroom",
                            ProvinceId = province.Id,
                        });
                    }

                    if (i == 8)                     //  Name = "Western Cape"
                    {
                        _townList.Add(new EntityTown()
                        {
                            Id         = UtilsService.GenerateId(),
                            Name       = "Cape Town",
                            ProvinceId = province.Id,
                        });
                        _townList.Add(new EntityTown()
                        {
                            Id         = UtilsService.GenerateId(),
                            Name       = "Mossel Bay",
                            ProvinceId = province.Id,
                        });
                        _townList.Add(new EntityTown()
                        {
                            Id         = UtilsService.GenerateId(),
                            Name       = "Worcester",
                            ProvinceId = province.Id,
                        });
                    }
                }

                using (var db = new MancobaLocalDataApi(ConnectionFactory, PlatformCapabilities))
                {
                    var response = await db.SaveTown(_townList);
                }
            }

            return(_townList.OrderBy(c => c.Name).ToList());
        }