public async Task <UserCheckoutResponseViewModel> LoginUserToDeliveryOption([FromBody] GuestSignInToDeliveryTransactionFormDataViewModel model) { try { var clientIpAddress = _clientIpProvider.Get(); //reserve timeslot for Hoho if any ReserveTimeSlotCommandResult resereBookingResult = new ReserveTimeSlotCommandResult(); var IsTimeSlotBooking = model.EventTicketAttributeList.Where(s => s.ReserveHohoBook == true).ToList(); if (IsTimeSlotBooking.Count() > 0) { resereBookingResult = await _commandSender.Send <ReserveTimeSlotCommand, ReserveTimeSlotCommandResult>(new ReserveTimeSlotCommand { EventTicketAttributeList = model.EventTicketAttributeList.Where(s => s.ReserveHohoBook == true).ToList(), UserAltId = model.UserAltId }); if (!resereBookingResult.Success) { return(new UserCheckoutResponseViewModel { Success = false, Session = await _sessionProvider.Get(), TransactionId = 0, }); } } CreateOrderCommandResult createOrderResult = new CreateOrderCommandResult(); // Check if place is Tiqets one if (model.IsTiqets) { createOrderResult = await _commandSender.Send <CreateOrderCommand, CreateOrderCommandResult>(new CreateOrderCommand { EventTicketAttributeList = model.EventTicketAttributeList, UserAltId = model.UserAltId }); } if ((model.IsTiqets && createOrderResult != null && createOrderResult.Success) || !model.IsTiqets) { CheckoutCommandResult transactionResult = await _commandSender.Send <CheckoutCommand, CheckoutCommandResult>(new CheckoutCommand { ChannelId = Contracts.Enums.Channels.Feel, EventTicketAttributeList = model.EventTicketAttributeList, UserAltId = model.UserAltId, Ip = clientIpAddress, TransactionType = model.IsItinerary ? TransactionType.Itinerary : TransactionType.Regular, TransactionCurrency = model.TransactionCurrency, TargetCurrencyCode = _geoCurrency.GetSessionCurrency(HttpContext), IsLoginCheckout = true, ReferralId = model.ReferralId, DonationAmount = model.DonationAmount, IsBSPUpgrade = model.IsBSPUpgrade }); if (model.IsTiqets) { await _commandSender.Send(new Contracts.Commands.Tiqets.SaveOrderCommand { TransactionId = transactionResult.Id, PaymentToken = createOrderResult.PaymentToken, OrderRefernceId = createOrderResult.OrderRefernceId, ModifiedBy = model.UserAltId }); } if (IsTimeSlotBooking.Count() > 0 && resereBookingResult.Success) { await _commandSender.Send(new Contracts.Commands.CitySightSeeing.SaveOrderCommand { TransactionId = transactionResult.Id, FromTime = resereBookingResult.FromTime, EndTime = resereBookingResult.EndTime, Distributor_reference = resereBookingResult.Distributor_reference, Reservation_reference = resereBookingResult.Reservation_reference, Reservation_valid_until = resereBookingResult.Reservation_valid_until, TicketId = resereBookingResult.TicketId, ModifiedBy = model.UserAltId }); } var filteredEventVenueMapping = model.EventTicketAttributeList.Where(w => (w.EventVenueMappingTimeId != -1 || w.EventVenueMappingTimeId != 0)); foreach (var item in filteredEventVenueMapping.Where(s => s.EventVenueMappingTimeId != 0)) { await _commandSender.Send(new TransactionMoveAroundMappingCommand { TransactionId = transactionResult.Id, EventVenueMappingTimeId = item.EventVenueMappingTimeId, PurchaserAddress = item.PurchaserAddress, CreatedUtc = DateTime.UtcNow, CreatedBy = Guid.NewGuid(), ModifiedBy = Guid.NewGuid() }); } try { var orderData = await _querySender.Send(new CurrentOrderDataQuery { TransactionAltId = transactionResult.TransactionAltId }); orderData.Transaction.NetTicketAmount = _geoCurrency.Exchange((decimal)orderData.Transaction.NetTicketAmount, orderData.CurrencyType.Code); orderData.Transaction.GrossTicketAmount = _geoCurrency.Exchange((decimal)orderData.Transaction.GrossTicketAmount, orderData.CurrencyType.Code); orderData.Transaction.ServiceCharge = _geoCurrency.Exchange(orderData.Transaction.ServiceCharge != null ? (decimal)orderData.Transaction.ServiceCharge : 0, orderData.CurrencyType.Code); orderData.Transaction.ConvenienceCharges = _geoCurrency.Exchange(orderData.Transaction.ConvenienceCharges != null ? (decimal)orderData.Transaction.ConvenienceCharges : 0, orderData.CurrencyType.Code); foreach (var item in orderData.orderConfirmationSubContainer) { foreach (var eventContainer in item.subEventContainer) { foreach (var eta in eventContainer.EventTicketAttribute) { _geoCurrency.eventTicketAttributeUpdate(eta, HttpContext, "USD"); } foreach (var td in eventContainer.TransactionDetail) { _geoCurrency.updateTransactionDetail(td, HttpContext, orderData.CurrencyType.Id, "USD"); } } } await _mailChimpProvider.AddBuyerCart(orderData); } catch (Exception e) { _logger.Log(LogCategory.Error, e); } return(new UserCheckoutResponseViewModel { Success = true, IsPaymentByPass = transactionResult.IsPaymentByPass, StripeAccount = transactionResult.StripeAccount, TransactionAltId = transactionResult.TransactionAltId, Session = await _sessionProvider.Get(), TransactionId = transactionResult.Id, }); } else { return(new UserCheckoutResponseViewModel { Success = false, Session = await _sessionProvider.Get(), TransactionId = 0, IsTiqetsOrderFailure = true }); } } catch (Exception ex) { _logger.Log(LogCategory.Error, ex); return(new UserCheckoutResponseViewModel { Success = false, Session = await _sessionProvider.Get(), TransactionId = 0, }); } }
public async Task <UserCheckoutResponseViewModel> Login([FromBody] LoginTransactionFormDataViewModel model) { model.UserDetail.ChannelId = Channels.Feel; var authenticated = await _authenticationHelper.AuthenticateUser(model.UserDetail, u => { return(Task.FromResult(true)); }); if (authenticated) { var queryResult = await _querySender.Send(new LoginUserQuery { Email = model.UserDetail.Email, Password = model.UserDetail.Password, ChannelId = Channels.Feel, }); var clientIpAddress = _clientIpProvider.Get(); //reserve timeslot for Hoho if any ReserveTimeSlotCommandResult resereBookingResult = new ReserveTimeSlotCommandResult(); var IsTimeSlotBooking = model.EventTicketAttributeList.Where(s => s.ReserveHohoBook == true).ToList(); if (IsTimeSlotBooking.Count() > 0) { resereBookingResult = await _commandSender.Send <ReserveTimeSlotCommand, ReserveTimeSlotCommandResult>(new ReserveTimeSlotCommand { EventTicketAttributeList = model.EventTicketAttributeList.Where(s => s.ReserveHohoBook == true).ToList(), UserAltId = queryResult.User.AltId, }); if (!resereBookingResult.Success) { return(new UserCheckoutResponseViewModel { Success = false, Session = await _sessionProvider.Get(), TransactionId = 0, }); } } CreateOrderCommandResult createOrderResult = new CreateOrderCommandResult(); // Check if place is Tiqets one if (model.IsTiqets) { createOrderResult = await _commandSender.Send <CreateOrderCommand, CreateOrderCommandResult>(new CreateOrderCommand { EventTicketAttributeList = model.EventTicketAttributeList, UserAltId = queryResult.User.AltId, }); } if ((model.IsTiqets && createOrderResult != null && createOrderResult.Success) || !model.IsTiqets) { CheckoutCommandResult transactionResult = await _commandSender.Send <CheckoutCommand, CheckoutCommandResult>(new CheckoutCommand { ChannelId = Contracts.Enums.Channels.Feel, EventTicketAttributeList = model.EventTicketAttributeList, UserAltId = queryResult.User.AltId, Ip = clientIpAddress, TransactionType = model.IsItinerary ? TransactionType.Itinerary : TransactionType.Regular, TransactionCurrency = model.TransactionCurrency, TargetCurrencyCode = _geoCurrency.GetSessionCurrency(HttpContext), IsLoginCheckout = true, ReferralId = model.ReferralId, DonationAmount = model.DonationAmount }); if (model.IsTiqets) { await _commandSender.Send(new Contracts.Commands.Tiqets.SaveOrderCommand { TransactionId = transactionResult.Id, PaymentToken = createOrderResult.PaymentToken, OrderRefernceId = createOrderResult.OrderRefernceId, ModifiedBy = queryResult.User.AltId }); } if (IsTimeSlotBooking.Count() > 0 && resereBookingResult.Success) { await _commandSender.Send(new Contracts.Commands.CitySightSeeing.SaveOrderCommand { TransactionId = transactionResult.Id, FromTime = resereBookingResult.FromTime, EndTime = resereBookingResult.EndTime, Distributor_reference = resereBookingResult.Distributor_reference, Reservation_reference = resereBookingResult.Reservation_reference, Reservation_valid_until = resereBookingResult.Reservation_valid_until, TicketId = resereBookingResult.TicketId, TimeSlot = resereBookingResult.TimeSlot, ModifiedBy = queryResult.User.AltId }); } var filteredEventVenueMapping = model.EventTicketAttributeList.Where(w => (w.EventVenueMappingTimeId != -1 || w.EventVenueMappingTimeId != 0)); foreach (var item in filteredEventVenueMapping.Where(s => s.EventVenueMappingTimeId != 0)) { await _commandSender.Send(new TransactionMoveAroundMappingCommand { TransactionId = transactionResult.Id, EventVenueMappingTimeId = item.EventVenueMappingTimeId, PurchaserAddress = item.PurchaserAddress, CreatedUtc = DateTime.UtcNow, CreatedBy = Guid.NewGuid(), ModifiedBy = Guid.NewGuid() }); } return(new UserCheckoutResponseViewModel { IsPaymentByPass = transactionResult.IsPaymentByPass, StripeAccount = transactionResult.StripeAccount, Success = authenticated, TransactionAltId = transactionResult.TransactionAltId, Session = await _sessionProvider.Get(), TransactionId = transactionResult.Id, }); } else { return(new UserCheckoutResponseViewModel { Success = false, Session = await _sessionProvider.Get(), TransactionId = 0, IsTiqetsOrderFailure = true }); } } else { return(new UserCheckoutResponseViewModel { Success = false, Session = await _sessionProvider.Get(), TransactionId = 0, }); } }
public CheckoutCommandResult BlockSeat(List <SeatDetail> seatData, TransactionDetail transactionDetail, FIL.Contracts.DataModels.EventTicketAttribute eventTicketAttribute, EventTicketDetail eventTicketDetail, Guid userAltId, Channels channelId) { try { CheckoutCommandResult checkoutCommandResult = new CheckoutCommandResult(); FIL.Contracts.DataModels.EventDetail eventDetails = _eventDetailRepository.Get(eventTicketDetail.EventDetailId); var BarcodeNumber = ""; int seatCounter = 0; if (eventTicketDetail.InventoryTypeId == InventoryType.Seated || eventTicketDetail.InventoryTypeId == InventoryType.SeatedWithSeatSelection) { if (seatData != null) { foreach (var seat in seatData) { FIL.Contracts.DataModels.MatchLayoutSectionSeat matchLayoutSectionSeats = _matchLayoutSectionSeatRepository.Get(seat.MatchLayoutSectionSeatId); if (matchLayoutSectionSeats != null && matchLayoutSectionSeats.SeatStatusId != SeatStatus.Sold) { Random rd = new Random(); BarcodeNumber = eventDetails.StartDateTime.ToString("ddMM"); int uniqueIdLength = 4; string uniqueIdChars = "1234567890"; char[] uniqueIdChar = new char[uniqueIdLength]; for (int j = 0; j < uniqueIdLength; j++) { uniqueIdChar[j] = uniqueIdChars[rd.Next(0, uniqueIdChars.Length)]; } string uniqueId = new string(uniqueIdChar); matchLayoutSectionSeats.Id = matchLayoutSectionSeats.Id; matchLayoutSectionSeats.SeatStatusId = channelId == Channels.Corporate ? SeatStatus.BlockedforSponsor : SeatStatus.BlockedByCustomer; matchLayoutSectionSeats.UpdatedUtc = DateTime.UtcNow; matchLayoutSectionSeats.UpdatedBy = userAltId; _matchLayoutSectionSeatRepository.Save(matchLayoutSectionSeats); _matchSeatTicketDetailRepository.Save(new MatchSeatTicketDetail { AltId = Guid.NewGuid(), EventTicketDetailId = eventTicketDetail.Id, MatchLayoutSectionSeatId = matchLayoutSectionSeats.Id, BarcodeNumber = BarcodeNumber + "0" + (short)channelId + matchLayoutSectionSeats.Id + uniqueId, Price = transactionDetail.PricePerTicket, TransactionId = transactionDetail.TransactionId, ModifiedBy = userAltId, TicketTypeId = (TicketType)transactionDetail.TicketTypeId, SeatStatusId = SeatStatus.Sold, PrintStatusId = PrintStatus.NotPrinted, IsEnabled = true, EntryCountAllowed = 1, ChannelId = channelId, }); seatCounter++; } } if (seatData.Count == seatCounter) { checkoutCommandResult.Success = true; checkoutCommandResult.IsSeatSoldOut = false; } else { checkoutCommandResult.Success = false; checkoutCommandResult.IsSeatSoldOut = true; } } else { List <FIL.Contracts.DataModels.MatchLayoutSectionSeat> matchLayoutSectionSeats = AutoMapper.Mapper.Map <List <FIL.Contracts.DataModels.MatchLayoutSectionSeat> >(_matchLayoutSectionSeatRepository.GetByEventTicketDetails(eventTicketDetail.Id, transactionDetail.TotalTickets)); if (matchLayoutSectionSeats.Count == transactionDetail.TotalTickets) { foreach (var seatItem in matchLayoutSectionSeats) { Random rd = new Random(); BarcodeNumber = eventDetails.StartDateTime.ToString("ddMM"); int uniqueIdLength = 4; string uniqueIdChars = "1234567890"; char[] uniqueIdChar = new char[uniqueIdLength]; for (int j = 0; j < uniqueIdLength; j++) { uniqueIdChar[j] = uniqueIdChars[rd.Next(0, uniqueIdChars.Length)]; } string uniqueId = new string(uniqueIdChar); if (seatItem.SeatStatusId == SeatStatus.UnSold && (seatItem.SeatTypeId == SeatType.Available || seatItem.SeatTypeId == SeatType.WheelChair)) { if (seatItem.SeatTypeId == SeatType.WheelChair) { var wheelChairSeat = _masterLayoutCompanionSeatMappingRepository.GetByWheelChairSeatId(seatItem.Id); if (wheelChairSeat != null) { seatItem.Id = wheelChairSeat.CompanionSeatId; seatItem.SeatStatusId = channelId == Channels.Corporate ? SeatStatus.BlockedforSponsor : SeatStatus.BlockedByCustomer; seatItem.ModifiedBy = userAltId; _matchLayoutSectionSeatRepository.Save(seatItem); _matchSeatTicketDetailRepository.Save(new MatchSeatTicketDetail { AltId = Guid.NewGuid(), EventTicketDetailId = eventTicketDetail.Id, MatchLayoutSectionSeatId = wheelChairSeat.CompanionSeatId, BarcodeNumber = BarcodeNumber + "0" + (short)channelId + wheelChairSeat.CompanionSeatId + uniqueId, Price = transactionDetail.PricePerTicket, TransactionId = transactionDetail.TransactionId, ModifiedBy = userAltId, TicketTypeId = (TicketType)transactionDetail.TicketTypeId, SeatStatusId = SeatStatus.Sold, PrintStatusId = PrintStatus.NotPrinted, IsEnabled = true, EntryCountAllowed = 1, ChannelId = channelId, }); } seatItem.Id = seatItem.Id; seatItem.SeatStatusId = channelId == Channels.Corporate ? SeatStatus.BlockedforSponsor : SeatStatus.BlockedByCustomer; seatItem.ModifiedBy = userAltId; _matchLayoutSectionSeatRepository.Save(seatItem); _matchSeatTicketDetailRepository.Save(new MatchSeatTicketDetail { AltId = Guid.NewGuid(), EventTicketDetailId = eventTicketDetail.Id, MatchLayoutSectionSeatId = seatItem.Id, BarcodeNumber = BarcodeNumber + "0" + (short)channelId + seatItem.Id + uniqueId, Price = transactionDetail.PricePerTicket, TransactionId = transactionDetail.TransactionId, ModifiedBy = userAltId, TicketTypeId = (TicketType)transactionDetail.TicketTypeId, SeatStatusId = SeatStatus.Sold, PrintStatusId = PrintStatus.NotPrinted, IsEnabled = true, EntryCountAllowed = 1, ChannelId = channelId, }); } else { seatItem.Id = seatItem.Id; seatItem.SeatStatusId = channelId == Channels.Corporate ? SeatStatus.BlockedforSponsor : SeatStatus.BlockedByCustomer; seatItem.ModifiedBy = userAltId; _matchLayoutSectionSeatRepository.Save(seatItem); _matchSeatTicketDetailRepository.Save(new MatchSeatTicketDetail { AltId = Guid.NewGuid(), EventTicketDetailId = eventTicketDetail.Id, MatchLayoutSectionSeatId = seatItem.Id, BarcodeNumber = BarcodeNumber + "0" + (short)channelId + seatItem.Id + uniqueId, Price = transactionDetail.PricePerTicket, TransactionId = transactionDetail.TransactionId, ModifiedBy = userAltId, TicketTypeId = (TicketType)transactionDetail.TicketTypeId, SeatStatusId = SeatStatus.Sold, PrintStatusId = PrintStatus.NotPrinted, IsEnabled = true, EntryCountAllowed = 1, ChannelId = channelId, }); } seatCounter++; } } if (seatCounter == transactionDetail.TotalTickets) { checkoutCommandResult.Success = true; checkoutCommandResult.IsSeatSoldOut = false; } else { checkoutCommandResult.Success = false; checkoutCommandResult.IsSeatSoldOut = true; } } else { checkoutCommandResult.Success = false; checkoutCommandResult.IsSeatSoldOut = true; } } } else { for (int i = 1; i <= transactionDetail.TotalTickets * 1; i++) { Random rd = new Random(); BarcodeNumber = eventDetails.StartDateTime.ToString("ddMM"); int uniqueIdLength = 14; string uniqueIdChars = "abcdefghijklmnopqrstuvwxyz1234567890"; char[] uniqueIdChar = new char[uniqueIdLength]; for (int j = 0; j < uniqueIdLength; j++) { uniqueIdChar[j] = uniqueIdChars[rd.Next(0, uniqueIdChars.Length)]; } string uniqueId = new string(uniqueIdChar); _matchSeatTicketDetailRepository.Save(new MatchSeatTicketDetail { AltId = Guid.NewGuid(), EventTicketDetailId = eventTicketDetail.Id, BarcodeNumber = BarcodeNumber + "0" + (short)channelId + uniqueId, Price = transactionDetail.PricePerTicket, TransactionId = transactionDetail.TransactionId, ModifiedBy = userAltId, TicketTypeId = (TicketType)transactionDetail.TicketTypeId, SeatStatusId = SeatStatus.Sold, PrintStatusId = PrintStatus.NotPrinted, IsEnabled = true, EntryCountAllowed = 1, ChannelId = channelId, }); seatCounter++; } if (seatCounter == transactionDetail.TotalTickets) { checkoutCommandResult.Success = true; checkoutCommandResult.IsSeatSoldOut = false; } else { checkoutCommandResult.Success = false; checkoutCommandResult.IsSeatSoldOut = true; } } return(checkoutCommandResult); } catch (Exception e) { _logger.Log(Logging.Enums.LogCategory.Error, e); return(new CheckoutCommandResult { Success = false, IsSeatSoldOut = true }); } }