Пример #1
0
        public ActionResult Index(int id)
        {
            DeviceDataService deviceDataService = new DeviceDataService();
            var device = deviceDataService.Get(id);
            LocationDataService locationDataService = new LocationDataService();
            var locations = locationDataService.GetAllByDevice(device.Id);

            if (locations.Count == 0)
            {
                return(View("NoLocationsAvailable"));
            }
            else
            {
                return(View(locations));
            }
        }
Пример #2
0
        public ActionResult Sort(int id, int time)
        {
            LocationDataService locationDataService = new LocationDataService();
            var locations = locationDataService.GetAllByDevice(id);

            List <Location> sortedList = new List <Location>();

            var now = DateTime.Now;

            foreach (var location in locations)
            {
                if ((now - location.TimeStamp).TotalMinutes <= (time * 60))
                {
                    sortedList.Add(location);
                }
            }
            //if no sorting can be made by that time, the last known place is shown
            if (sortedList.Count == 0)
            {
                sortedList.Add(locations[locations.Count - 1]);
            }

            return(View("Index", sortedList));
        }