public bool AddTransactionInformation(BookedPassInformationViewModel bookingInfo, bool pgStatus, string transId)
 {
     _logger.LogInfo("Trying to add new PG transaction information after payment for Id " + transId);
     try
     {
         PGTransactionInformation pgInfo = new PGTransactionInformation();
         pgInfo.BookingDate             = bookingInfo.BookingDate;
         pgInfo.BookedPassInformationId = bookingInfo.Id;
         pgInfo.TravellerId             = bookingInfo.TravellerId;
         pgInfo.UniqueReferrenceNumber  = bookingInfo.UniqueReferrenceNumber;
         pgInfo.TransactionNumber       = transId;
         pgInfo.TotalAmout      = bookingInfo.TotalAmout;
         pgInfo.PaymentStatus   = pgStatus;
         pgInfo.PaymentResponse = pgStatus ? "Success" : "Failed";
         pgInfo.PaymentMode     = "Credit Card";
         pgInfo.IsActive        = pgStatus;
         _paymentGatewayRepository.AddTransactionInformation(pgInfo);
         _logger.LogInfo("PG transaction information updated successfully for trans Id " + transId);
         return(true);
     }
     catch (Exception ex)
     {
         _logger.LogError(ex.Message);
         return(false);
     }
 }
Esempio n. 2
0
        public async Task <ActionResult <TravellerResponse> > BookPass([FromBody] BookedPassInformationViewModel bookingInfo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(string.Format(_messageHandler.GetMessage(ErrorMessagesEnum.ModelValidation), "", ModelState.Values.First().Errors.First().ErrorMessage)));
            }
            var response = await _travellerService.BookPass(bookingInfo);

            return(Ok(response));
        }
Esempio n. 3
0
 public async Task <BookedPassInformationViewModel> GetBookingDatailsById(string uId)
 {
     _logger.LogInfo("Trying to get booking info with booking id " + uId);
     try
     {
         BookedPassInformationViewModel bookingInfo = _mapper.Map <BookedPassInformation, BookedPassInformationViewModel>(await _travellerRepository.GetBookingDatailsById(uId));
         _logger.LogInfo("Retrieved booking info with booking id " + uId);
         return(bookingInfo);
     }
     catch (Exception ex)
     {
         _logger.LogInfo(ex.Message);
         return(null);
     }
 }
Esempio n. 4
0
 public bool UpdateBookingInformation(BookedPassInformationViewModel bookingInfo, bool pgStatus, string transId)
 {
     _logger.LogInfo("Trying to update Booking pass information after payment");
     try
     {
         BookedPassInformation bookingInformation = _travellerRepository.GetBookingDatailsById(bookingInfo.UniqueReferrenceNumber).Result;
         bookingInformation.PaymentStatus     = pgStatus;
         bookingInformation.TransactionNumber = transId;
         bookingInformation.IsActive          = pgStatus;
         bookingInformation.PaymentResponse   = pgStatus ?"Success":"Failed";
         _travellerRepository.UpdateBookingInformation(bookingInformation);
         _logger.LogInfo("Booking pass information updated successfully for id " + bookingInfo.UniqueReferrenceNumber);
         return(true);
     }
     catch (Exception ex)
     {
         _logger.LogError(ex.Message);
         return(false);
     }
 }
