public IHttpActionResult getSearchCity(CityStatusDTO c) { return(Ok(BL.CityBL.getSearchCity(c))); }
public static List <CityDTO> getSearchCity(CityStatusDTO c) { using (MoveilEntities db = new MoveilEntities()) { if (c.PrecioApt == 1) { if (c.Poblacion == 1) { var com = db.NewCities.Where(p => p.NewApt >= 1400 && p.DistritoCode == c.Distrito && p.NewPoblacion >= 200000).ToList(); if (com == null || com.Count == 0) { var com2 = db.NewCities.Where(p => p.NewApt >= 1400 && p.NewPoblacion >= 200000).ToList(); if (com2 == null || com.Count == 0) { return(CONVERTERES.CityConverters.ConvertCityListToDTO(db.NewCities.Where(p => p.NewApt >= 1400).ToList())); } return(CONVERTERES.CityConverters.ConvertCityListToDTO(com2)); } return(CONVERTERES.CityConverters.ConvertCityListToDTO(com)); } else if (c.Poblacion == 2) { var com = db.NewCities.Where(p => p.NewApt >= 1400 && p.DistritoCode == c.Distrito && p.NewPoblacion >= 100000 && p.NewPoblacion < 200000).ToList(); if (com == null || com.Count == 0) { var com2 = db.NewCities.Where(p => p.NewApt >= 1400 && p.NewPoblacion >= 100000 && p.NewPoblacion < 200000).ToList(); if (com2 == null || com.Count == 0) { return(CONVERTERES.CityConverters.ConvertCityListToDTO(db.NewCities.Where(p => p.NewApt >= 1400).ToList())); } return(CONVERTERES.CityConverters.ConvertCityListToDTO(com2)); } return(CONVERTERES.CityConverters.ConvertCityListToDTO(com)); } else { var com = db.NewCities.Where(p => p.NewApt >= 1400 && p.DistritoCode == c.Distrito && p.NewPoblacion < 100000).ToList(); if (com == null || com.Count == 0) { var com2 = db.NewCities.Where(p => p.NewApt >= 1400 && p.NewPoblacion < 100000).ToList(); if (com2 == null || com.Count == 0) { return(CONVERTERES.CityConverters.ConvertCityListToDTO(db.NewCities.Where(p => p.NewApt >= 1400).ToList())); } return(CONVERTERES.CityConverters.ConvertCityListToDTO(com2)); } return(CONVERTERES.CityConverters.ConvertCityListToDTO(com)); } } else if (c.PrecioApt == 2) { if (c.Poblacion == 1) { var com = db.NewCities.Where(p => p.NewApt >= 1200 && p.NewApt < 1400 && p.DistritoCode == c.Distrito && p.NewPoblacion >= 200000).ToList(); if (com == null || com.Count == 0) { var com2 = db.NewCities.Where(p => p.NewApt >= 1200 && p.NewApt < 1400 && p.NewPoblacion >= 200000).ToList(); if (com2 == null || com.Count == 0) { return(CONVERTERES.CityConverters.ConvertCityListToDTO(db.NewCities.Where(p => p.NewApt >= 1200 && p.NewApt < 1400).ToList())); } return(CONVERTERES.CityConverters.ConvertCityListToDTO(com2)); } return(CONVERTERES.CityConverters.ConvertCityListToDTO(com)); } else if (c.Poblacion == 2) { var com = db.NewCities.Where(p => p.NewApt >= 1200 && p.NewApt < 1400 && p.DistritoCode == c.Distrito && p.NewPoblacion >= 100000 && p.NewPoblacion < 200000).ToList(); if (com == null || com.Count == 0) { var com2 = db.NewCities.Where(p => p.NewApt >= 1200 && p.NewApt < 1400 && p.NewPoblacion >= 100000 && p.NewPoblacion < 200000).ToList(); if (com2 == null || com.Count == 0) { return(CONVERTERES.CityConverters.ConvertCityListToDTO(db.NewCities.Where(p => p.NewApt >= 1200 && p.NewApt < 1400).ToList())); } return(CONVERTERES.CityConverters.ConvertCityListToDTO(com2)); } return(CONVERTERES.CityConverters.ConvertCityListToDTO(com)); } else { var com = db.NewCities.Where(p => p.NewApt >= 1200 && p.NewApt < 1400 && p.DistritoCode == c.Distrito && p.NewPoblacion < 100000).ToList(); if (com == null || com.Count == 0) { var com2 = db.NewCities.Where(p => p.NewApt >= 1200 && p.NewApt < 1400 && p.NewPoblacion < 100000).ToList(); if (com2 == null || com.Count == 0) { return(CONVERTERES.CityConverters.ConvertCityListToDTO(db.NewCities.Where(p => p.NewApt >= 1200 && p.NewApt < 1400).ToList())); } return(CONVERTERES.CityConverters.ConvertCityListToDTO(com2)); } return(CONVERTERES.CityConverters.ConvertCityListToDTO(com)); } } else if (c.PrecioApt == 3) { if (c.Poblacion == 1) { var com = db.NewCities.Where(p => p.NewApt >= 1000 && p.NewApt < 1200 && p.DistritoCode == c.Distrito && p.NewPoblacion >= 200000).ToList(); if (com == null || com.Count == 0) { var com2 = db.NewCities.Where(p => p.NewApt < 1000 && p.NewApt > 1200 && p.NewPoblacion >= 200000).ToList(); if (com2 == null || com.Count == 0) { return(CONVERTERES.CityConverters.ConvertCityListToDTO(db.NewCities.Where(p => p.NewApt >= 1000 && p.NewApt < 1200).ToList())); } return(CONVERTERES.CityConverters.ConvertCityListToDTO(com2)); } return(CONVERTERES.CityConverters.ConvertCityListToDTO(com)); } if (c.Poblacion == 2) { var com = db.NewCities.Where(p => p.NewApt >= 1000 && p.NewApt < 1200 && p.DistritoCode == c.Distrito && p.NewPoblacion >= 100000 && p.NewPoblacion < 200000).ToList(); if (com == null || com.Count == 0) { var com2 = db.NewCities.Where(p => p.NewApt >= 1000 && p.NewApt < 1200 && p.NewPoblacion >= 100000 && p.NewPoblacion < 200000).ToList(); if (com2 == null || com.Count == 0) { return(CONVERTERES.CityConverters.ConvertCityListToDTO(db.NewCities.Where(p => p.NewApt >= 1000 && p.NewApt < 1200).ToList())); } return(CONVERTERES.CityConverters.ConvertCityListToDTO(com2)); } return(CONVERTERES.CityConverters.ConvertCityListToDTO(com)); } else { var com = db.NewCities.Where(p => p.NewApt >= 1000 && p.NewApt < 1200 && p.DistritoCode == c.Distrito && p.NewPoblacion < 100000).ToList(); if (com == null || com.Count == 0) { var com2 = db.NewCities.Where(p => p.NewApt >= 1000 && p.NewApt < 1200 && p.NewPoblacion < 100000).ToList(); if (com2 == null || com.Count == 0) { return(CONVERTERES.CityConverters.ConvertCityListToDTO(db.NewCities.Where(p => p.NewApt >= 1000 && p.NewApt < 1200).ToList())); } return(CONVERTERES.CityConverters.ConvertCityListToDTO(com2)); } return(CONVERTERES.CityConverters.ConvertCityListToDTO(com)); } } else { if (c.Poblacion == 1) { var com = db.NewCities.Where(p => p.NewApt < 1000 && p.DistritoCode == c.Distrito && p.NewPoblacion >= 200000).ToList(); if (com == null || com.Count == 0) { var com2 = db.NewCities.Where(p => p.NewApt < 1000 && p.NewPoblacion >= 200000).ToList(); if (com2 == null || com.Count == 0) { return(CONVERTERES.CityConverters.ConvertCityListToDTO(db.NewCities.Where(p => p.NewApt < 1000).ToList())); } return(CONVERTERES.CityConverters.ConvertCityListToDTO(com2)); } return(CONVERTERES.CityConverters.ConvertCityListToDTO(com)); } if (c.Poblacion == 2) { var com = db.NewCities.Where(p => p.NewApt < 1000 && p.DistritoCode == c.Distrito && p.NewPoblacion >= 100000 && p.NewPoblacion < 200000).ToList(); if (com == null || com.Count == 0) { var com2 = db.NewCities.Where(p => p.NewApt < 1000 && p.NewPoblacion >= 100000 && p.NewPoblacion < 200000).ToList(); if (com2 == null || com.Count == 0) { return(CONVERTERES.CityConverters.ConvertCityListToDTO(db.NewCities.Where(p => p.NewApt < 1000).ToList())); } return(CONVERTERES.CityConverters.ConvertCityListToDTO(com2)); } return(CONVERTERES.CityConverters.ConvertCityListToDTO(com)); } else { var com = db.NewCities.Where(p => p.NewApt < 1000 && p.DistritoCode == c.Distrito && p.NewPoblacion < 100000).ToList(); if (com == null || com.Count == 0) { var com2 = db.NewCities.Where(p => p.NewApt < 1000 && p.NewPoblacion < 100000).ToList(); if (com2 == null || com.Count == 0) { return(CONVERTERES.CityConverters.ConvertCityListToDTO(db.NewCities.Where(p => p.NewApt < 1000).ToList())); } return(CONVERTERES.CityConverters.ConvertCityListToDTO(com2)); } return(CONVERTERES.CityConverters.ConvertCityListToDTO(com)); } } } }