public ActionResult DeleteParkingFloor(int id) { ParkingFloor parkingFloor = parkingFloorService.Get(id); string name = $"{parkingFloor.Id}"; return(View("DeleteParkingFloor", name)); }
public void Delete(long id) { ParkingFloor parkingFloor = parkingFloorRepository.Get(id); parkingFloorRepository.Remove(parkingFloor); parkingFloorRepository.SaveChanges(); }
public void FullFloor() { var floor = new ParkingFloor(null, "A", 5); foreach (var item in floor.ParkingLocations) { item.ParkAuto(new Auto("", 0)); } Assert.IsTrue(floor.IsFull); }
public void NewFloor() { var floor = new ParkingFloor(null, "A", 10); Assert.AreEqual("A", floor.Name); Assert.AreEqual(10, floor.ParkingLocations.Count); Assert.AreEqual("A-0", floor.ParkingLocations[0].Name); Assert.AreEqual("A-5", floor.ParkingLocations[5].Name); Assert.IsFalse(floor.IsFull); }
public void FloorTick() { var facility = new ParkingFacility(); var ramp = new ParkingRamp(facility, "Red", 0, 100); var floor = new ParkingFloor(ramp, "A", 5); floor.InQueue.Enqueue(new Auto("", .001)); floor.Tick(); Assert.AreEqual(1, floor.ParkingLocations.Where(r => r.Occupant != null).Count()); Simulator.Clock.Tick(); floor.Tick(); Assert.AreEqual(0, floor.ParkingLocations.Where(r => r.Occupant != null).Count()); }
public void FloorOpenLocation() { var floor = new ParkingFloor(null, "A", 5); foreach (var item in floor.ParkingLocations) { item.ParkAuto(new Auto("", 0)); } floor.ParkingLocations[3].AutoDeparts(); var location = floor.FindOpenLocation(); Assert.IsNotNull(location); Assert.AreEqual(location, floor.ParkingLocations[3]); }
public ActionResult AddParkingLot(ParkingLotViewModel model) { ParkingLot parkingLotEntity = new ParkingLot { CompanyName = model.CompanyName, Address = model.Address, ZipCode = model.ZipCode, AddedDate = DateTime.UtcNow, ModifiedDate = DateTime.UtcNow, InitialNumberOfFloors = model.InitialNumberOfFloors, InitialNumberOfSpotsPerFloor = model.InitialNumberOfSpotsPerFloor }; List <ParkingFloor> parkingFloors = new List <ParkingFloor>(); for (int i = 0; i < model.InitialNumberOfFloors; i++) { ParkingFloor parkingFloor = new ParkingFloor { AddedDate = DateTime.UtcNow, ModifiedDate = DateTime.UtcNow, }; parkingFloor.ParkingSpots = new List <ParkingSpot>(); for (int j = 0; j < model.InitialNumberOfSpotsPerFloor; j++) { ParkingSpot parkingSpot = new ParkingSpot { AddedDate = DateTime.UtcNow, ModifiedDate = DateTime.UtcNow, }; parkingSpot.ParkingFloor = parkingFloor; parkingFloor.ParkingSpots.Add(parkingSpot); } parkingFloor.ParkingLot = parkingLotEntity; parkingFloors.Add(parkingFloor); } parkingLotEntity.ParkingFloors = parkingFloors; parkingLotService.Insert(parkingLotEntity); if (parkingLotEntity.Id > 0) { return(RedirectToAction("index")); } return(View(model)); }
public void FloorDepartAuto() { var floor = new ParkingFloor(null, "A", 5); foreach (var item in floor.ParkingLocations) { item.ParkAuto(new Auto("", 0)); } var auto = floor.ParkingLocations[3].Occupant; floor.AutoExitingFrom(floor.ParkingLocations[3]); Assert.IsNotNull(auto); Assert.IsNull(floor.ParkingLocations[3].Occupant); Assert.IsFalse(floor.IsFull); Assert.AreEqual(1, floor.OutQueueLength); }
public ActionResult AddParkingFloor(ParkingFloorViewModel model) { var parkingLot = parkingLotService.Get(model.ParkingLotId); if (parkingLot != null) { ParkingFloor parkingFloorEntity = new ParkingFloor { NumberOfSpots = model.NumberOfSpots, AddedDate = DateTime.UtcNow, ModifiedDate = DateTime.UtcNow, ParkingLotId = model.ParkingLotId }; List <ParkingSpot> parkingSpots = new List <ParkingSpot>(); for (int j = 0; j < model.NumberOfSpots; j++) { ParkingSpot parkingSpot = new ParkingSpot { AddedDate = DateTime.UtcNow, ModifiedDate = DateTime.UtcNow, }; parkingFloorEntity.ParkingSpots = parkingSpots; parkingSpots.Add(parkingSpot); } parkingFloorEntity.ParkingSpots = parkingSpots; parkingFloorService.Insert(parkingFloorEntity); if (parkingFloorEntity.Id > 0) { return(RedirectToAction("index")); } return(View(model)); } else { TempData["NoLotMessage"] = "The Lot number does not exist"; return(RedirectToAction("Index")); } }
// Admin public void AddFloor(ParkingFloor floor) { ParkingManager.AddFloor(floor); }
// admin internal void AddFloor(ParkingFloor floor) { ParkingFloors.Add(floor); }
public void Update(ParkingFloor parkingFloor) { parkingFloorRepository.Update(parkingFloor); }
public void Insert(ParkingFloor parkingFloor) { parkingFloorRepository.Insert(parkingFloor); }