public PeterParker(PeterParker parent, ParkingType type) { parkings = new List <Parking>(parent.parkings); parkings.Add(new Parking(type)); totalLength = parent.totalLength; //baseCurve = parent.baseCurve; }
public ActionResult <ParkingTypeDetailDTO> UpdateParkingType(long id, [FromBody] ParkingType updatedParkingType) { var parkingType = this.parkingTypeRepository.UpdateParkingType(id, updatedParkingType); var parkingTypeResult = this.mapper.Map <ParkingTypeDetailDTO>(parkingType); return(parkingTypeResult); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Description")] ParkingType parkingType) { if (id != parkingType.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(parkingType); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ParkingTypeExists(parkingType.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(parkingType)); }
public static void Calculate(ParkingType parkingType, string inTime, string inAMPM, string inDate, string outTime, string outAMPM, string outDate) { inDate = Utility.CalculateDate(inDate); outDate = Utility.CalculateDate(outDate); Physical.Parking.Calculate(parkingType, inTime, inAMPM, inDate, outTime, outAMPM, outDate); }
public bool Parkvehicle(Vehicle vehicle, ParkingType parkingType) { if (!IsFull) { ParkingSpace availableSpace = AvailableSpaces.Where(p => p.Type == parkingType).OrderBy(p => p).FirstOrDefault(); if (availableSpace != null) { availableSpace.Vehicle = vehicle; availableSpace.IsOccupied = true; UsedSpaces.Add(availableSpace); AvailableSpaces.Remove(availableSpace); if (UsedSpaces.Count == MAX_SLOT) { IsFull = true; } IsEmpty = false; return(true); } return(false); } else { Console.WriteLine("Parking is Full"); return(false); } }
public ActionResult <ParkingType> Create(ParkingType c) { var parkingType = this.mapper.Map <ParkingType>(c); parkingType = this.parkingTypeRepository.Create(parkingType); return(this.mapper.Map <ParkingType>(parkingType)); }
public ParkingType CreateParkingType(ParkingType c) { this.context.ParkingTypes.Add(c); this.context.SaveChanges(); return(c); }
public double ParkingCost(ParkingType parkingType, ParkingSpot parkingSpot) { GeneralParking generalParking = new GeneralParking(); ValetParking valetParking = new ValetParking(); FrequentFlyerParking frequentFlyerParking = new FrequentFlyerParking(); var hoursParked = ((DateTime.Now - parkingSpot.StartTime).Minutes) / 60; double totalPrice = 0; switch (parkingType) { case ParkingType.General: totalPrice = (hoursParked) * generalParking.ParkingPrice; break; case ParkingType.Valet: totalPrice = (hoursParked) * valetParking.ParkingPrice; break; case ParkingType.FrequentFlyer: totalPrice = (hoursParked) * frequentFlyerParking.ParkingPrice; break; default: throw new Exception("Time error"); } ; return(totalPrice); }
public IChargeCalculator GetParkingCalculator(ParkingType parkingType) { return(parkingType switch { ParkingType.ShortStay => new ShortStayCalculator(), ParkingType.LongStay => new LongStayCalculator(), _ => throw new ParkingTypeNotSupportedException($"{parkingType} is not supported.") });
public ParkingType UpdateParkingType(long id, ParkingType newParkingType) { newParkingType.Id = id; this.context.Entry(newParkingType).State = EntityState.Modified; this.context.SaveChanges(); return(newParkingType); }
public ActionResult DeleteConfirmed(int id) { ParkingType parkingType = db.ParkingTypes.Find(id); db.ParkingTypes.Remove(parkingType); db.SaveChanges(); return(RedirectToAction("Index")); }
public double CalculateCharge(Visitor visitor, ParkingType parkingType) { _ = visitor ?? throw new ArgumentNullException(nameof(visitor)); IChargeCalculator chargeCalculator = _chargeCalculatorFactory.GetParkingCalculator(parkingType); return(chargeCalculator.CalculateCharge(visitor.StartParking, visitor.LeaveParking)); }
public Parking(double distance) { height = distance; necessaryRoad = 0; width = 0; widthOffset = 0; isDouble = false; type = ParkingType.Road; }
public ActionResult Edit([Bind(Include = "ParkingTypeID,ParkingTypeName,ParkingSpots,ParkingSecurity")] ParkingType parkingType) { if (ModelState.IsValid) { db.Entry(parkingType).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(parkingType)); }
public async Task <IActionResult> Create([Bind("Id,Description")] ParkingType parkingType) { if (ModelState.IsValid) { _context.Add(parkingType); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(parkingType)); }
public ActionResult Create([Bind(Include = "ParkingTypeID,ParkingTypeName,ParkingSpots,ParkingSecurity")] ParkingType parkingType) { if (ModelState.IsValid) { db.ParkingTypes.Add(parkingType); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(parkingType)); }
public static IParkingCostCalculator CreateCalculator(ParkingType type) { switch (type) { case ParkingType.ValetParking: return new ValetParkingCalculator(); case ParkingType.ShortTermParking: return new ShortTermParkingCalculator(); } throw new InvalidEnumArgumentException("type", (int)type, type.GetType()); }
/// <summary> /// Helper method to park a vehicle to its desired type /// </summary> /// <param name="manager">Parking lot manager</param> /// <param name="type">Parking type</param> private static void ParkVehicle(IParkingLotManager manager, ParkingType type) { try { // Print the booking number if vehicle is parked successfully Console.WriteLine(string.Format("Ticket number: {0}", manager.ParkVehicle(type))); } catch (ParkingSpaceNotAvailableException ex) { Console.WriteLine(ex.Message); } }
public ParkingSpot AddCar(ParkingType parkingType, Driver driver, ParkingSpot parkingSpot) //public List<ParkingSpot> AddCar(ParkingType parkingType, Driver driver, ParkingSpot parkingSpot) { List <ParkingSpot> parkingSpots = new List <ParkingSpot>(); //var Id = Guid.NewGuid; Driver driverInfo = new Driver { LicensePlate = driver.LicensePlate, Name = driver.Name }; ParkingSpot parking = new ParkingSpot { Id = Guid.NewGuid(), GetParkingType = parkingSpot.GetParkingType, ParkingSpotNumber = parkingSpot.ParkingSpotNumber, ParkingStructureLevel = parkingSpot.ParkingStructureLevel, HoursParked = parkingSpot.HoursParked, StartTime = DateTime.Now, Unavailable = true }; parkingSpots.Add(parking); switch (parkingType) { case ParkingType.General: GPSpotOwners.Add(driverInfo); break; case ParkingType.Valet: VPSpotOwners.Add(driverInfo); break; case ParkingType.FrequentFlyer: FFSpotOwners.Add(driverInfo); break; default: throw new Exception("incorrect parking spot type"); } //store data somewhere //var parkingList = new List<ParkingSpot>(); //foreach (ParkingSpot p in parkingSpots) //{ // var eachElement = p; // parkingList.Add(eachElement); //} return(parking); //returning ticket with start time }
public static IParkingCostCalculator CreateCalculator(ParkingType type) { switch (type) { case ParkingType.ValetParking: return(new ValetParkingCalculator()); case ParkingType.ShortTermParking: return(new ShortTermParkingCalculator()); } throw new InvalidEnumArgumentException("type", (int)type, type.GetType()); }
public double Cost(ParkingType parkingType, double timeParked) { if (parkingType == ParkingType.General) { return(1 * timeParked); } if (parkingType == ParkingType.Valet) { return(2 * timeParked); } return(3 * timeParked); //return parkingType * timeParked; }
// GET: ParkingTypes/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ParkingType parkingType = db.ParkingTypes.Find(id); if (parkingType == null) { return(HttpNotFound()); } return(View(parkingType)); }
/// <summary> /// Parks a vehicle into the Parking system /// </summary> /// <param name="parkingType">Type of Parking</param> /// <returns>Ticket number</returns> public string ParkVehicle(ParkingType parkingType) { if (_parkingLot == null) { throw new InvalidOperationException("Parking lot is not opened!!!"); } var availableSpace = GetAvailableSpot(parkingType); if (availableSpace == null) { throw new ParkingSpaceNotAvailableException(); } availableSpace.IsOccupied = true; return(availableSpace.ToString()); }
public static string GetParkingType(ParkingType parkingType) { switch (parkingType) { case ParkingType.ShortTermParking: return "Short-Term Parking"; case ParkingType.EconomyParking: return "Economy Parking"; case ParkingType.LongTermSurfaceParking: return "Long-Term Surface Parking"; case ParkingType.LongTermGarageParking: return "Long-Term Garage Parking"; case ParkingType.ValetParking: return "Valet Parking"; } // required to compile return ""; }
public bool Park(Vehicle vehicle, ParkingType parkingType) { int available = availableSpace[parkingType]; if (available > 0) { Space space = new Space(); space.Vehicle = vehicle; space.Floor = new Random().Next(1, 4); space.ParkingType = parkingType; vehicleSpaceMapper.Add(vehicle.Number, space); availableSpace[parkingType] = available - 1; Console.WriteLine("Added"); return(true); } else { Console.WriteLine("Parking is Full"); return(false); } }
public void RemoveCar(ParkingType parkingType, Driver parking, ParkingSpot parkingSpot) { switch (parkingType) { case ParkingType.General: GeneralParkingSpotOwners.Remove(parking); break; case ParkingType.Valet: ValetParkingSpotOwners.Remove(parking); break; case ParkingType.FrequentFlyer: FrequentFlyerParkingSpotOwners.Remove(parking); break; default: throw new Exception("Car not found"); } ParkingSpots.Remove(parkingSpot); }
public void switchParking(ParkingType _parkingType) { ext.ParkingType = _parkingType; if (ext.ParkingType == ParkingType.LateralParking) { bigGrid.Background = new ImageBrush(ext.laterallParkingImage); theCar.RotationAngle = 180.01; } else { bigGrid.Background = new ImageBrush(ext.bigParkingImage); theCar.RotationAngle = 0.01; } foreach (Line line in this.lines) { this.bigGrid.Children.Remove(line); } this.lines.Clear(); MapWindow_SizeChanged(null, null); if (ext.ParkingType == ParkingType.LateralParking) { theCar.Left = 1160 * bigGrid.ActualHeight / funcs.getRH(); theCar.Top = 27 * bigGrid.ActualHeight / funcs.getRH(); } else { theCar.Left = 2140 * bigGrid.ActualHeight / funcs.getRH(); theCar.Top = 4500 * bigGrid.ActualHeight / funcs.getRH(); // 4553 4500 } lastBigGridWidth = bigGrid.ActualWidth; tmpRefreshShitsTimes = 1; if (ext.MapSettingsWindow != null) { ext.MapSettingsWindow.RefreshShits(); } }
public static void Initialize(PLotContext context) { context.Database.EnsureCreated(); if (context.ParkingType.Any()) { return; } var standardType = new ParkingType { Description = "Standard" }; var handicapType = new ParkingType { Description = "Handicap" }; context.ParkingType.Add(standardType); context.ParkingType.Add(handicapType); context.SaveChanges(); foreach (var i in Enumerable.Range(1, 24)) { context.ParkingSpot.Add(new ParkingSpot { Type = standardType }); } context.SaveChanges(); foreach (var i in Enumerable.Range(1, 6)) { context.ParkingSpot.Add(new ParkingSpot { Type = handicapType }); } context.SaveChanges(); }
public static void Calculate(ParkingType parkingType, string inTime, string inAMPM, string inDate, string outTime, string outAMPM, string outDate) { NavigateTo.Homepage(); Browser.SetValue(Controls.ParkingCalculator.ddlLot,EnumValues.GetParkingType(parkingType)); if (!string.IsNullOrEmpty(inTime)) { Browser.SetValue(Controls.ParkingCalculator.txtEntryTime, inTime); } if (!string.IsNullOrEmpty(inAMPM)) { Browser.SetValue(Controls.ParkingCalculator.rdoEntryTimeAMPM, inAMPM); } if (!string.IsNullOrEmpty(inDate)) { Browser.SetValue(Controls.ParkingCalculator.txtEntryDate, inDate); } if (!string.IsNullOrEmpty(outTime)) { Browser.SetValue(Controls.ParkingCalculator.txtExitTime, outTime); } if (!string.IsNullOrEmpty(outAMPM)) { Browser.SetValue(Controls.ParkingCalculator.rdoExitTimeAMPM, outAMPM); } if (!string.IsNullOrEmpty(outDate)) { Browser.SetValue(Controls.ParkingCalculator.txtExitDate, outDate); } Browser.Invoke(Controls.ParkingCalculator.btnCalculate); }
public static void VerifyResult(ParkingType parkingType, string inTime, string inAMPM, string inDate, string outTime, string outAMPM, string outDate) { bool errorIsShown = false; inDate = Utility.CalculateDate(inDate); outDate = Utility.CalculateDate(outDate); DateTime entryDateTime = DateTime.MinValue, exitDateTime = DateTime.MinValue; // Convert entry and exit to a Date time. If we can't convert then the app should be displaying an error try { entryDateTime = Convert.ToDateTime(inDate + " " + inTime + " " + inAMPM); } catch (Exception) { // Date or time is invalid, we should show an error. errorIsShown = SpecificErrorIsShown(ErrorMessages.EnterCorrectDate); } try { exitDateTime = Convert.ToDateTime(outDate + " " + outTime + " " + outAMPM); } catch (Exception) { // Date or time is invalid, we should show an error. errorIsShown = SpecificErrorIsShown(ErrorMessages.EnterCorrectDate); } // if we have shown the error, the date is not valid so exit and pass the test if (!errorIsShown) { VerifyResult(parkingType, entryDateTime, exitDateTime); } }
public ActionResult <ParkingType> Put(long id, ParkingType c) { var parkingType = this.parkingTypeRepository.Update(id, c); return(Ok(parkingType)); }
public static void Calculate(ParkingType parkingType, DateTime inDateTime, DateTime outDateTime) { throw new NotImplementedException(); }
public void CalculateCost(ParkingType parkingType, int minutes) { IParkingCostCalculator calculator = CalculatorFactory.CreateCalculator(parkingType); _view.GiveParkingCost(calculator.CalculateCost(minutes)); }
public static void Calculate(ParkingType parkingType, DateTime inDateTime, DateTime outDateTime) { Physical.Parking.Calculate(parkingType, inDateTime, outDateTime); }
public static void CalculateAndVerify(ParkingType parkingType, string inTime, string inAMPM, string inDate, string outTime, string outAMPM, string outDate) { Calculate(parkingType, inTime, inAMPM, inDate, outTime, outAMPM, outDate); Verification.Verify.VerifyResult(parkingType, inTime, inAMPM, inDate, outTime, outAMPM, outDate); }
public Parking(ParkingType type) { this.type = type; switch (type) { case ParkingType.P0Single: { height = 2000; width = 6000; widthOffset = 6000; necessaryRoad = 3500; isDouble = false; break; } case ParkingType.P0Double: { height = 4000; width = 6000; widthOffset = 6000; necessaryRoad = 3500; isDouble = true; break; } case ParkingType.P45Single: { height = 5162; width = 5162; widthOffset = 3253; necessaryRoad = 3500; isDouble = false; break; } case ParkingType.P45Double: { height = 8697; width = 5162; widthOffset = 3253; necessaryRoad = 3500; isDouble = true; break; } case ParkingType.P60Single: { height = 5480; width = 4492; widthOffset = 2656; necessaryRoad = 4500; isDouble = false; break; } case ParkingType.P60Double: { height = 9810; width = 4492; widthOffset = 2656; necessaryRoad = 4500; isDouble = true; break; } case ParkingType.P90Single: { height = 5000; width = 2300; widthOffset = 2300; necessaryRoad = 6000; isDouble = false; break; } case ParkingType.P90Double: { height = 10000; width = 2300; widthOffset = 2300; necessaryRoad = 6000; isDouble = true; break; } } }
/// <summary> /// Instantiates a Parking space /// </summary> /// <param name="locationX">X Location of the parking space</param> /// <param name="locationY">Y Location of the parking space</param> /// <param name="type">Type of parking</param> public ParkingSpace(int locationX, int locationY, ParkingType type) : this(locationX, locationY) { Type = type; }
public async Task <IHttpActionResult> PopulateParkingTableFromImport() { using (var db = DbHelper.GetDb()) { var incoming = await db.OuMapDumpParkings.ToListAsync(); incoming.ForEach(p => { var customData = JsonConvert.DeserializeObject <OuMapsCustomGeoData>(p.geodata); var marker = new Models.Point() { Position = new Position() { Longitude = customData.Longitude, Latitude = customData.Latitude } }; var shape = customData.Polygon; int spaces, handicap; if (!int.TryParse(p.spacecount, out spaces)) { spaces = 0; } if (!int.TryParse(p.handicappedcount, out handicap)) { handicap = 0; } var location = new Models.DB.Location() { Name = p.loctitle, Description = p.loctext, ImgUrl = string.IsNullOrEmpty(p.locimg) ? p.locimg : "http://www.ou.edu" + p.locimg, MarkerData = JsonConvert.SerializeObject(marker, Formatting.Indented), GeoData = JsonConvert.SerializeObject(shape, Formatting.Indented) }; var parking = new Models.DB.Parking() { ParkingCode = p.loccode, HandicapCount = handicap, SpaceCount = spaces }; foreach (var parkingType in p.parkingtypes.Split(',')) { var trimmed = parkingType.Trim(); var type = db.ParkingTypes.Local.FirstOrDefault(t => t.Name == trimmed); if (type == null) { type = new ParkingType() { Name = trimmed }; db.ParkingTypes.Add(type); } parking.ParkingTypes.Add(type); } location.Parking = parking; db.Locations.Add(location); }); try { return(Ok(await db.SaveChangesAsync())); } catch (Exception e) { return(Content(HttpStatusCode.InternalServerError, e)); } } }
public static void VerifyResult(ParkingType parkingType, DateTime inDateTime, DateTime outDateTime) { TimeSpan ts = (outDateTime - inDateTime); int days = ts.Days; int Remaininghours = ts.Hours; int Remainingminutes = ts.Minutes; int ChargableWeeks = 0, ChargableDays = 0, ChargableHours = 0; decimal cost = 0; switch (parkingType) { case ParkingType.ShortTermParking: // $2 first hour; $1 each additional 1/2 hour $24 daily maximum break; case ParkingType.EconomyParking: // $2 per hour $9 daily maximum $54 per week (7th day free) // NOTE: The "spec" says $2 per hour, but the app has $4 per hour int EconomyBaseRate = 2; // Calculate weeks ChargableWeeks = days / 7; cost = ChargableWeeks * 54; // calculate days ChargableDays = days % 7; cost = cost + ChargableDays * 9; // calculate hours ChargableHours = Remaininghours; int hourCost = Remaininghours * EconomyBaseRate; if (hourCost > 9) { hourCost = 9; } if ((Remainingminutes > 0) && (hourCost < 7)) { cost = cost + hourCost + EconomyBaseRate; } else { cost = cost + hourCost; } break; case ParkingType.LongTermSurfaceParking: // $2 per hour $10 daily maximum $60 per week (7th day free) break; case ParkingType.LongTermGarageParking: // $2 per hour $12 daily maximum $72 per week (7th day free) break; case ParkingType.ValetParking: // $18 per day $12 for five hours or less break; } // Cleanup the result and tokenise it into an array Regex regex = new Regex(@"\s{2,}",RegexOptions.IgnorePatternWhitespace | RegexOptions.Singleline); string actual = regex.Replace(Physical.Parking.GetResult().Trim()," "); string[] splitResult = actual.Split(' '); Assert.AreEqual(days,Convert.ToInt32(splitResult[2].Replace("(","")),"Verification of number of days."); Assert.AreEqual(ChargableHours,Convert.ToInt32(splitResult[4]),"Verification of number of hours"); Assert.AreEqual(Remainingminutes, Convert.ToInt32(splitResult[6]), "Verifciation of number of minutes."); Assert.AreEqual("$" + cost.ToString("#,#.00#"), "$" + splitResult[1]); //$ 4.00 (0 Days, 0 Hours, 59 Minutes) }