Пример #1
0
 public JsonResult Json()
 {
     using (FoodRContext db = new FoodRContext())
     {
         //Find all the trucks out right now.
         //TODO: Prolly want to expand this to check for trucks that will be out with in an hour from now, maybe.
         //TESTING: this date should be changed to now, but for testing im leaving it like this
         var myDate = new DateTime(2014, 4, 23, 11, 15, 0);
         var trucks = db.FoodTrucks.Where(t => t.ScheduledStops.Any(e => e.From < myDate && e.To > myDate)).ToArray();
         return Json(trucks, JsonRequestBehavior.AllowGet);
     }
 }
Пример #2
0
        protected override int GetIdFromSlug(string slug)
        {
            using (var context = new FoodRContext())
            {
                var result = context.FoodTrucks.SingleOrDefault(t => t.UrlSlug == slug);
                if (result == null)
                {
                    return 0;
                }

                return result.Id;
            }
        }
Пример #3
0
        public ActionResult Map()
        {
            MapViewModel m = new MapViewModel();

            using (FoodRContext db = new FoodRContext())
            {
                //Find all the trucks out right now.
                //TODO: Prolly want to expand this to check for trucks that will be out with in an hour from now, maybe.
                //TESTING: this date should be changed to now, but for testing im leaving it like this
                var myDate = new DateTime(2014, 4, 23, 11, 15, 0);
                m.Trucks = db.FoodTrucks.Where(t => t.ScheduledStops.Any(e => e.From < myDate && e.To > myDate)).ToArray();
            }

            return View(m);
        }