コード例 #1
0
 public ParkingSpace(int capacity)
 {
     db = new Garage2_0Context();
     ps = new int[capacity];
     GetList();
     Capacity = capacity;
 }
コード例 #2
0
        public StatisticsViewModel(List <Vehicle> vehicles)
        {
            Garage2_0Context db = new Garage2_0Context();

            NumberOfMembers          = db.Members.Count();
            NumberOfVehicles         = vehicles.Count();
            NumberOfWheels           = vehicles.Sum(v => v.NumOfTires);
            NumberOfVehiclesPerColor = new Dictionary <Enum, int>();
            foreach (Colors color in Enum.GetValues(typeof(Colors)))
            {
                NumberOfVehiclesPerColor.Add(color, vehicles.Where(v => v.Color == color).Count());
            }
            NumberOfVehiclesPerType = new Dictionary <string, int>();
            foreach (var item in db.VehicleTypes)
            {
                NumberOfVehiclesPerType.Add(item.Type, vehicles.Where(v => v.VehicleType.Type == item.Type).Count());
            }
            EarliestCheckInTime = vehicles.OrderBy(v => v.CheckInTime).FirstOrDefault()?.CheckInTime;
            LatestCheckInTime   = vehicles.OrderByDescending(v => v.CheckInTime).FirstOrDefault()?.CheckInTime;
            foreach (Vehicle vehicle in vehicles)
            {
                if (vehicle.TypeId != 3)
                {
                    TotalPrice += VehicleHelpers.CalculateParkingPrice(vehicle.CheckInTime, DateTime.Now);
                }
                else
                {
                    TotalPrice += 2 * VehicleHelpers.CalculateParkingPrice(vehicle.CheckInTime, DateTime.Now);
                }
            }
        }
コード例 #3
0
        public AdvancedViewModel(ParkingSpace park)
        {
            capacity = park.Capacity;
            rows     = capacity / 5;
            array    = park.ps;
            db       = park.db;

            if (capacity % 5 != 0)
            {
                rows++;
            }
        }