Esempio n. 1
0
        // GET: ParkingSpots
        public ActionResult Index(string sortOrder, bool filterAvailableOnly = false)
        {
            IEnumerable <ParkingSpot> parkingSpots = null;
            CheckInsParkingSpots      chps         = new CheckInsParkingSpots();

            if (filterAvailableOnly)
            {
                parkingSpots = chps.AvailableParkingSpots();
            }
            else
            {
                parkingSpots = db.ParkingSpots();
            }

            List <DetailsParkingSpotVM> viewModel = new List <DetailsParkingSpotVM>();

            foreach (ParkingSpot parkingSpot in Sort(parkingSpots, sortOrder).ToList())
            {
                CheckIn checkIn = chps.CheckInByParkingSpot(parkingSpot.ID);

                viewModel.Add(new DetailsParkingSpotVM
                {
                    Availability = new CheckInsParkingSpots().Availability(checkIn),
                    ParkingSpot  = parkingSpot,
                    CheckIn      = checkIn
                });
            }

            return(View(viewModel));
        }
Esempio n. 2
0
        // GET: ParkingSpots/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            ParkingSpot parkingSpot = db.ParkingSpot(id);

            if (parkingSpot == null)
            {
                return(HttpNotFound());
            }

            CheckInsParkingSpots chps = new CheckInsParkingSpots();
            CheckIn checkIn           = chps.CheckInByParkingSpot(parkingSpot.ID);

            return(View(new DetailsParkingSpotVM
            {
                Availability = chps.Availability(checkIn),
                ParkingSpot = parkingSpot,
                CheckIn = checkIn
            }));
        }