public async Task OnGet(int?id, int pickUp, int dropDown, DateTime reserveFrom, DateTime reserveTo) { Car = await carManager.GetCar((int)id); ReserveFrom = reserveFrom; ReserveTo = reserveTo; PickUpLocation = await locationManager.GetLocation(pickUp); DropDownLocation = await locationManager.GetLocation(dropDown); }
// GET: Locations/Details/5 public async Task <IActionResult> Details(int id) { var location = await _context.GetLocation(id); if (location == null) { return(NotFound()); } return(View(location)); }
public async Task MakeReservation(PaymentDTO car) { LocationDTO pickUpLocation = await locationManager.GetLocation(car.PickUpLocationId); LocationDTO dropDownLocation = await locationManager.GetLocation(car.DropDownLocationId); SearchDTO selectedCar = new SearchDTO { Id = car.Id, ReserveFrom = car.ReserveFrom, ReserveTo = car.ReserveTo, CountryPickUp = pickUpLocation.Country, CityPickUp = pickUpLocation.City, LocationPickUp = pickUpLocation.Address, CountryDropDown = dropDownLocation.Country, CityDropDown = dropDownLocation.City, LocationDropDown = dropDownLocation.Address }; List <int> avaibleCarIds = carManager.GetCars(selectedCar).Select(c => c.Id).ToList(); //check if still available if (avaibleCarIds.Contains(car.Id)) { string userId = httpContextAccessor.HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier); CarDTO originalCar = await carManager.GetCar(car.Id); await _context.AddAsync(new Reservation { CarId = car.Id, ReservationPrice = ((int)Math.Abs((car.ReserveFrom - car.ReserveTo).TotalDays) + 1) * originalCar.Price, ReserveFrom = car.ReserveFrom, ReserveTo = car.ReserveTo, PickUpLocationId = pickUpLocation.Id, DropDownLocationId = dropDownLocation.Id, UserId = userId }); await _context.SaveChangesAsync(); } }
/// <summary> /// Updates the location. /// </summary> public void UpdateLocation() { LocationLoading = true; LocationManager.GetLocation(); }
public Task <Location> GetLocation(Guid id) { return(_locationManager.GetLocation(id)); }