// GET: UserPlans/Details/id
        public ActionResult Details(int?id, DateTime date, string fromlocation)
        {
            DateTime newTime   = Convert.ToDateTime(date);
            TimeSpan ntime     = newTime.TimeOfDay;
            DateTime nplandate = Convert.ToDateTime(date);
            var      start     = fromlocation;

            //check if ID requested is null. If null return bad request page
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var time = date;

            //calculate the Day and hour from the time chosen by the user
            var day = Convert.ToString(time.DayOfWeek);
            var hr  = Convert.ToString(time.Hour);

            //Find the location matching the id from the database
            Location location = db.Locations.Find(id);
            // get the average pedestrian count for the given location at given day and hour
            string avgCount = PedestrianCount(location.Latitude, location.Longitude, day, hr);
            //create a detailed location object to store in the database to display to the user
            DetailedLocation detailedLocation = new DetailedLocation
            {
                StartLocation       = start,
                LocationID          = location.Id,
                Location            = location.Name,
                Theme               = location.Theme,
                Latitude            = Convert.ToDouble(location.Latitude),
                Longitude           = Convert.ToDouble(location.Longitude),
                PeopleCount         = avgCount,
                Date                = date,
                Time                = ntime,
                AccessibilityLevel  = location.AccessibilityLevel,
                AccessibilityRating = location.AccessibilityRating
            };

            //return the newly added location to the view model
            return(View(detailedLocation));
        }
Example #2
0
        public void Initialize(BasicWarehouse warehouse)
        {
            _warehouse = warehouse;
            try
            {
                LocationList = new ObservableCollection <LocationViewModel>();

/*              foreach (var p in _warehouse.DBService.GetPlaceIDs())
 *                  LocationList.Add(new LocationViewModel { ID = p.ID, Size = p.Size, Blocked = p.Blocked, Reserved = p.Reserved });
 *              foreach (var l in LocationList)
 *                  l.Initialize(_warehouse);
 */
                DetailedLocation.Initialize(_warehouse);
                Messenger.Default.Register <MessageAccessLevel>(this, (mc) => { AccessLevel = mc.AccessLevel; });
                Messenger.Default.Register <MessageViewChanged>(this, async vm => await ExecuteViewActivated(vm.ViewModel));
            }
            catch (Exception e)
            {
                _warehouse.AddEvent(Database.Event.EnumSeverity.Error, Database.Event.EnumType.Exception, e.Message);
                throw new Exception(string.Format("{0}.{1}: {2}", this.GetType().Name, (new StackTrace()).GetFrame(0).GetMethod().Name, e.Message));
            }
        }
        public ActionResult AnyLocationDetails(string location, double lat, double lon, DateTime date)
        {
            DateTime newTime   = Convert.ToDateTime(date);
            TimeSpan ntime     = newTime.TimeOfDay;
            DateTime nplandate = Convert.ToDateTime(date);
            var      time      = date;

            //calculate the Day and hour from the time chosen by the user
            var              day              = Convert.ToString(time.DayOfWeek);
            var              hr               = Convert.ToString(time.Hour);
            string           avgCount         = PedestrianCount(Convert.ToString(lat), Convert.ToString(lon), day, hr);
            DetailedLocation detailedLocation = new DetailedLocation
            {
                Location    = location,
                Latitude    = Convert.ToDouble(lat),
                Longitude   = Convert.ToDouble(lon),
                PeopleCount = avgCount,
                Date        = date,
                Time        = ntime
            };

            return(View(detailedLocation));
        }