コード例 #1
0
        private void AddPropertyTypes()
        {
            if (_context.PropertyTypes.Any() == false)
            {
                var propertyTypes = new List <string>()
                {
                    "House", "Appartment", "Unit", "Villa", "Townhouse", "Acerage"
                };

                propertyTypes.ForEach(c => _context.Add(new PropertyType
                {
                    Name = c
                }));

                _context.SaveChanges();
            }
        }
コード例 #2
0
        static void ImportPostCodes()
        {
            using (var reader = new StreamReader(@"C:\temp\australian_postcodes.csv"))
            {
                List <string> Code           = new List <string>();
                List <string> Locality       = new List <string>();
                List <string> State          = new List <string>();
                List <string> Long           = new List <string>();
                List <string> Lat            = new List <string>();
                List <string> Id             = new List <string>();
                List <string> DeliveryCentre = new List <string>();
                List <string> Type           = new List <string>();
                List <string> Status         = new List <string>();

                List <PostCode> PostCodes = new List <PostCode>();

                while (!reader.EndOfStream)
                {
                    var line   = reader.ReadLine();
                    var values = line.Split(',');

                    string x = values[0];

                    string sub = values[1].ToLower().Replace(" ", "-") + "-" + values[0];

                    if (x != "postcode")
                    {
                        PostCodes.Add(new PostCode
                        {
                            Code     = int.Parse(values[0]),
                            Locality = values[1],
                            State    = values[2],
                            Long     = values[3],
                            Lat      = values[4],
                            //Id = int.Parse(values[5].ToString()),
                            DeliveryCentre = values[6],
                            Type           = values[7],
                            Status         = values[8],
                            Suburb         = sub
                        });
                    }



                    //Code.Add(values[0]);
                    //Locality.Add(values[1]);
                }

                var codesToAdd = PostCodes.OrderBy(x => x.Code).ToList();

                _dbcontext.PostCodes.AddRange(codesToAdd);

                _dbcontext.SaveChanges();
            }
        }
コード例 #3
0
        internal List <AgencyCompany> GetAgencyCompanies()
        {
            if (!_context.AgencyCompanies.Any())
            {
                agencyCompanies = new List <AgencyCompany>
                {
                    new AgencyCompany {
                        Name         = "Remax",
                        LogoImageUrl = "remax.jpg",
                        BrandColor   = "#fff"
                    },
                    new AgencyCompany {
                        Name         = "RayWhite",
                        LogoImageUrl = "ray-white.jpg",
                        BrandColor   = "#FEE536"
                    },
                    new AgencyCompany {
                        Name         = "LJ Hooker",
                        LogoImageUrl = "lj-hooker.jpg",
                        BrandColor   = "#000000"
                    },
                    new AgencyCompany {
                        Name         = "YONG",
                        LogoImageUrl = "yong.jpg",
                        BrandColor   = "#E4322C"
                    },
                    new AgencyCompany {
                        Name         = "@Realty",
                        LogoImageUrl = "realty.jpg",
                        BrandColor   = "#1F1F1F"
                    }
                };

                _context.AddRange(agencyCompanies);
                _context.SaveChanges();
                return(agencyCompanies);
            }
            else
            {
                return(agencyCompanies = _context.AgencyCompanies.ToList());
            }
        }
コード例 #4
0
        internal void CreatePropertiesForCode(PostCode code, List <Agency> agencies)
        {
            var props = _context.Properties.Where(x => x.Suburb == code.Locality).ToList();

            if (!props.Any())
            {
                System.Console.WriteLine("Creating properties for suburb " + code.Locality + " in PostCode: " + code.Code);
                this.agencies = agencies;
                try
                {
                    List <Property> properties = new List <Property>();

                    int count        = 3;
                    int streetNumber = 5;
                    for (int i = 0; i < count; i++)
                    {
                        var property = GenerateProperty(code, streetNumber);
                        var images   = GenImages(property.Id);
                        property.Images.AddRange(images);
                        properties.Add(property);
                        //if (!property.Listings.Any(x=>x.)) {
                        //    throw new Exception("we cant run here");
                        //}
                        //System.Console.WriteLine("Created Property: " + property.Slug);

                        streetNumber = streetNumber + 3;
                        //properties.Add(property);
                        //i++;
                    }
                    _context.AddRange(properties);
                    _context.SaveChanges();
                }
                catch (Exception ex)
                {
                    var error = ex.Message;
                    throw ex;
                }
            }
            else
            {
                System.Console.WriteLine("Properties for " + code.Locality + " aleady exist...");
            }
        }