コード例 #1
0
ファイル: Generator.cs プロジェクト: bart-kosmala/fakers
        static model.Address SetAddress(string street)
        {
            try
            {
                Logger.generatorSetAddress();

                ClearGeoAPI geo = GetDataFromJson.getGeo("", street);
                try
                {
                    if (geo == null)
                    {
                        throw new NullReferenceException();
                    }
                }
                catch (NullReferenceException e)
                {
                    Logger.log(e);
                    return(new model.Address());
                }


                if (geo.City == null)
                {
                    Logger.generatorSetAddressError();
                    return(new model.Address {
                        City = "null", Street = "null"
                    });
                }

                if (geo.City == street)
                {
                    Logger.generatorSetAddressTheSameError();
                    return(new model.Address {
                        City = "null", Street = "null"
                    });
                }

                model.Address address = new model.Address
                {
                    City        = geo.City,
                    Street      = street + HouseNumber.GetHouseNumber(),
                    Voivodeship = geo.Voivodeship,
                    Location    = new String($"{geo.Latiude}, {geo.Longitude}")
                };

                return(address);
            }
            catch (Exception e)
            {
                Logger.log(e);
                return(null);
            }
        }