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

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