Ejemplo n.º 1
0
        /// <summary>
        /// Search hospitals in database using Location option
        /// </summary>
        /// <param name="latitude">Latitide</param>
        /// <param name="longitude">Longitude</param>
        /// <param name="distance">Distance between 2 locations</param>
        /// <returns>List[HospitalEntity] that contains a list of Hospitals</returns>
        public static async Task <List <HospitalEntity> > LocationSearchHospital(double latitude, double longitude, double distance)
        {
            List <HospitalEntity> hospitalList = null;

            // Search for suitable hospitals in database
            using (LinqDBDataContext data = new LinqDBDataContext())
            {
                hospitalList = await Task.Run(() =>
                                              (from h in data.SP_LOCATION_SEARCH_HOSPITAL(latitude, longitude, distance)
                                               select new HospitalEntity()
                {
                    Hospital_ID = h.Hospital_ID,
                    Hospital_Name = h.Hospital_Name,
                    Address = h.Address,
                    Ward_ID = h.Ward_ID,
                    District_ID = h.District_ID,
                    City_ID = h.City_ID,
                    Phone_Number = h.Phone_Number,
                    Coordinate = h.Coordinate,
                    Is_Active = h.Is_Active,
                    Rating = h.Rating
                }).ToList());
            }

            // Return list of hospitals
            return(hospitalList);
        }