public ActionResult Information() { VehicleInformationViewModel model = new VehicleInformationViewModel(); var allVehicles = db.Vehicles.ToList(); model.ParkingInfo = ParkingHelper.GetParkingLots(allVehicles); model.NumberOfTyres = allVehicles.Sum(x => x.NumberOfTyres); IQueryable <Vehicle> query = db.Vehicles; model.Car = query.Where(x => x.VehicleType.Name.Equals("Car")).Count(); model.Train = query.Where(x => x.VehicleType.Name.Equals("Train")).Count(); model.Airplane = query.Where(x => x.VehicleType.Name.Equals("Airplane")).Count(); model.MiniBus = query.Where(x => x.VehicleType.Name.Equals("MiniBus")).Count(); model.Bus = query.Where(x => x.VehicleType.Name.Equals("Bus")).Count(); model.Motorbike = query.Where(x => x.VehicleType.Name.Equals("Motorbike")).Count(); model.Boat = query.Where(x => x.VehicleType.Name.Equals("Boat")).Count(); model.Sedan = query.Where(x => x.VehicleType.Name.Equals("Sedan")).Count(); model.MiniBus = query.Where(x => x.VehicleType.Name.Equals("MiniBus")).Count(); model.TotalVehicle = allVehicles.Count(); foreach (var vehicle in allVehicles) { model.CostToThisMoment = model.CostToThisMoment + ParkingHelper.GetCost(vehicle.ParkingStartTime); } return(View(model)); }
public VehicleDeleteViewModel toViewModel(Vehicle vehicle) { VehicleDeleteViewModel model = new VehicleDeleteViewModel { Id = vehicle.Id, RegNr = vehicle.RegNr, VehicleTypeName = VehicleTypeName, Color = vehicle.Color, ParkingLotNo = vehicle.ParkingLotNumber, ParkingStartTime = vehicle.ParkingStartTime, ParkingStopTime = DateTime.Now, NoOfTyres = vehicle.NumberOfTyres, Model = vehicle.Modell, Fabricate = vehicle.Brand, Duration = ParkingHelper.GetDuration(vehicle.ParkingStartTime), PaymentAmount = ParkingHelper.GetCost(vehicle.ParkingStartTime) }; return(model); }
public VehicleVoucherViewModel toViewModel(Vehicle vehicle, Member member) { VehicleVoucherViewModel model = new VehicleVoucherViewModel { VoucherID = voucherId(), MemberId = member.MemberId, MemberName = member.FullName, RegNr = vehicle.RegNr, VehicleTypeName = VehicleTypeName, Color = vehicle.Color, ParkingLotNo = vehicle.ParkingLotNumber, ParkingStartTime = vehicle.ParkingStartTime, ParkingStopTime = DateTime.Now, NoOfTyres = vehicle.NumberOfTyres, Modell = vehicle.Modell, Brand = vehicle.Brand, Duration = ParkingHelper.GetDuration(vehicle.ParkingStartTime), PaymentAmount = ParkingHelper.GetCost(vehicle.ParkingStartTime) }; return(model); }