Exemplo n.º 1
0
        public List <MeetingVM> GetMeetingsInRadius(decimal latitude, decimal longitude, int miles)
        {
            var point = DbGeography.FromText(string.Format("POINT ({0} {1})", longitude, latitude), 4326);

            using (MeetingContext db = new MeetingContext())
            {
                var results = (from a in db.Meetings
                               where a.Geography.Distance(point) * 0.000621371 <= miles
                               select a).Select(x => new MeetingVM
                {
                    Address      = x.Address,
                    CasoID       = x.Address,
                    DayOfWeek    = x.DayOfWeek,
                    distance     = x.Geography.Distance(point) * 0.000621371,
                    Latitude     = x.Latitude,
                    LocationName = x.LocationName,
                    Longitude    = x.Longitude,
                    MeetingName  = x.MeetingName,
                    MeetingType  = x.MeetingType,
                    Options      = x.Options,
                    Time         = x.Time
                }).OrderBy(x => x.Time).ToList();
                return(results);
            }
        }
Exemplo n.º 2
0
 public void AddNewMeeting(Meeting meeting)
 {
     using (MeetingContext db = new MeetingContext())
     {
         db.Meetings.Add(meeting);
         db.SaveChanges();
         return;
     }
 }