Beispiel #1
0
        public async Task ReturnCar(Guid bookingId, string bearer)
        {
            var booking = await bookingRepository.GetAsync(bookingId);

            var claim = JWTTokenGenerator.GetClaim(bearer, emailClaim);

            bookingRepository.Remove(booking);
            await bookingRepository.SaveAsync();
        }
        public async Task ReturnCar(Guid bookingId, string bearer)
        {
            var booking = await bookingRepository.GetAsync(bookingId);

            var claim = JWTTokenGenerator.GetClaim(bearer, emailClaim);

            if (booking.User.Email != claim)
            {
                throw new InvalidCredentialException("Not authorized!");
            }

            bookingRepository.Remove(booking);
            await bookingRepository.SaveAsync();
        }
Beispiel #3
0
        public async Task <Booking> BookCar(Guid carId, Guid userId, DateTime startDate, DateTime endDate, string bearer)
        {
            var car = await carRepository.GetAsync(carId);

            User user = await userOperationHandler.GetUser(userId);

            var claim = JWTTokenGenerator.GetClaim(bearer, emailClaim);

            var booking = Booking.Create(car, user, startDate, endDate);

            bookingRepository.Add(booking);
            await bookingRepository.SaveAsync();

            return(booking);
        }
        public async Task <Booking> BookCar(Guid carId, Guid userId, DateTime startDate, DateTime endDate, string bearer)
        {
            var car = await carRepository.GetAsync(carId);

            var user = await userRepository.GetAsync(userId);

            var claim = JWTTokenGenerator.GetClaim(bearer, emailClaim);

            if (user.Email != claim)
            {
                throw new InvalidCredentialException("Not authorized!");
            }

            var booking = Booking.Create(car, user, startDate, endDate);

            bookingRepository.Add(booking);
            await bookingRepository.SaveAsync();

            return(booking);
        }