Exemplo n.º 1
0
        public async Task <IActionResult> Statistics()
        {
            var vehicles = await _context.Vehicles.ToListAsync();

            var types = await _context.VehicleType2s.ToListAsync();

            var model = new ViewModels.Statistics();
            var createdVehicleStats = new Dictionary <string, int>();

            foreach (var type in types)
            {
                var nrOf = vehicles.Count(v => v.VehicleType2Id == type.Id);
                createdVehicleStats.Add(type.Name, nrOf);
            }

            model.NrOfCreatedVehicles = createdVehicleStats;

            model.TotalNrOfWheels = vehicles.Sum(v => v.NrOfWheels);

            var totalParkedSpots = _context.Spots.Count();

            model.TotalParkedSpots = totalParkedSpots;

            model.TotalSpots = garageSettings.Value.Size;

            model.UnparkedSpots = model.TotalSpots - model.TotalParkedSpots;

            var now        = DateTime.Now;
            var totalHours = vehicles.Sum(v => Convert.ToInt32((now - v.ArrivalTime).TotalHours));

            model.ParkingValuePending = totalHours * priceSettings.Value.Price;

            return(View(model));
        }
Exemplo n.º 2
0
        /*===============================*\
        |*         Constructeurs         *|
        \*===============================*/

        /// <summary>
        /// Constructeur complet
        /// </summary>
        /// <param name="width">Largeur (nombre de colonnes)</param>
        /// <param name="height">Hauteur (nombre de lignes)</param>
        public Grid(int width, int height)
        {
            this.width  = width;
            this.height = height;

            statistics = new ViewModels.Statistics();
            this.InitCells(width, height);
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Statistics()
        {
            var vehicles = await _context.ParkedVehicle.ToListAsync();

            var model = new ViewModels.Statistics();

            //model.ParkedCars = vehicles.Where(v => v.VehicleType == VehicleType.Car).Count();
            //model.ParkedMotorcycles = vehicles.Where(v => v.VehicleType == VehicleType.Motorcycle).Count();
            //model.ParkedBuses = vehicles.Where(v => v.VehicleType == VehicleType.Bus).Count();
            //model.ParkedAirplanes = vehicles.Where(v => v.VehicleType == VehicleType.Airplane).Count();
            //model.ParkedBoats = vehicles.Where(v => v.VehicleType == VehicleType.Boat).Count();

            model.TotalNrOfWheels = vehicles.Sum(v => v.NrOfWheels);

            var now              = DateTime.Now;
            var totalHours       = vehicles.Sum(v => Convert.ToInt32((now - v.ArrivalTime).TotalHours));
            var totalParkedSpots = GetGarage().Count(x => x != null);

            model.ParkingValuePending = totalHours * priceSettings.Value.Price * totalParkedSpots;

            return(View(model));
        }