public bool SaveGuestUsers(GuestUserDetail guestUserDetail, TransactionDetail transactionDetail) { try { var countryData = _countryRepository.GetByAltId(guestUserDetail.PhoneCode); var newGuest = _guestDetailRepository.Save(new FIL.Contracts.DataModels.GuestDetail { TransactionDetailId = transactionDetail.Id, Age = guestUserDetail.Age.ToString(), DocumentNumber = guestUserDetail.IdentityNumber, Email = guestUserDetail.Email, FirstName = guestUserDetail.FirstName, LastName = guestUserDetail.LastName, CustomerDocumentTypeId = guestUserDetail.IdentityType == 0 ? 1 : guestUserDetail.IdentityType, PhoneNumber = guestUserDetail.PhoneNumber, PhoneCode = countryData == null ? "NA" : countryData.Phonecode.ToString(), GenderId = guestUserDetail.Gender == 0 ? Gender.Male : (Gender)guestUserDetail.Gender, IsEnabled = true, CreatedUtc = DateTime.UtcNow, UpdatedUtc = DateTime.UtcNow }); return(true); } catch (Exception e) { _logger.Log(Logging.Enums.LogCategory.Error, e); return(false); } }
public SearchVenue GetPlacePrice(SearchVenue searchVenue, List <EventDetail> eventDetails, List <EventTicketDetail> eventTicketDetails, List <TicketCategory> ticketCategories, List <EventTicketAttribute> eventTicketAttributes ) { try { var adultCategories = ticketCategories.Where((item) => { // check is adult exists return(item.Name.ToLower().Contains("adult")); }); var childCategories = ticketCategories.Where((item) => { // check if child exists return(item.Name.ToLower().Contains("child")); }); var adultPriceModel = new PriceModel(); var childPriceModel = new PriceModel(); if (adultCategories.Count() > 0) { // if adult exists then pick base price of adult adultPriceModel = filterPrices(adultCategories.ToList(), eventTicketDetails, eventTicketAttributes); } if (childCategories.Count() > 0) { // if child exists then pick base price of child childPriceModel = filterPrices(childCategories.ToList(), eventTicketDetails, eventTicketAttributes); } if (adultCategories.Count() == 0 || childCategories.Count() == 0) { // if adult or child not exists then pick the base price of place var currentPriceModel = filterEtabyPrice(eventTicketAttributes); if (childCategories.Count() == 0) { childPriceModel = currentPriceModel; } if (adultCategories.Count() == 0) { adultPriceModel = currentPriceModel; } } if (eventDetails.Count() == 0 || eventTicketDetails.Count() == 0 || eventTicketAttributes.Count() == 0) { return(searchVenue); } else { searchVenue.AdultETAId = adultPriceModel.EtaId; searchVenue.ChildETAId = childPriceModel.EtaId; searchVenue.AdultPrice = Decimal.Parse(adultPriceModel.Price.ToString("0.00")); searchVenue.ChildPrice = Decimal.Parse(childPriceModel.Price.ToString("0.00")); searchVenue.Price = searchVenue.AdultPrice + searchVenue.ChildPrice; } return(searchVenue); } catch (Exception e) { _logger.Log(Logging.Enums.LogCategory.Error, e); return(searchVenue); } }
public User GetCheckoutUser(CheckoutCommand checkoutCommand, FIL.Contracts.Models.Country country) { try { if (checkoutCommand.IsLoginCheckout) { User currentUser = _userRepository.GetByAltId(checkoutCommand.UserAltId); return(currentUser); } else { User user = checkoutCommand.GuestUser.SignUpMethodId == null?_userRepository.GetByEmailIdAndChannelId(checkoutCommand.GuestUser.Email, checkoutCommand.ChannelId) : _userRepository.GetByEmailAndChannel(checkoutCommand.GuestUser.Email, checkoutCommand.ChannelId, checkoutCommand.GuestUser.SignUpMethodId); if (user == null) { Guid userAltId = Guid.NewGuid(); user = new User { AltId = userAltId, Email = checkoutCommand.GuestUser.Email, Password = _passwordHasher.HashPassword(checkoutCommand.GuestUser.Email, checkoutCommand.GuestUser.Password), RolesId = 2, // TODO: XXX: Need a default CreatedBy = userAltId, CreatedUtc = DateTime.UtcNow, UserName = checkoutCommand.GuestUser.Email, FirstName = checkoutCommand.GuestUser.FirstName, LastName = checkoutCommand.GuestUser.LastName, PhoneCode = country.Phonecode.ToString(), PhoneNumber = checkoutCommand.GuestUser.PhoneNumber, ChannelId = ((checkoutCommand.ChannelId == Channels.Website) ? Channels.Website : Channels.Feel), SignUpMethodId = SignUpMethods.Regular, IsEnabled = true, IsRASVMailOPT = checkoutCommand.GuestUser.IsMailOpt }; user = _userRepository.Save(user); } else { user.FirstName = checkoutCommand.GuestUser.FirstName; user.LastName = checkoutCommand.GuestUser.LastName; user.PhoneCode = country.Phonecode.ToString(); user.PhoneNumber = checkoutCommand.GuestUser.PhoneNumber; user = _userRepository.Save(user); } return(user); } } catch (Exception e) { _logger.Log(Logging.Enums.LogCategory.Error, e); return(new User { }); } }
public DateTime GetLocalDateTime(DateTime utcDateTime) { try { TimeZoneInfo tzinfo = TimeZoneInfo.Local; var localDateTime = TimeZoneInfo.ConvertTimeFromUtc(utcDateTime, TimeZoneInfo.FindSystemTimeZoneById(tzinfo.StandardName)); return(localDateTime); } catch (Exception e) { _logger.Log(Logging.Enums.LogCategory.Error, e); return(utcDateTime); } }
public SearchVenue GetNearestPlace(List <SearchVenue> allPlaces, System.Device.Location.GeoCoordinate coord) { try { var nearest = allPlaces.Select(x => new System.Device.Location.GeoCoordinate(Double.Parse(x.Latitude), Double.Parse(x.Longitude))) .OrderBy(x => x.GetDistanceTo(coord)) .First(); var foundPlace = allPlaces.ToList().Find(x => Double.Parse(x.Latitude) == nearest.Latitude); return(foundPlace); } catch (Exception e) { _logger.Log(Logging.Enums.LogCategory.Error, e); return(null); } }
public FIL.Contracts.DataModels.Referral GetReferral( string referralId, long eventId, Guid modifiedBy ) { try { var Referral = _referralRepository.GetBySlug(referralId); if (Referral != null) { return Referral; } else { var referral = new Referral { Name = referralId, Code = referralId, Description = "", AltId = Guid.NewGuid(), EventId = eventId, IsEnabled = true, Slug = referralId, CreatedBy = modifiedBy, CreatedUtc = DateTime.UtcNow, ModifiedBy = modifiedBy, UpdatedBy = modifiedBy, UpdatedUtc = DateTime.UtcNow }; return _referralRepository.Save(referral); } } catch (Exception e) { _logger.Log(Logging.Enums.LogCategory.Error, e); return new Referral { }; } }
public async Task <GoogleMapApiResponse> GetLatLong(string address) { try { var googleService = await GetLatLongFromAddress(address); if (googleService != null && googleService.lat != null && googleService.lng != null) { return(googleService); } else { return(null); } } catch (Exception e) { _logger.Log(Logging.Enums.LogCategory.Error, e); return(null); } }
public DurationModel DurationTime(Parent result) { var durationValue = GetDurationTime(result); var durationTime = 0; try { if (durationValue.Split("days").Count() > 1) { durationTime = ((int.Parse(durationValue.Split("days")[0]) * 60) * 24) + (int.Parse(durationValue.Split("days")[1].Split("hours")[0]) * 60); } if (durationValue.Split("day").Count() > 1) { durationTime = ((int.Parse(durationValue.Split("day")[0]) * 60) * 24) + (int.Parse(durationValue.Split("day")[1].Split("hours")[0]) * 60); } else if (durationValue.Split("hours").Count() > 1) { durationTime = (int.Parse(durationValue.Split("hours")[0]) * 60) + int.Parse(durationValue.Split("hours")[1].Split("mins")[0]); } else if (durationValue.Split("hour").Count() > 1) { durationTime = (int.Parse(durationValue.Split("hour")[0]) * 60) + int.Parse(durationValue.Split("hour")[1].Split("mins")[0]); } else { durationTime = int.Parse(Regex.Replace(durationValue.ToString(), "[^0-9]+", string.Empty)); } return(new DurationModel { DurationTime = durationTime, DurationValue = durationValue }); } catch (Exception e) { _logger.Log(Logging.Enums.LogCategory.Error, e); return(new DurationModel { }); } }
public void SaveTransactionScheduleDetail(long TransactionDetailId, long ScheduleDetailId) { try { var scheduleDetail = _scheduleDetailRepository.Get(ScheduleDetailId); var transactionScheduleDetail = new TransactionScheduleDetail { TransactionDetailId = TransactionDetailId, ScheduleDetailId = ScheduleDetailId, StartDateTime = scheduleDetail.StartDateTime, EndDateTime = scheduleDetail.EndDateTime, IsEnabled = true, CreatedBy = Guid.NewGuid(), CreatedUtc = DateTime.UtcNow }; _transactionScheduleDetail.Save(transactionScheduleDetail); } catch (Exception e) { _logger.Log(Logging.Enums.LogCategory.Error, e); } }
public Parent GetDistance(string originAddress, string destinationAddress) { try { HttpWebRequest request = WebRequest.Create("https://maps.googleapis.com/maps/api/distancematrix/json?origins=" + originAddress + "&destinations=" + destinationAddress + "&mode=driving&language=en-EN&sensor=false&key=AIzaSyDZ4Ik7ENzLWY1tLh1ul8NxhWBdWGK6tQU") as HttpWebRequest; HttpWebResponse response = (HttpWebResponse)request.GetResponse(); WebHeaderCollection header = response.Headers; var encoding = ASCIIEncoding.ASCII; Parent result = new Parent(); using (var reader = new System.IO.StreamReader(response.GetResponseStream(), encoding)) { string responseText = reader.ReadToEnd(); result = JsonConvert.DeserializeObject <Parent>(responseText); } return(result); } catch (Exception e) { _logger.Log(Logging.Enums.LogCategory.Error, e); return(null); } }
public IPDetail SaveIp(string ipAddress) { try { IPDetail ipDetail = new IPDetail(); if (!string.IsNullOrWhiteSpace(ipAddress)) { ipDetail = _iPDetailRepository.GetByIpAddress(ipAddress); if (ipDetail == null) { IResponse <IpApiResponse> ipApiResponse = _ipApi.GetUserLocationByIp(ipAddress).Result; if (ipApiResponse.Result != null) { ipDetail = _iPDetailRepository.Save(new IPDetail { IPAddress = ipAddress, CountryCode = ipApiResponse.Result.CountryCode, CountryName = ipApiResponse.Result.Country, RegionCode = ipApiResponse.Result.Region, RegionName = ipApiResponse.Result.RegionName, City = ipApiResponse.Result.City, Zipcode = ipApiResponse.Result.ZipCode, TimeZone = ipApiResponse.Result.Timezone, Latitude = Convert.ToDecimal(ipApiResponse.Result.Latitude), Longitude = Convert.ToDecimal(ipApiResponse.Result.Longitude) }); } } } return(ipDetail); } catch (Exception e) { _logger.Log(Logging.Enums.LogCategory.Error, e); return(null); } }
protected override Task <ICommandResult> Handle(UpdateTransactionCommand command) { List <TransactionDetail> transactionDetailList = new List <TransactionDetail>(); var transaction = _transactionRepository.Get(command.TransactionId); if (transaction != null && transaction.CreatedBy != null && transaction.ChannelId != Channels.Feel) { var user = _userRepository.GetByAltId(transaction.CreatedBy); user.PhoneCode = command.DeliveryDetail[0].PhoneCode; user.PhoneNumber = command.DeliveryDetail[0].PhoneNumber; User upadateUserResult = _userRepository.Save(user); } var transactionDetails = AutoMapper.Mapper.Map <IEnumerable <FIL.Contracts.DataModels.TransactionDetail> >(_transactionDetailRepository.GetByTransactionId(command.TransactionId)); var eventTicketAttributeIds = transactionDetails.Select(s => s.EventTicketAttributeId).Distinct(); var eventTicketAttributes = AutoMapper.Mapper.Map <IEnumerable <Contracts.Models.EventTicketAttribute> >(_eventTicketAttributeRepository.GetByIds(eventTicketAttributeIds)); var ticketFeeDetails = AutoMapper.Mapper.Map <IEnumerable <Contracts.Models.TicketFeeDetail> >(_ticketFeeDetailRepository.GetByEventTicketAttributeIds(eventTicketAttributeIds)); var isItinerary = TransactionType.Regular; decimal totalConvenienceCharge = 0, smsCharges = 0, totalServiceCharge = 0, totalDeliveryCharge = 0, grossTicketAmount = 0, transactionFee = 0, transactionFeeValue = 0, transactionFeeValueTypeId = 0, creditCardSurcharge = 0, creditCardSurchargeValue = 0, creditCardSurchargeValueTypeId = 0; Channels ChannelID = transaction.ChannelId; foreach (var transactionDetail in transactionDetails) { TransactionDetail transactionDetailMapper = transactionDetail; var eventTicketAttribute = eventTicketAttributes.Where(w => w.Id == transactionDetail.EventTicketAttributeId).FirstOrDefault(); var ticketFeeDetailList = ticketFeeDetails.Where(w => w.EventTicketAttributeId == eventTicketAttribute.Id); var commandDeliveryDetail = command.DeliveryDetail.Where(w => w.EventTicketAttributeId == eventTicketAttribute.Id).FirstOrDefault(); grossTicketAmount += transactionDetail.PricePerTicket * transactionDetail.TotalTickets; } foreach (var transactionDetail in transactionDetails) { TransactionDetail transactionDetailMapper = transactionDetail; if (transactionDetail.TransactionType == TransactionType.Itinerary) { isItinerary = TransactionType.Itinerary; } var eventTicketAttribute = eventTicketAttributes.Where(w => w.Id == transactionDetail.EventTicketAttributeId).FirstOrDefault(); var ticketFeeDetailList = ticketFeeDetails.Where(w => w.EventTicketAttributeId == eventTicketAttribute.Id).OrderBy(o => o.FeeId); // Convert TicketFeeDetails into geo currency... if (ChannelID == Channels.Feel) { _geoCurrency.UpdateTicketFeeDetails(ticketFeeDetailList.ToList(), command.TargetCurrencyCode, eventTicketAttribute.CurrencyId); } var commandDeliveryDetail = command.DeliveryDetail.Where(w => w.EventTicketAttributeId == eventTicketAttribute.Id).FirstOrDefault(); decimal prevConvenienceCharges = 0; decimal DeliveryCharge = 0, ServiceCharge = 0, ConvenienceCharge = 0; decimal convenienceCharges = 0, serviceCharge = 0, pahCharge = 0, unitLevelSMSCharge = 0, unitLevelTransactionFee = 0; foreach (var ticketFeeDetail in ticketFeeDetailList) { if (ticketFeeDetail.FeeId == (int)FeeType.ConvenienceCharge) { if (ticketFeeDetail.ValueTypeId == (int)ValueTypes.Percentage) { convenienceCharges = ((ticketFeeDetail.Value * (transactionDetail.PricePerTicket * transactionDetail.TotalTickets)) / 100); prevConvenienceCharges = convenienceCharges; } else if (ticketFeeDetail.ValueTypeId == (int)ValueTypes.Flat) { convenienceCharges = ticketFeeDetail.Value * transactionDetail.TotalTickets; prevConvenienceCharges = convenienceCharges; } } if (ticketFeeDetail.FeeId == (int)FeeType.SMSCharge) { smsCharges = ticketFeeDetail.Value; } if (ticketFeeDetail.FeeId == (int)FeeType.TransactionFee) { transactionFeeValue = ticketFeeDetail.Value; transactionFeeValueTypeId = ticketFeeDetail.ValueTypeId; } if (ticketFeeDetail.FeeId == (int)FeeType.CreditCardSurcharge) { creditCardSurchargeValue = ticketFeeDetail.Value; creditCardSurchargeValueTypeId = ticketFeeDetail.ValueTypeId; } if (transactionFeeValueTypeId == (int)ValueTypes.Percentage) { transactionFee = ((transactionFeeValue * (totalConvenienceCharge + smsCharges)) / 100); } else if (transactionFeeValueTypeId == (int)ValueTypes.Flat) { transactionFee = transactionFeeValue; } if (creditCardSurchargeValueTypeId == (int)ValueTypes.Percentage) { creditCardSurcharge = ((creditCardSurchargeValue * (grossTicketAmount + transactionFee)) / 100); } else if (creditCardSurchargeValue == (int)ValueTypes.Flat) { creditCardSurcharge = creditCardSurchargeValue; } unitLevelSMSCharge = (smsCharges / transactionDetails.Count()); unitLevelTransactionFee = ((transactionFee + creditCardSurcharge) / transactionDetails.Count()); ConvenienceCharge = convenienceCharges + unitLevelSMSCharge + unitLevelTransactionFee; if (ticketFeeDetail.FeeId == (int)FeeType.ServiceCharge) { if (ticketFeeDetail.ValueTypeId == (int)ValueTypes.Percentage) { serviceCharge = ((ticketFeeDetail.Value * prevConvenienceCharges) / 100); prevConvenienceCharges = 0; } else if (ticketFeeDetail.ValueTypeId == (int)ValueTypes.Flat) { serviceCharge = ticketFeeDetail.Value * transactionDetail.TotalTickets; } } ServiceCharge = serviceCharge; if (commandDeliveryDetail.DeliveryTypeId == DeliveryTypes.PrintAtHome && ticketFeeDetail.FeeId == (int)FeeType.PrintAtHomeCharge) { pahCharge = ticketFeeDetail.Value; } DeliveryCharge = pahCharge; } transactionDetailMapper.ConvenienceCharges = ConvenienceCharge; transactionDetailMapper.ServiceCharge = ServiceCharge; transactionDetailMapper.DeliveryCharges = DeliveryCharge; totalDeliveryCharge += DeliveryCharge; totalServiceCharge += ServiceCharge; totalConvenienceCharge += ConvenienceCharge; transactionDetailList.Add(transactionDetailMapper); } if (transactionFeeValueTypeId == (int)ValueTypes.Percentage) { transactionFee = ((transactionFeeValue * (totalConvenienceCharge + smsCharges)) / 100); } else if (transactionFeeValueTypeId == (int)ValueTypes.Flat) { transactionFee = transactionFeeValue; } if (creditCardSurchargeValueTypeId == (int)ValueTypes.Percentage) { creditCardSurcharge = ((creditCardSurchargeValue * (grossTicketAmount + transactionFee)) / 100); } else if (creditCardSurchargeValue == (int)ValueTypes.Flat) { creditCardSurcharge = creditCardSurchargeValue; } if (transactionFee > 0) { transaction.ConvenienceCharges = transactionFee + creditCardSurcharge; transaction.ServiceCharge = totalServiceCharge; transaction.DeliveryCharges = totalDeliveryCharge; transaction.GrossTicketAmount = grossTicketAmount; transaction.NetTicketAmount = ((grossTicketAmount + transactionFee + creditCardSurcharge) - transaction.DiscountAmount); } else { transaction.ConvenienceCharges = totalConvenienceCharge + transactionFee + creditCardSurcharge; transaction.ServiceCharge = totalServiceCharge; transaction.DeliveryCharges = totalDeliveryCharge; transaction.GrossTicketAmount = grossTicketAmount; transaction.NetTicketAmount = ((grossTicketAmount + totalConvenienceCharge + totalServiceCharge + totalDeliveryCharge + transactionFee + creditCardSurcharge) - transaction.DiscountAmount); } if (ChannelID == Channels.Feel) { _geoCurrency.UpdateTransactionUpdates(transaction, command.TargetCurrencyCode); } FIL.Contracts.DataModels.Transaction transactionResult = _transactionRepository.Save(transaction); foreach (var transactionDetail in transactionDetailList) { TransactionDetail transactionDetailResult = _transactionDetailRepository.Save(transactionDetail); try { if (ChannelID == Channels.Feel) { var currentETA = command.EventTicketAttributeList.Where(s => s.Id == transactionDetail.EventTicketAttributeId && (transactionDetail.TicketTypeId != null ? (TicketType)transactionDetail.TicketTypeId : TicketType.Regular) == s.TicketType).FirstOrDefault(); if (currentETA != null && currentETA.GuestDetails != null) { foreach (FIL.Contracts.Commands.Transaction.GuestUserDetail currentGuestDetail in currentETA.GuestDetails) { _saveGuestUserProvider.SaveGuestUsers(currentGuestDetail, transactionDetail); } } } } catch (Exception e) { _logger.Log(Logging.Enums.LogCategory.Error, e); } } var transactionDeliveryDetails = _transactionDeliveryDetailRepository.GetByTransactionDetailIds(transactionDetails.Select(s => s.Id).Distinct()); foreach (var deliveryDetail in command.DeliveryDetail) { var transactionDeliveryDetail = transactionDeliveryDetails.Where(w => w.TransactionDetailId == transactionDetails.Where(c => c.EventTicketAttributeId == deliveryDetail.EventTicketAttributeId).Select(s => s.Id).FirstOrDefault()).FirstOrDefault(); if (transactionDeliveryDetail == null) { _transactionDeliveryDetailRepository.Save(new TransactionDeliveryDetail { TransactionDetailId = transactionDetails.Where(w => w.EventTicketAttributeId == deliveryDetail.EventTicketAttributeId).Select(s => s.Id).FirstOrDefault(), DeliveryTypeId = deliveryDetail.DeliveryTypeId, PickupBy = Convert.ToInt16(string.IsNullOrWhiteSpace(deliveryDetail.RepresentativeFirstName) ? 0 : 1), SecondaryName = $"{deliveryDetail.FirstName} {deliveryDetail.LastName}", SecondaryContact = $"{deliveryDetail.PhoneCode}-{deliveryDetail.PhoneNumber}", SecondaryEmail = deliveryDetail.DeliveryTypeId == DeliveryTypes.Courier ? deliveryDetail.Email : deliveryDetail.Email, PickUpAddress = command.PickUpAddress }); } else { transactionDeliveryDetail.SecondaryName = $"{deliveryDetail.FirstName} {deliveryDetail.LastName}"; transactionDeliveryDetail.SecondaryContact = $"{deliveryDetail.PhoneCode}-{deliveryDetail.PhoneNumber}"; transactionDeliveryDetail.SecondaryEmail = deliveryDetail.DeliveryTypeId == DeliveryTypes.Courier ? deliveryDetail.Email : deliveryDetail.Email; transactionDeliveryDetail.PickUpAddress = command.PickUpAddress; _transactionDeliveryDetailRepository.Save(transactionDeliveryDetail); } } var transactionresult = _transactionRepository.Get(command.TransactionId); UpdateTransactionCommandResult updateTransactionCommandResult = new UpdateTransactionCommandResult(); updateTransactionCommandResult.Id = transactionresult.Id; updateTransactionCommandResult.CurrencyId = transactionresult.CurrencyId; updateTransactionCommandResult.GrossTicketAmount = transactionresult.GrossTicketAmount; updateTransactionCommandResult.DeliveryCharges = transactionresult.DeliveryCharges; updateTransactionCommandResult.ConvenienceCharges = transactionresult.ConvenienceCharges; updateTransactionCommandResult.ServiceCharge = transactionresult.ServiceCharge; updateTransactionCommandResult.DiscountAmount = transactionresult.DiscountAmount; updateTransactionCommandResult.NetTicketAmount = transactionresult.NetTicketAmount; return(Task.FromResult <ICommandResult>(updateTransactionCommandResult)); }
public CheckoutCommandResult CheckTicketLimit(CheckoutCommand checkoutCommand) { try { FIL.Contracts.Models.EventDetail eventDetail = new Contracts.Models.EventDetail(); bool isPurchase = false; List <FIL.Contracts.DataModels.Transaction> transactionByData = new List <Contracts.DataModels.Transaction>(); if (checkoutCommand.GuestUser != null && checkoutCommand.GuestUser.Email != null && checkoutCommand.GuestUser.PhoneNumber != null) { transactionByData = _transactionRepository.GetSuccessFullTransactionByEmailOrPhoneNumber(checkoutCommand.GuestUser.Email, checkoutCommand.GuestUser.PhoneNumber).Where(s => s.ChannelId == Channels.Website).ToList(); } if (transactionByData.Count() > 0 && !(bool)checkoutCommand.IsASI) { IEnumerable <TransactionDetail> transactionDetails = _transactionDetailRepository.GetByTransactionIds(transactionByData.Select(s => s.Id).Distinct()); IEnumerable <Contracts.DataModels.EventTicketAttribute> eventTicketAttributeDetails = _eventTicketAttributeRepository.GetByEventTicketAttributeIds(transactionDetails.Select(s => s.EventTicketAttributeId).Distinct()); IEnumerable <Contracts.DataModels.EventTicketDetail> eventTicketDetails = _eventTicketDetailRepository.GetByEventTicketDetailIds(eventTicketAttributeDetails.Select(s => s.EventTicketDetailId)); IEnumerable <EventDetail> eventDetails = _eventDetailRepository.GetByEventDetailIds(eventTicketDetails.Select(s => s.EventDetailId).Distinct()); foreach (FIL.Contracts.DataModels.EventDetail itemEventDetail in eventDetails) { var filteredOrderEventTicketAttribute = checkoutCommand.EventTicketAttributeList.Where(s => s.EventDetailId == itemEventDetail.Id); if (filteredOrderEventTicketAttribute.Any()) { var tEventTicketDetails = eventTicketDetails.Where(w => w.EventDetailId == itemEventDetail.Id).Distinct(); var tETD = eventTicketDetails.Where(s => s.EventDetailId == itemEventDetail.Id); var tETA = eventTicketAttributeDetails.Where(w => tETD.Select(s => s.Id).Contains(w.EventTicketDetailId)); int transactionTotalTickets = transactionDetails.Where(w => tETA.Select(s => s.Id).Contains(w.EventTicketAttributeId)).Distinct().Select(s => s.TotalTickets).Sum(item => item); int commanEventTicketAttributesSum = filteredOrderEventTicketAttribute.Select(s => s.TotalTickets).Sum(item => item); int ticketLimit = 10; if (itemEventDetail.TicketLimit != null) { ticketLimit = (int)itemEventDetail.TicketLimit; } if ((commanEventTicketAttributesSum + transactionTotalTickets) > ticketLimit) { eventDetail = AutoMapper.Mapper.Map <FIL.Contracts.Models.EventDetail>(itemEventDetail); isPurchase = true; break; } } } } if (isPurchase && !checkoutCommand.ISRasv) { return(new CheckoutCommandResult { Id = 0, Success = false, EventName = eventDetail.Name, IsTransactionLimitExceed = true, IsTicketCategorySoldOut = false }); } else { return(new CheckoutCommandResult { Success = true }); } } catch (Exception e) { _logger.Log(Logging.Enums.LogCategory.Error, e); return(new CheckoutCommandResult { Success = true }); } }
protected override Task <ICommandResult> Handle(ApplyDiscountCommand command) { var transaction = _transactionRepository.Get(command.TransactionId); var transactionDetails = _transactionDetailRepository.GetByTransactionId(command.TransactionId); var ipDetail = _iPDetailRepository.Get((int)transaction.IPDetailId); decimal totalDiscountAmount = 0; decimal discountAmount = 0; foreach (TransactionDetail currentTransactionDetail in transactionDetails) { var eventTicketDetailDiscount = _eventTicketDiscountDetailRepository.GetAllByEventTicketAttributeId(currentTransactionDetail.EventTicketAttributeId).ToList(); if (eventTicketDetailDiscount.Count() > 0 && currentTransactionDetail.TicketTypeId != 4) { List <long> discountIds = new List <long>(); foreach (var currentEventTicketDetailDiscount in eventTicketDetailDiscount) { discountIds.Add(currentEventTicketDetailDiscount.DiscountId); } var discounts = _discountRepository.GetAllDiscountsByIds(discountIds).Where(w => w.IsEnabled); if (discounts.Count() > 0) { List <long> Ids = new List <long>(); foreach (var id in discounts) { Ids.Add(id.Id); } var discountPromoCode = _discountPromoCodeRepository.GetAllDiscountIds(Ids).Where(s => s.PromoCode == command.Promocode).FirstOrDefault(); if (discountPromoCode != null) { //Check for limit bool limitFlag = true; if (discountPromoCode.Limit != null && discountPromoCode.Limit != 0) { var promoCodeTransactions = _transactionRepository.GetSuccessfullTransactionByPromoCode(discountPromoCode.PromoCode).ToList(); var promocodeTransactionDetails = _transactionDetailRepository.GetByTransactionIds(promoCodeTransactions.Select(s => s.Id)).Where(w => w.EventTicketAttributeId == currentTransactionDetail.EventTicketAttributeId); if (promocodeTransactionDetails.Count() >= discountPromoCode.Limit) { limitFlag = false; } } if (limitFlag) { if (discounts.Where(s => s.Id == discountPromoCode.DiscountId).FirstOrDefault().DiscountValueTypeId == Contracts.Enums.DiscountValueType.Flat) { discountAmount = (decimal)(currentTransactionDetail.TotalTickets * discounts.Where(s => s.Id == discountPromoCode.DiscountId).FirstOrDefault().DiscountValue); if (discountAmount == (currentTransactionDetail.PricePerTicket * currentTransactionDetail.TotalTickets)) { currentTransactionDetail.ConvenienceCharges = 0; currentTransactionDetail.ServiceCharge = 0; } } else if (discounts.Where(s => s.Id == discountPromoCode.DiscountId).FirstOrDefault().DiscountValueTypeId == Contracts.Enums.DiscountValueType.Percentage) { discountAmount = (decimal)(((currentTransactionDetail.PricePerTicket * currentTransactionDetail.TotalTickets) * (decimal)discounts.Where(s => s.Id == discountPromoCode.DiscountId).FirstOrDefault().DiscountValue) / 100); if (discountAmount == (currentTransactionDetail.PricePerTicket * currentTransactionDetail.TotalTickets)) { currentTransactionDetail.ConvenienceCharges = 0; currentTransactionDetail.ServiceCharge = 0; } } totalDiscountAmount += discountAmount; if (command.Channel == Contracts.Enums.Channels.Feel) { var eventTicketAttribute = _eventTicketAttributeRepository.Get(currentTransactionDetail.EventTicketAttributeId); var eventCurreny = _currencyTypeRepository.Get(eventTicketAttribute.CurrencyId); var targetCurrency = _currencyTypeRepository.Get(transaction.CurrencyId); if (discounts.Where(s => s.Id == discountPromoCode.DiscountId).FirstOrDefault().DiscountValueTypeId == Contracts.Enums.DiscountValueType.Flat) { discountAmount = _geoCurrency.GetConvertedDiscountAmount((Decimal)discountAmount, eventCurreny.Id, targetCurrency.Code); totalDiscountAmount = _geoCurrency.GetConvertedDiscountAmount((Decimal)totalDiscountAmount, eventCurreny.Id, targetCurrency.Code); } } currentTransactionDetail.DiscountAmount = discountAmount; _transactionDetailRepository.Save(currentTransactionDetail); } } } } } ApplyDiscountCommandResult applyDiscountCommandResult = new ApplyDiscountCommandResult(); if (totalDiscountAmount == 0) { applyDiscountCommandResult.Id = 0; } else { transaction.DiscountAmount = totalDiscountAmount; transaction.NetTicketAmount = transaction.NetTicketAmount - totalDiscountAmount; if (transaction.GrossTicketAmount == totalDiscountAmount) { transaction.NetTicketAmount = 0; transaction.ConvenienceCharges = 0; transaction.ServiceCharge = 0; } transaction.DiscountCode = command.Promocode; _transactionRepository.Save(transaction); applyDiscountCommandResult.Id = transaction.Id; applyDiscountCommandResult.CurrencyId = transaction.CurrencyId; applyDiscountCommandResult.GrossTicketAmount = transaction.GrossTicketAmount; applyDiscountCommandResult.DeliveryCharges = transaction.DeliveryCharges; applyDiscountCommandResult.ConvenienceCharges = transaction.ConvenienceCharges; applyDiscountCommandResult.ServiceCharge = transaction.ServiceCharge; applyDiscountCommandResult.DiscountAmount = transaction.DiscountAmount; applyDiscountCommandResult.NetTicketAmount = transaction.NetTicketAmount; } try { if (transaction.NetTicketAmount <= 0) { var liveOnlineTransactionDetailModel = _transactionRepository.GetFeelOnlineDetails(transaction.Id).FirstOrDefault(); if (liveOnlineTransactionDetailModel != null) { //check if subcategory is LiveOnline var eventCategoryModel = _eventCategoryRepository.Get(Convert.ToInt16(liveOnlineTransactionDetailModel.EventcategoryId)); var eventModel = _eventRepository.Get(liveOnlineTransactionDetailModel.EventId); if ((eventCategoryModel != null && eventModel.MasterEventTypeId == Contracts.Enums.MasterEventType.Online && command.Channel == Contracts.Enums.Channels.Feel) || eventModel.EventCategoryId == 119) { _zoomMeetingProvider.CreateMeeting(transaction, true); applyDiscountCommandResult.IsPaymentBypass = true; } } } } catch (Exception e) { _logger.Log(Logging.Enums.LogCategory.Error, e); } return(Task.FromResult <ICommandResult>(applyDiscountCommandResult)); }
public SearchVenueQueryResult Handle(SearchVenueQuery query) { List <FIL.Contracts.DataModels.SearchVenue> VenueResult = new List <Contracts.DataModels.SearchVenue>(); try { var citiesArray = query.CityName != null?query.CityName.Split(",") : null; var eventCategoriesRepositoryData = _eventCategoryRepository.GetAll().Where(s => s.IsFeel == true); var categories = query.Categories != null?query.Categories.Split(",") : null; List <long> categoryList = new List <long>(); if (categories != null && categories.Count() > 0 && query.PlaceId == 0) { foreach (var item in categories) { try { var categoryInfo = eventCategoriesRepositoryData.FirstOrDefault(x => x.DisplayName == item).Id; categoryList.Add(categoryInfo); } catch (Exception ex) { _logger.Log(Logging.Enums.LogCategory.Error, ex); } } } else if (categories != null && categories.Count() == 0 && query.PlaceId == 0) { var categoryInfo = eventCategoriesRepositoryData.FirstOrDefault(x => x.DisplayName == query.Categories).Id; categoryList.Add(categoryInfo); } var cityLists = query.CityIds != null?_cityRepository.GetByCityIds(query.CityIds) : null; var itineraryPlaces = query.PlaceId == 0 ? _eventRepository.GetAllItineraryPlaces(cityLists.Select(s => s.Id).ToList(), categoryList).GroupBy(x => x.Id, (key, group) => group.First()) : _eventRepository.GetItinerarySearchPlaces(query.PlaceId).GroupBy(x => x.Id, (key, group) => group.First()); var placeWeekOpenDayList = _placeWeekOpenDaysRepository.GetByEventIds(itineraryPlaces.Select(s => (long)s.Id).Distinct().ToList()); var dayTimeMappingLists = _dayTimeMappingsRepository.GetAllByPlaceWeekOpenDays(placeWeekOpenDayList.Select(s => (long)s.Id).Distinct().ToList()); var placeHolidayDatesRepositoryLists = _placeHolidayDatesRepository.GetAllByEventIds(itineraryPlaces.Select(s => (long)s.Id).Distinct().ToList()); var placeVisitDurationRepositoryLists = _PlaceVisitDurationRepository.GetByEventIds(itineraryPlaces.Select(s => (long)s.Id).Distinct().ToList()); var eventDetails = _eventDetailRepository.GetByEventIds(itineraryPlaces.Select(s => (long)s.Id).Distinct().ToList()).Where(s => s.IsEnabled == true); var eventTicketDetails = _eventTicketDetailRepository.GetByEventDetailIds(eventDetails.Select(s => (long)s.Id).Distinct().ToList()).Where(s => s.IsEnabled == true); var eventTicketAttributes = _eventTicketAttributeRepository.GetByEventTicketDetailIds(eventTicketDetails.Select(s => (long)s.Id).Distinct().ToList()).Where(s => s.IsEnabled == true); var ticketCategories = _ticketCategoryRepository.GetByTicketCategoryIds(eventTicketDetails.Select(s => (long)s.TicketCategoryId).Distinct().ToList()); var Days = _daysRepository.GetAll(); foreach (var currentPlace in itineraryPlaces) { var PlaceVisitDuration = placeVisitDurationRepositoryLists.FirstOrDefault(x => x.EventId == currentPlace.Id); var placeWeekOpenDays = placeWeekOpenDayList.Where(x => x.EventId == currentPlace.Id); var dayTimeMappings = dayTimeMappingLists.Where(s => placeWeekOpenDays.Any(p => p.Id == s.PlaceWeekOpenDayId)); SearchVenue searchVenue = new SearchVenue(); searchVenue.CategoryName = currentPlace.Category; searchVenue.EventId = currentPlace.Id; searchVenue.CityId = currentPlace.CityId; searchVenue.EventSource = currentPlace.EventSource; searchVenue.CityName = currentPlace.CityName; searchVenue.CountryName = currentPlace.CountryName; searchVenue.Currency = currentPlace.Currency; searchVenue.EventName = currentPlace.Name; searchVenue.EventAltId = currentPlace.AltId; searchVenue.EventSlug = currentPlace.Slug; searchVenue.Address = (currentPlace.AddressLineOne == null ? string.Empty : currentPlace.AddressLineOne) + "," + (currentPlace.AddressLineTwo == null ? string.Empty : currentPlace.AddressLineTwo); searchVenue.Id = currentPlace.Id; searchVenue.PlaceWeekOpenDays = placeWeekOpenDays.ToList(); searchVenue.DayTimeMappings = dayTimeMappings.ToList(); searchVenue.PlaceHolidaysList = placeHolidayDatesRepositoryLists.Where(x => x.EventId == currentPlace.Id).ToList(); searchVenue.EventDescription = currentPlace.EventDescription; searchVenue.EventDetails = eventDetails.Where(x => x.EventId == currentPlace.Id).ToList(); searchVenue.EventTicketDetails = eventTicketDetails.Where(x => searchVenue.EventDetails.Any(s => s.Id == x.EventDetailId)).ToList(); searchVenue.EventTicketAttributes = eventTicketAttributes.Where(x => searchVenue.EventTicketDetails.Any(s => s.Id == x.EventTicketDetailId)).ToList(); searchVenue.ticketCategories = ticketCategories.Where(x => searchVenue.EventTicketDetails.Any(s => s.TicketCategoryId == x.Id)).ToList(); if (currentPlace.Latitude != null) { var latArr = currentPlace.Latitude.Split("E"); var longArr = currentPlace.Longitude.Split("E"); searchVenue.Latitude = latArr[0]; searchVenue.Longitude = longArr[0]; } else { searchVenue.Latitude = null; searchVenue.Longitude = null; } VenueResult.Add(searchVenue); } return(new SearchVenueQueryResult() { Venues = VenueResult.Distinct().ToList(), Days = Days.ToList() }); } catch (Exception e) { return(new SearchVenueQueryResult() { Venues = VenueResult.Distinct().ToList() }); } }
public CheckoutCommandResult SaveTransaction(CheckoutCommand checkoutCommand, IEnumerable <Contracts.Models.EventTicketAttribute> eventTicketAttributeModel, FIL.Contracts.DataModels.User user) { try { var isPaymentBypass = false; var StripeAccount = FIL.Contracts.Enums.StripeAccount.None; List <TransactionDetail> transactionDetailList = new List <TransactionDetail>(); List <FIL.Contracts.Models.CartItemModel> lstEventDetailId = new List <FIL.Contracts.Models.CartItemModel>(); FIL.Contracts.DataModels.Transaction transaction = new FIL.Contracts.DataModels.Transaction(); decimal grossTicketAmount = 0; long eventDetailId = 0, ticketCategoryId = 0; decimal netTicketAmount = 0; decimal totalDiscountAmount = 0; if (checkoutCommand.IsASI == null) { checkoutCommand.IsASI = false; } var allETD = _eventTicketDetailRepository.GetByEventTicketDetailsIds(eventTicketAttributeModel.Select(s => s.EventTicketDetailId).Distinct()).Distinct(); var allED = _eventDetailRepository.GetByIds(allETD.Select(s => s.EventDetailId).Distinct()).Distinct(); foreach (Contracts.Commands.Transaction.EventTicketAttribute ticketAttributes in checkoutCommand.EventTicketAttributeList) { var currentTA = ticketAttributes; var transactionType = checkoutCommand.IsQrTransaction ? TransactionType.QRCode : checkoutCommand.TransactionType == TransactionType.Itinerary ? TransactionType.Itinerary : ticketAttributes.TicketType == TicketType.SeasonPackage ? TransactionType.Season : ticketAttributes.TransactionType == TransactionType.LiveOnline ? TransactionType.LiveOnline : ticketAttributes.TransactionType == TransactionType.AddOns ? TransactionType.AddOns : TransactionType.Regular; decimal discountAmount = 0, donationAmount = 0; if (ticketAttributes.DiscountedPrice > 0) { discountAmount = ticketAttributes.DiscountedPrice; } if (ticketAttributes.DonationAmount != null && ticketAttributes.DonationAmount > 0) { donationAmount = (decimal)ticketAttributes.DonationAmount; } Contracts.Models.EventTicketAttribute checkoutCommandEventTicketAttribute = eventTicketAttributeModel.Where(w => w.Id == ticketAttributes.Id).FirstOrDefault(); decimal pricePerTicket = checkoutCommandEventTicketAttribute.Price; EventTicketDetail eventTicketDetail = allETD.Where(s => s.Id == checkoutCommandEventTicketAttribute.EventTicketDetailId && s.IsEnabled).FirstOrDefault(); if (eventTicketDetail != null) { EventDetail eventDetail = allED.Where(s => s.Id == eventTicketDetail.EventDetailId && s.IsEnabled).FirstOrDefault(); if (eventDetail != null) { var visitStartDate = ticketAttributes.VisitDate; var visitEndDate = ticketAttributes.VisitDate; if (checkoutCommand.TransactionType == TransactionType.Itinerary) { visitStartDate = ticketAttributes.VisitStartTime.Split(":").Count() > 1 ? new DateTime(visitStartDate.Year, visitStartDate.Month, visitStartDate.Day, Convert.ToInt32(ticketAttributes.VisitStartTime.Split(":")[0]), Convert.ToInt32(ticketAttributes.VisitStartTime.Split(":")[1]), 0) : visitStartDate; visitEndDate = ticketAttributes.VisitEndTime.Split(":").Count() > 1 ? new DateTime(visitEndDate.Year, visitEndDate.Month, visitEndDate.Day, Convert.ToInt32(ticketAttributes.VisitEndTime.Split(":")[0]), Convert.ToInt32(ticketAttributes.VisitEndTime.Split(":")[1]), 0) : visitEndDate; } visitStartDate = visitStartDate < new DateTime(1753, 1, 1) ? DateTime.UtcNow : visitStartDate; visitEndDate = visitEndDate < new DateTime(1753, 1, 1) ? DateTime.UtcNow : visitEndDate; if ((bool)checkoutCommand.IsASI) { pricePerTicket = ticketAttributes.TicketType == TicketType.Child ? 0 : checkoutCommandEventTicketAttribute.Price; } if (ticketAttributes.OverridedAmount != null && checkoutCommand.IsBSPUpgrade && ticketAttributes.OverridedAmount != 0) { pricePerTicket = (decimal)ticketAttributes.OverridedAmount; } if (ticketAttributes.TicketType == TicketType.SeasonPackage) { eventDetailId = eventTicketDetail.EventDetailId; lstEventDetailId.Add(new FIL.Contracts.Models.CartItemModel { EventDetailId = eventDetailId }); ticketCategoryId = eventTicketDetail.TicketCategoryId; IEnumerable <EventDetail> seasonEventDetails = _eventDetailRepository.GetSeasonEventDetails(eventDetail.EventId, eventDetail.VenueId).Where(s => s.IsEnabled == true); IEnumerable <EventTicketDetail> seasonEventTicketDetails = _eventTicketDetailRepository.GetByEventDetailIds(seasonEventDetails.Select(s => s.Id).Distinct()).Where(w => w.TicketCategoryId == eventTicketDetail.TicketCategoryId); List <Contracts.DataModels.EventTicketAttribute> seasonEventTicketAttributes = _eventTicketAttributeRepository.GetByEventTicketDetailIds(seasonEventTicketDetails.Select(s => s.Id).Distinct()).Where(W => W.IsEnabled == true && W.SeasonPackage == true).ToList(); var seasonPrice = seasonEventTicketAttributes[0].SeasonPackagePrice; pricePerTicket = seasonPrice / seasonEventTicketAttributes.Count; } else { eventDetailId = eventDetail.Id; lstEventDetailId.Add(new FIL.Contracts.Models.CartItemModel { EventDetailId = eventTicketDetail.EventDetailId }); ticketCategoryId = eventTicketDetail.TicketCategoryId; } if (Convert.ToInt16(ticketAttributes.TotalTickets) <= checkoutCommandEventTicketAttribute.RemainingTicketForSale) { TransactionDetail transactionDetail = new TransactionDetail(); transactionDetail.EventTicketAttributeId = ticketAttributes.Id; transactionDetail.TotalTickets = Convert.ToInt16(ticketAttributes.TotalTickets); transactionDetail.PricePerTicket = checkoutCommand.TransactionType == TransactionType.Itinerary ? ticketAttributes.Price : pricePerTicket; transactionDetail.DiscountAmount = discountAmount; transactionDetail.VisitDate = visitStartDate; transactionDetail.VisitEndDate = visitEndDate; transactionDetail.TransactionType = transactionType; transactionDetail.TicketTypeId = checkoutCommand.TransactionType == TransactionType.Itinerary ? (short)(ticketAttributes.IsAdult ? 10 : 2) : (short)(TicketType)ticketAttributes.TicketType; if (checkoutCommand.ReferralId != null) { var referral = _referralProvider.GetReferral(checkoutCommand.ReferralId, eventDetail.EventId, checkoutCommand.ModifiedBy); if (referral != null && referral.Id != 0) { transactionDetail.ReferralId = referral.Id; } } if (checkoutCommand.ChannelId == Channels.Feel && checkoutCommand.TransactionType != TransactionType.Itinerary) { _geoCurrency.UpdateTransactionUpdates(transactionDetail, checkoutCommand.TargetCurrencyCode, checkoutCommandEventTicketAttribute.CurrencyId); } if (donationAmount > 0) // Donation doesn't need the local currency as the amount itself in the local currency { transactionDetail.PricePerTicket = transactionDetail.PricePerTicket + donationAmount; } netTicketAmount += ((ticketAttributes.TotalTickets * (decimal)transactionDetail.PricePerTicket) - ((decimal)transactionDetail.DiscountAmount)); grossTicketAmount += ((ticketAttributes.TotalTickets * transactionDetail.PricePerTicket)); totalDiscountAmount += (decimal)transactionDetail.DiscountAmount; transactionDetail.MembershipId = ticketAttributes.MembershipId; transactionDetailList.Add(transactionDetail); } else { EventDetail eventDetails = _eventDetailRepository.Get(eventDetailId); Contracts.DataModels.TicketCategory ticketCategory = _ticketCategoryRepository.Get((int)ticketCategoryId); return(new CheckoutCommandResult { Id = 0, Success = false, EventName = eventDetails.Name, TicketCategoryName = ticketAttributes.TicketType == TicketType.SeasonPackage ? "Season - " + ticketCategory.Name : ticketCategory.Name, IsTransactionLimitExceed = false, IsTicketCategorySoldOut = true }); } } else { EventDetail eventDetails = _eventDetailRepository.Get(eventDetailId); Contracts.DataModels.TicketCategory ticketCategory = _ticketCategoryRepository.Get((int)ticketCategoryId); return(new CheckoutCommandResult { Id = 0, Success = false, EventName = eventDetails.Name, TicketCategoryName = ticketAttributes.TicketType == TicketType.SeasonPackage ? "Season - " + ticketCategory.Name : ticketCategory.Name, IsTransactionLimitExceed = false, IsTicketCategorySoldOut = true }); } } else { EventDetail eventDetails = _eventDetailRepository.Get(eventDetailId); Contracts.DataModels.TicketCategory ticketCategory = _ticketCategoryRepository.Get((int)ticketCategoryId); return(new CheckoutCommandResult { Id = 0, Success = false, EventName = eventDetails.Name, TicketCategoryName = ticketAttributes.TicketType == TicketType.SeasonPackage ? "Season - " + ticketCategory.Name : ticketCategory.Name, IsTransactionLimitExceed = false, IsTicketCategorySoldOut = true }); } } var intialCurrencyId = eventTicketAttributeModel.Select(s => s.CurrencyId).FirstOrDefault(); var currencyId = eventTicketAttributeModel.Select(s => s.CurrencyId).FirstOrDefault(); if (checkoutCommand.ChannelId == Channels.Feel) // Update the currencyId { if (checkoutCommand.TransactionType == TransactionType.Itinerary) { currencyId = _geoCurrency.GetCurrencyID(checkoutCommand.TransactionCurrency).Id; } else { currencyId = _geoCurrency.GetCurrencyID(checkoutCommand.TargetCurrencyCode).Id; } } /*if (checkoutCommand.ISRasv) // NAB test bed * { * var splitprice = netTicketAmount.ToString("0.00").Split("."); * var price = splitprice[0] + ".00"; * netTicketAmount = Convert.ToDecimal(netTicketAmount); * }*/ transaction.ChannelId = checkoutCommand.ChannelId; transaction.CurrencyId = currencyId; transaction.TotalTickets = Convert.ToInt16(checkoutCommand.EventTicketAttributeList.Sum(s => s.TotalTickets)); transaction.GrossTicketAmount = grossTicketAmount; transaction.NetTicketAmount = netTicketAmount; transaction.DiscountAmount = totalDiscountAmount; transaction.TransactionStatusId = TransactionStatus.UnderPayment; transaction.FirstName = user.FirstName; transaction.LastName = user.LastName; transaction.PhoneCode = user.PhoneCode; transaction.PhoneNumber = user.Email == "*****@*****.**" ? checkoutCommand.GuestUser.PhoneNumber : user.PhoneNumber; transaction.EmailId = user.Email == "*****@*****.**" ? checkoutCommand.GuestUser.PhoneNumber : user.Email; transaction.CountryName = !string.IsNullOrWhiteSpace(user.PhoneCode) ? _countryRepository.GetByPhoneCode(user.PhoneCode).Name : "India"; transaction.CreatedBy = user.AltId; transaction.CreatedUtc = DateTime.UtcNow; try { var ipDetail = _saveIPProvider.SaveIp(checkoutCommand.Ip); if (ipDetail != null && ipDetail.Id > 0) { transaction.IPDetailId = ipDetail.Id; } } catch (Exception e) { _logger.Log(Logging.Enums.LogCategory.Error, e); transaction.IPDetailId = 1; } transaction.ModifiedBy = user.AltId; transaction.AltId = Guid.NewGuid(); if (transaction.CurrencyId != 7) { transaction.OTP = checkoutCommand.OTPCode; } if (checkoutCommand.DonationAmount != null && checkoutCommand.DonationAmount != 0) { transaction.DonationAmount = checkoutCommand.DonationAmount; } FIL.Contracts.DataModels.Transaction transactionResult = _transactionRepository.Save(transaction); foreach (TransactionDetail transactionDetail in transactionDetailList) { transactionDetail.TransactionId = transactionResult.Id; var currentTransactionDetail = _transactionDetailRepository.Save(transactionDetail); FIL.Contracts.DataModels.EventTicketAttribute eventTicketAttribute = AutoMapper.Mapper.Map <FIL.Contracts.DataModels.EventTicketAttribute>(_eventTicketAttributeRepository.Get(transactionDetail.EventTicketAttributeId)); FIL.Contracts.DataModels.EventTicketDetail eventTicketDetail = AutoMapper.Mapper.Map <FIL.Contracts.DataModels.EventTicketDetail>(_eventTicketDetailRepository.Get(eventTicketAttribute.EventTicketDetailId)); if (Convert.ToInt16(transactionDetail.TotalTickets) <= eventTicketAttribute.RemainingTicketForSale) { eventTicketAttribute.RemainingTicketForSale -= transactionDetail.TotalTickets; _eventTicketAttributeRepository.Save(eventTicketAttribute); if (checkoutCommand.ChannelId == Channels.Website) { if (eventTicketDetail.InventoryTypeId == InventoryType.Seated || eventTicketDetail.InventoryTypeId == InventoryType.SeatedWithSeatSelection || eventTicketDetail.InventoryTypeId == InventoryType.NoneSeated) { List <Contracts.Models.TMS.SeatDetail> seatDetail = new List <Contracts.Models.TMS.SeatDetail>(); if (checkoutCommand.SeatDetails != null) { seatDetail = AutoMapper.Mapper.Map <List <Contracts.Models.TMS.SeatDetail> >(checkoutCommand.SeatDetails.Where(w => w.EventTicketDetailId == eventTicketDetail.Id)); } else { seatDetail = null; } var seatBlock = _seatBlockingProvider.BlockSeat(seatDetail, transactionDetail, eventTicketAttribute, eventTicketDetail, user.AltId, Channels.Website); if (!seatBlock.Success && seatBlock.IsSeatSoldOut) { return(new CheckoutCommandResult { Success = false, Id = 0, TransactionAltId = Guid.NewGuid(), IsTransactionLimitExceed = false, IsTicketCategorySoldOut = false, IsSeatSoldOut = true }); } } } } else { EventDetail eventDetails = _eventDetailRepository.Get(eventDetailId); Contracts.DataModels.TicketCategory ticketCategory = _ticketCategoryRepository.Get((int)ticketCategoryId); return(new CheckoutCommandResult { Id = 0, Success = false, EventName = eventDetails.Name, TicketCategoryName = transactionDetail.TicketTypeId == (short)TicketType.SeasonPackage ? "Season - " + ticketCategory.Name : ticketCategory.Name, IsTransactionLimitExceed = false, IsTicketCategorySoldOut = true }); } /* Save Transaction Schedule Detail */ var currentTicket = checkoutCommand.EventTicketAttributeList.Where(s => s.Id == currentTransactionDetail.EventTicketAttributeId).FirstOrDefault(); if (currentTicket.ScheduleDetailId != null && currentTicket.ScheduleDetailId != 0) { _saveTransactionScheduleDetailProvider.SaveTransactionScheduleDetail(currentTransactionDetail.Id, (long)currentTicket.ScheduleDetailId); } } try { if (checkoutCommand.ChannelId == Channels.Feel || checkoutCommand.ChannelId == Channels.Website) // If Live Online Transaction with 0.00 price { var @event = _eventRepository.Get(allED.FirstOrDefault().EventId); if (@event != null) { if (@event.MasterEventTypeId == Contracts.Enums.MasterEventType.Online && transaction.NetTicketAmount == 0) { _zoomMeetingProvider.CreateMeeting(transaction, true); isPaymentBypass = true; } else if (@event.MasterEventTypeId == Contracts.Enums.MasterEventType.Online) { StripeAccount = _eventStripeConnectAccountProvider.GetEventStripeAccount(allED.FirstOrDefault().EventId, checkoutCommand.ChannelId); } } } } catch (Exception e) { _logger.Log(Logging.Enums.LogCategory.Error, e); } try { /*Check if referred transactionId already upgraded to BSP or successfull transaction, if yes then don't allow another transaction using same referral/ transaction id*/ if (checkoutCommand.IsBSPUpgrade && checkoutCommand.ReferralId != null) { var transactions = _transactionRepository.GetAllSuccessfulTransactionByReferralId(checkoutCommand.ReferralId); if (transactions.Any()) { return(new CheckoutCommandResult { Id = 0, Success = false, IsBSPUpgraded = true }); } } } catch (Exception e) { _logger.Log(Logging.Enums.LogCategory.Error, e); } return(new CheckoutCommandResult { Id = transactionResult.Id, CartBookingModel = lstEventDetailId, Transaction = transactionResult, IsPaymentByPass = isPaymentBypass, Success = true, StripeAccount = StripeAccount, }); } catch (Exception e) { _logger.Log(Logging.Enums.LogCategory.Error, e); return(new CheckoutCommandResult { }); } }