Esempio n. 5
0
        public async Task <TravellerResponse> BookPass(BookedPassInformationViewModel bookingInfo)
        {
            _logger.LogInfo("Trying to book pass having id " + bookingInfo.PassInformationId + "with traveller id " + bookingInfo.TravellerDeviceId);
            try
            {
                //Get selected pass information based on id
                PassInformationViewModel passInformation = _mapper.Map <PassInformation, PassInformationViewModel>(await _passRepository.GetActivePass(bookingInfo.PassInformationId));
                if (passInformation == null)
                {
                    throw new Exception(string.Format(_messageHandler.GetMessage(ErrorMessagesEnum.InValidPassInformation)));
                }

                //Get active user based on device id
                Traveller travellerInfo    = new Traveller();
                var       isExistTraveller = _travellerRepository.GetTravellerByDeviceId(bookingInfo.TravellerDeviceId);
                if (isExistTraveller == null)
                {
                    //Add traveller information
                    travellerInfo.DeviceId   = bookingInfo.TravellerDeviceId;
                    travellerInfo.DeviceType = bookingInfo.TravellerDeviceType;
                    travellerInfo.IsActive   = true;

                    //Added new traveller
                    _travellerRepository.AddTraveller(travellerInfo);
                    _logger.LogInfo("Successfully added new traveller with device id " + bookingInfo.TravellerDeviceId);

                    //Once traveller info added then get the traveller id
                    isExistTraveller = _travellerRepository.GetTravellerByDeviceId(bookingInfo.TravellerDeviceId);
                }

                //Business logic goes here for booking pass information
                bookingInfo.TravellerId            = isExistTraveller.Id;
                bookingInfo.UniqueReferrenceNumber = "HST-" + bookingInfo.TravellerId + "-" + DateTime.Now.ToString("ddMMyyhhmmssff");
                bookingInfo.TransactionNumber      = DateTime.Now.ToString("ddMMyyhhmmssff");
                bookingInfo.BookingDate            = DateTime.Today;
                bookingInfo.TotalAmout             = (bookingInfo.Adult * passInformation.AdultPrice) + (bookingInfo.Child * passInformation.ChildPrice);
                bookingInfo.IsActive = true;
                bookingInfo.QRCode   = null;
                // QR code information to be stored with booking information id
                QRCodeViewModel qrCode = new QRCodeViewModel();
                //bookingInfo.PaymentStatus = true;
                //bookingInfo.IsActive = true;
                //bookingInfo.PaymentResponse = "Success";
                qrCode.IsActive = false;
                qrCode.BookedPassInformationId = bookingInfo.Id;
                qrCode.PassExpiredDuraionDate  = passInformation.PassExpiredDate;
                bookingInfo.QRCode             = qrCode;
                ///////////////////////////////////////////////////////////////
                if (bookingInfo.TotalAmout == 0)
                {
                    throw new Exception(string.Format(_messageHandler.GetMessage(ErrorMessagesEnum.InValidPassengerInformation)));
                }
                _travellerRepository.BookPass(_mapper.Map <BookedPassInformation>(bookingInfo));
                _logger.LogInfo("Successfully addded booking information");
                TravellerResponse response = new TravellerResponse(true, string.Format(_messageHandler.GetSuccessMessage(SuccessMessagesEnum.SuccessfullySaved)));
                response.Result = bookingInfo.UniqueReferrenceNumber;
                return(response);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                return(new TravellerResponse(false, ex.Message));
            }
        }
Esempio n. 6
0
        private bool ProcessAppointmentAfterPaytmPayment(GMOPaymentResponse response, BookedPassInformationViewModel bookingInfo)
        {
            try
            {
                if (response != null)
                {
                    bool   pgStatus       = false;
                    bool   bookingStatus  = false;
                    string Vmmp_txn       = response.ShopID;
                    bool   VpaymentStatus = String.IsNullOrEmpty(response.ErrorCode) ? true : false;
                    _logger.LogError("Payment gateway response status: " + VpaymentStatus);

                    _logger.LogError("Trying to update success booking pass information for id " + bookingInfo.UniqueReferrenceNumber);
                    bookingStatus = _travellerService.UpdateBookingInformation(bookingInfo, VpaymentStatus, response.TranID);
                    _logger.LogInfo("Booking pass information updated successfully for id " + bookingInfo.UniqueReferrenceNumber);

                    ///////////////////////////////// Add New PG Transation Information /////////////////////////
                    if (bookingStatus)
                    {
                        _logger.LogError("Trying to add new payment gateway transaction for id " + bookingInfo.UniqueReferrenceNumber);
                        pgStatus = _paymentGatewayTransactionService.AddTransactionInformation(bookingInfo, VpaymentStatus, response.TranID);
                        _logger.LogInfo("PG transaction information updated successfully for trans Id " + response.TranID);
                        return(pgStatus);
                    }
                    return(bookingStatus);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                return(false);
            }
        }