public void ClearSearch(string type) { switch (type) { case "checklist": SearchChecklistText = string.Empty; Checklists.Clear(); _checklistRepository.All().ForEach(c => Checklists.Add(c)); break; case "customer": SearchCustomerText = string.Empty; Customers.Clear(); _customerRepository.All().ForEach(c => Customers.Add(c)); break; case "parkinglot": SearchLocationText = string.Empty; ParkingLots.Clear(); _parkingLotRepository.All().ForEach(p => ParkingLots.Add(p)); break; } SelectFirstComboBoxItem(); }
public async Task <IActionResult> PostParkingLots([FromBody] ParkingLots parkingLots) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.ParkingLots.Add(parkingLots); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (ParkingLotsExists(parkingLots.LotId)) { return(new StatusCodeResult(StatusCodes.Status409Conflict)); } else { throw; } } return(CreatedAtAction("GetParkingLots", new { id = parkingLots.LotId }, parkingLots)); }
public async Task <IActionResult> PutParkingLots([FromRoute] string id, [FromBody] ParkingLots parkingLots) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != parkingLots.LotId) { return(BadRequest()); } _context.Entry(parkingLots).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ParkingLotsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public override void OnEnter() { if (Settings.IsOfflineMode) { MessageBox.Show("Dit scherm is niet beschikbaar in offline mode."); _router.GoBack(); return; } if (_isEditing) { _isEditing = false; return; } if (ViewBag?.Task != null) { SelectedTask = ViewBag.Task; } else { SelectedTask = new Task { Inspections = new List <Inspection>(), TaskSchedules = new List <TaskSchedule>(), DateTimeStart = DateTime.Today, Hash = MD5.Crypt($"{DateTime.Now.ToLongDateString()}-{SelectedTask?.GetHashCode()}") }; EndDate = DateTime.Today.AddDays(1); IsRepeating = false; CanEditStartDate = true; } if (SelectedTask.Remarks == null) { SelectedTask.Remarks = ""; } SelectedTask.TaskSchedules.ToList().ForEach(t => TaskSchedules.Add(t)); Customers.Clear(); ParkingLots.Clear(); Checklists.Clear(); StartDate = DateTime.Today; EndDate = DateTime.Today.AddDays(1); _customerRepository.All().ForEach(Customers.Add); _checklistRepository.All().ForEach(Checklists.Add); _parkingLotRepository.All().ForEach(ParkingLots.Add); CalculateInspectionDates(); SelectFirstComboBoxItem(); }
public override object Park(Car car) { var notFullLot = ParkingLots.FirstOrDefault(l => !l.IsFull()); if (notFullLot == null) { throw new NoSpaceException("no space"); } return(notFullLot.Park(car)); }
public override object Park(Car car) { var parkingLot = ParkingLots.Where(lot => !lot.IsFull()).OrderByDescending(lot => lot.RemainSpaceCount()).FirstOrDefault(); if (parkingLot == null) { throw new NoSpaceException("no space"); } return(parkingLot.Park(car)); }
public async Task <bool> TrySelectParkingLotById(string cityId, string parkingLotId) { Debug.WriteLine("[MainVm] TrySelectParkingLotById for {0} / {1} called", cityId, parkingLotId); ParkingLot parkingLot = null; await TrySelectCityById(cityId); var city = FindCityById(MetaData, cityId); if (city != null) { Debug.WriteLine("[MainVm] TrySelectParkingLotById for {0} / {1}: load city", cityId, parkingLotId); var cityDetails = await LoadCity(city.Id); if (FindParkingLotById(cityDetails, parkingLotId) == null) { Debug.WriteLine("[MainVm] TrySelectParkingLotById for {0} / {1}: force refresh city details", cityId, parkingLotId); cityDetails = await LoadCity(city.Id, true); } await DispatcherHelper.RunAsync(() => { SelectedCity = city; SelectedCityData = cityDetails; Debug.WriteLine( "[MainVm] TrySelectParkingLotById for {0} / {1}: set city + city data. find parking lot now", cityId, parkingLotId); }); parkingLot = FindParkingLotById(cityDetails, parkingLotId); } if (parkingLot != null) { await DispatcherHelper.RunAsync(() => { Debug.WriteLine("[MainVm] TrySelectParkingLotById for {0} / {1}: success", cityId, parkingLotId); var plot = ParkingLots.FirstOrDefault(x => x.Id == parkingLot.Id); if (plot != null) { SelectedParkingLot = plot; } }); return(true); } return(false); }
public override string ParkCar(Car car) { if (car == null) { return("wrong car"); } var usableLot = ParkingLots.Aggregate((current, next) => current.AvailablePositionRate >= next.AvailablePositionRate ? current : next); if (usableLot != null) { var ticket = usableLot.AddCarGetTicket(car); return(ticket); } return("Not enough position"); }
public void Search(string listType) { if (listType == "checklist") { Checklists.Clear(); _checklistRepository.All() .Where(c => c.Name.ToLower().Contains(SearchChecklistText.ToLower()) || c.Remarks.ToLower().Contains(SearchChecklistText.ToLower()) ).ToList().ForEach(c => Checklists.Add(c)); } else if (listType == "parkinglot") { ParkingLots.Clear(); _parkingLotRepository.All() .Where(p => p.Address.City.ToLower().Contains(SearchLocationText.ToLower()) || p.Address.Country.ToLower().Contains(SearchLocationText.ToLower()) || p.Address.ZipCode.ToLower().Contains(SearchLocationText.ToLower()) || p.Address.Street.ToLower().Contains(SearchLocationText.ToLower()) ).ToList().ForEach(p => ParkingLots.Add(p)); SelectFirstComboBoxItem(); } else if (listType == "customer") { Customers.Clear(); _customerRepository.All() .Where(c => c.Name.ToLower().Contains(SearchCustomerText.ToLower()) || c.Email.ToLower().Contains(SearchCustomerText.ToLower()) || c.Contact.ToLower().Contains(SearchCustomerText.ToLower()) || c.PhoneNumber.ToLower().Contains(SearchCustomerText.ToLower()) || c.Address.Street.ToLower().Contains(SearchCustomerText.ToLower()) || c.Address.ZipCode.ToLower().Contains(SearchCustomerText.ToLower()) || c.Address.City.ToLower().Contains(SearchCustomerText.ToLower()) || c.Address.Country.ToLower().Contains(SearchCustomerText.ToLower()) ).ToList().ForEach(c => Customers.Add(c)); } SelectFirstComboBoxItem(); }
public override string TryPark(Car car, out Ticket ticket) { var currentLot = ParkingLots.Where(x => x.IsAvailabe).OrderBy(x => x.AvailablePositions / x.Capacity).LastOrDefault(); return(TryParkToSpecificLot(car, currentLot, out ticket)); }
public string TryFetch(Ticket ticket, out Car car) { var currentLot = ParkingLots.FirstOrDefault(x => x.LotName == ticket.LotName); return(this.TryFetchFromSpecificLot(ticket, currentLot, out car)); }
public virtual string TryPark(Car car, out Ticket ticket) { var currentLot = ParkingLots.FirstOrDefault(x => x.IsAvailabe); return(this.TryParkToSpecificLot(car, currentLot, out ticket)); }
private ParkingLot ChooseParkingLotWithMoreEmptyPositions() { var maxCapacity = ParkingLots.Max(p => p.Capacity); return(ParkingLots.Find(p => p.Capacity == maxCapacity && p.IsFull == false)); }
private ParkingLot ChooseParkingLotWithLargerAvailablePositionRate() { var maxAvailablePositionRate = ParkingLots.Max(p => GetAvailablePositionRate(p)); return(ParkingLots.Find(p => GetAvailablePositionRate(p) == maxAvailablePositionRate && p.IsFull == false)); }