public async Task <ICollection <Location> > GetAsync(LocationSearch locationSearch = null) { try { var list = await _coronaContext.Locations.ToListAsync(); if (locationSearch.city != null && locationSearch.city != "All" && locationSearch.city != "") { list = list.Where(c => c.city == locationSearch.city).ToList(); } if (locationSearch.age != 0 && list.Count > 0) { List <Patient> patients = _coronaContext.Patients.Where(p => p.age == locationSearch.age).ToList(); if (patients.Count() > 0) { List <Location> locationsByAge = new List <Location>(); foreach (var patient in patients) { locationsByAge.AddRange(list.Where(l => l.patientId == patient.id).ToList()); } list = locationsByAge; } } if (locationSearch.startDate > DateTime.MinValue)//valid dates. { list = list.Where (location => !(locationSearch.endDate <= location.startDate || locationSearch.startDate <= location.endDate)).ToList();//-------------------not perfect } return(list); } catch { throw new Exception("exeption in search function"); } }
public ICollection <Location> SearchByCity(LocationSearch locationSearch) { CoronaContext context = new CoronaContext(); var listOfSpecificCity = context.Location.Where(l => l.City == locationSearch.City).ToList(); return(listOfSpecificCity); }
public ICollection <Location> Get(LocationSearch locationSearchModel) { try { using (CoronaContext coronaContext = new CoronaContext()) { if (locationSearchModel.age != 0) { List <Patient> patients = coronaContext.Patients.Where(p => p.age == locationSearchModel.age).ToList(); if (patients.Count() > 0) { List <Location> locationsByAge = new List <Location>(); foreach (var patient in patients) { List <Location> locations = coronaContext.Locations.Where(l => l.patientId == patient.id).ToList(); if (locations.Count() > 0) { Location locationModel = new Location(); locationsByAge.AddRange(locations); } } return(locationsByAge); } } } } catch (Exception e) { throw new Exception(e.ToString()); } throw new Exception("No locations"); }
public ICollection <Location> SearchByAllParams(LocationSearch locationSearch) { CoronaContext context = new CoronaContext(); var listPatient = context.Location.Where(l => l.City == locationSearch.City && l.StartDate > locationSearch.StartDate && l.EndDate < locationSearch.EndDate).ToList(); return(listPatient); }
public ICollection <Location> Get(LocationSearch locationSearch = null) { try { var list = locations; if (locationSearch.city != null && locationSearch.city != "All" && locationSearch.city != "") { list = list.Where(c => c.city == locationSearch.city).ToList(); return(list); } return(list); } catch (Exception e) { throw new Exception(e.ToString()); // return this.StatusCode(StatusCodes.Status500InternalServerError, "data failed"); } }
public ICollection <Location> SearchBy(LocationSearch locationSearch) { var searchList = new List <Location>(); //if (locationSearch.City != null) //{ // searchList = (List<Location>)SearchByDate(locationSearch); //} if (locationSearch.City == null) { searchList = (List <Location>)SearchByDate(locationSearch); } else { searchList = (List <Location>)SearchByCity(locationSearch); } return(searchList); }
public ICollection <Location> SearchByDate(LocationSearch locationSearch) { var listPatient = new List <Location>(); CoronaContext context = new CoronaContext(); foreach (var item in context.Patient.Include(x => x.Path)) { foreach (var item2 in item.Path) { if (item2.StartDate > locationSearch.StartDate /*&& item2.EndDate<locationSearch.EndDate*/) { listPatient.Add(item2); } } } //var listPatient = context.Location // .Where(l => l.StartDate > locationSearch.StartDate && // l.EndDate < locationSearch.EndDate).ToList(); return(listPatient); }
public async Task <List <Location> > Get(LocationSearch locationSearch) { return(await ILocationRepository.SearchBy(locationSearch)); }
public async Task <ICollection <Location> > GetAsync(LocationSearch locationSearch = null) { var res = await _locationRepository.GetAsync(locationSearch); return(res); }
public List <Location> Get(LocationSearch locationSearch) { return(_locationRepository.Get(locationSearch)); }