public HttpResponseMessage GetSingleProperty(int id) { var repository = new PropertiesRepository(); var result = repository.GetPropertyById(id); return(Request.CreateResponse(HttpStatusCode.OK, result)); }
public HttpResponseMessage GetPropertiesList() { var repository = new PropertiesRepository(); var result = repository.ListAllProperties(); return(Request.CreateResponse(HttpStatusCode.OK, result)); }
public DealsController(PropertiesRepository propertiesRepository, CustomersRepository customersRepository, SalespeopleRepository salespeopleRepository, DealsRepository dealsRepository) { propertiesDB = propertiesRepository; customersDB = customersRepository; salespeopleDB = salespeopleRepository; dealsDB = dealsRepository; }
public HttpResponseMessage EditProperty(int Id, PropertiesDto property) { var repository = new PropertiesRepository(); var result = repository.Edit(Id, property); if (result) { return(Request.CreateResponse(HttpStatusCode.OK)); } return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Property could not be updated")); }
public HttpResponseMessage AddNewProperty(PropertiesDto property) { var repository = new PropertiesRepository(); var result = repository.Create(property); if (result) { return(Request.CreateResponse(HttpStatusCode.Created)); } return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Property could not be added")); }
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(); }
public PropertiesController(PropertiesRepository propertiesRepository, CustomersRepository customersRepository) { propertiesDB = propertiesRepository; customersDB = customersRepository; }