コード例 #1
0
        public ICollection <Location> SearchByCity(LocationSearch locationSearch)
        {
            CoronaContext context            = new CoronaContext();
            var           listOfSpecificCity = context.Location.Where(l => l.City == locationSearch.City).ToList();

            return(listOfSpecificCity);
        }
コード例 #2
0
        public ICollection <Models.Location> GetByDate(Models.LocationSearch criteria)
        {
            if (criteria.startDate < DateTime.MinValue && criteria.endDate >= DateTime.Now)//valid dates.
            {
                throw new Exception("One or more of the dates are not valid.");
            }

            try
            {
                using (CoronaContext coronaContext = new CoronaContext())
                {
                    List <Location> returnObj      = new List <Models.Location>();
                    List <Location> matchLocations = coronaContext.Locations.Where
                                                         (location => !(criteria.endDate <= location.startDate && criteria.startDate <= location.endDate)).ToList();//-------------------not perfect
                    if (matchLocations.Count() > 0)
                    {
                        Models.Location locationModel = new Models.Location();
                        returnObj.AddRange(locationModel.ToLocationModel(matchLocations));
                    }
                    return(returnObj);
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.ToString());
            }
        }
コード例 #3
0
 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");
 }
コード例 #4
0
        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);
        }
コード例 #5
0
        ICollection <Location> ILocationRepository.GetAllList(List <Location> listPatient)
        {
            //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)
                {
                    listPatient.Add(item2);
                }
            }
            return(listPatient);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
 public PatientRepository(CoronaContext coronaContext)
 {
     _context = coronaContext;
 }
コード例 #8
0
 public LocationRepository(CoronaContext _coronaContext)
 {
     this._coronaContext = _coronaContext;
 }
コード例 #9
0
 public LocationSearchRepository(CoronaContext coronaContext)
 {
     _coronaContext = coronaContext;
 }