Exemple #1
0
        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);
        }
Exemple #2
0
        // 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));
        }
Exemple #3
0
        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();
            }
        }
Exemple #4
0
        /// <summary>
        /// Updates the location.
        /// </summary>
        public void UpdateLocation()
        {
            LocationLoading = true;

            LocationManager.GetLocation();
        }
Exemple #5
0
 public Task <Location> GetLocation(Guid id)
 {
     return(_locationManager.GetLocation(id));
 }