public ActionResult RouteComplete()
        {
            routeComplete = true;
            string        id           = User.Identity.GetUserId();
            Observee      observee     = db.Observees.Where(e => e.ApplicationUserId == id).FirstOrDefault();
            string        Message      = observee.FirstName + " " + observee.LastName + " has completed their route safely!";
            List <string> phoneNumbers = db.PhoneNumbers.Where(e => e.ObserverId == observee.ObserverId).Select(e => e.Number).ToList();

            foreach (string x in phoneNumbers)
            {
                SendAlert.Send(Message, x);
            }

            return(RedirectToAction("Index"));
        }
 private Task StartTimer()
 {
     return(Task.Run(() =>
     {
         Thread.Sleep(100000);
         bool completed = routeComplete;
         if (completed == false)
         {
             ApplicationDbContext db = new ApplicationDbContext();
             var observee = db.Observees.Where(e => e.ApplicationUserId == asynchid).FirstOrDefault();
             List <string> phoneNumbers = db.PhoneNumbers.Where(e => e.ObserverId == observee.ObserverId).Select(x => x.Number).ToList();
             foreach (string i in phoneNumbers)
             {
                 SendAlert.Send("Observee has not made it to their location!", i);
             }
         }
     }));
 }
        public ActionResult TraverseRoute()
        {
            ShowRouteViewModel routeData    = TempData["myModel"] as ShowRouteViewModel;
            string             Message      = routeData.observee.FirstName + " " + routeData.observee.LastName + " has begun their route";
            List <string>      phoneNumbers = db.PhoneNumbers.Where(e => e.ObserverId == routeData.observee.ObserverId).Select(e => e.Number).ToList();

            foreach (string x in phoneNumbers)
            {
                SendAlert.Send(Message, x);
            }
            if (routeData.route.note != null)
            {
                Message = routeData.observee.FirstName + " " + routeData.observee.LastName + " has been routed through a high risk area.";
                foreach (string x in phoneNumbers)
                {
                    SendAlert.Send(Message, x);
                }
            }
            TimeStart().GetAwaiter();
            return(View(routeData));
        }
        public ActionResult PanicButton(int?id)
        {
            Observee    panicObservee = db.Observees.Find(id);
            Observer    guardian      = db.Observers.Where(o => o.id == panicObservee.ObserverId).FirstOrDefault();
            Geolocation geo           = new Geolocation();


            ViewBag.PanicMessage = panicObservee.FirstName + " " + panicObservee.LastName + " has pushed the Panic Alert button. Their location is: " + geo.Retrieve();
            try
            {
                var phoneNumbers = db.PhoneNumbers.Where(p => p.ObserverId == guardian.id).ToList();
                foreach (var number in phoneNumbers)
                {
                    SendAlert.Send(ViewBag.PanicMessage, number.Number);
                }
            }
            catch
            {
                return(View());
            }


            return(View());
        }