static void Main(string[] args) { var services = new ServiceCollection(); services.AddDbContext <ListingsDbContext>(options => options.UseSqlServer("Server=localhost;Database=properties-api;Trusted_Connection=True;")); services.AddScoped <IPropertiesRepository, PropertiesRepository>(); var serviceProvider = services.BuildServiceProvider(); _dbcontext = serviceProvider.GetService <ListingsDbContext>(); _repo = new PropertiesRepository(_dbcontext); // run this to import post codes if (!_dbcontext.PostCodes.Any()) { ImportPostCodes(); } //var properties = _dbcontext.Properties.ToList(); //if (properties.Any()) //{ // System.Console.WriteLine("Removing Properties"); // _dbcontext.Properties.RemoveRange(_dbcontext.Properties); // _dbcontext.SaveChanges(); //} //var agents = _dbcontext.Agents.ToList(); //if (agents.Any()) //{ // System.Console.WriteLine("Removing Agents"); // _dbcontext.Agents.RemoveRange(_dbcontext.Agents); // _dbcontext.SaveChanges(); //} //var agencies = _dbcontext.Agencies.ToList(); //if (agencies.Any()) //{ // System.Console.WriteLine("Removing Agencies"); // _dbcontext.Agencies.RemoveRange(_dbcontext.Agencies); // _dbcontext.SaveChanges(); //} PropertyGen propertyGen = new PropertyGen(_dbcontext); propertyGen.GenerateProperties(); }
private void AddPropertyTypes(ListingsDbContext context) { 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(); } propertyTypes = _context.PropertyTypes.ToList(); }
public ListingService(ListingsDbContext context, IBus publisher) : base(context) { this.context = context; this.publisher = publisher; }
public SellerService(ListingsDbContext context) { this.context = context; }
public Properties(ListingsDbContext context) { _context = context; }
public LookupSeeder(ListingsDbContext context) { _context = context; }
public Agencies(ListingsDbContext context) { _context = context; }
public PropertyGen(ListingsDbContext context) { _context = context; }