public ZipcodeSearchQueryResult Handle(ZipcodeSearchQuery query) { var zipcodeResult = _zipRepository.GetByZipcode(query.Zipcode); return(new ZipcodeSearchQueryResult { IsExisting = zipcodeResult != null, }); }
protected override async Task Handle(SaveAddressCommand command) { var user = _userRepository.GetByAltId(command.UserAltId); var zipcode = _zipcodeRepository.GetByZipcode(command.Zipcode.ToString()); if (zipcode == null) { var zipCode = new Zipcode { AltId = Guid.NewGuid(), Postalcode = command.Zipcode.ToString(), IsEnabled = true }; _zipcodeRepository.Save(zipCode); zipcode = _zipcodeRepository.GetByZipcode(command.Zipcode.ToString()); } if (user != null && zipcode != null) { var addressDetail = new UserAddressDetail { UserId = user.Id, AltId = Guid.NewGuid(), FirstName = command.FirstName, LastName = command.LastName, PhoneCode = command.PhoneCode, PhoneNumber = command.PhoneNumber, AddressLine1 = command.AddressLine1, Zipcode = zipcode.Id, AddressTypeId = command.AddressTypeId, ModifiedBy = command.ModifiedBy, IsEnabled = true, CityId = null }; _userAddressDetailRepository.Save(addressDetail); } }
protected override async Task <ICommandResult> Handle(PaymentCommand query) { var transaction = _transactionRepository.Get(query.TransactionId); var currency = _currencyTypeRepository.Get(transaction.CurrencyId); User user = _userRepository.GetByEmail(transaction.EmailId); UserCardDetail userCardDetail = _userCardDetailRepository.GetByUserCardNumber(query.PaymentCard.CardNumber, user.Id); if (userCardDetail == null) { UserCardDetail obj = new UserCardDetail { UserId = user.Id, AltId = new Guid(), NameOnCard = query.PaymentCard.NameOnCard ?? string.Empty, CardNumber = query.PaymentCard.CardNumber ?? string.Empty, ExpiryMonth = query.PaymentCard.ExpiryMonth, ExpiryYear = query.PaymentCard.ExpiryYear, CardTypeId = query.PaymentCard.CardType }; userCardDetail = _userCardDetailRepository.Save(obj); } try { if (query.BillingAddress != null) { if (query.BillingAddress.Zipcode == null) { query.BillingAddress.Zipcode = "110016"; } var zipcode = _zipcodeRepository.GetByZipcode(query.BillingAddress.Zipcode.ToString()); if (zipcode == null) { var city = _cityRepository.GetByName(query.BillingAddress.City); var zipCode = new Zipcode { AltId = Guid.NewGuid(), Postalcode = query.BillingAddress.Zipcode.ToString(), CityId = city != null ? city.Id : 0, IsEnabled = true }; _zipcodeRepository.Save(zipCode); zipcode = _zipcodeRepository.GetByZipcode(query.BillingAddress.Zipcode.ToString()); } if (user != null && zipcode != null) { var addressDetail = new UserAddressDetail { UserId = user.Id, AltId = Guid.NewGuid(), FirstName = user.FirstName, LastName = user.LastName, PhoneCode = user.PhoneCode, PhoneNumber = user.PhoneNumber, AddressLine1 = query.BillingAddress.Address, Zipcode = zipcode.Id, AddressTypeId = AddressTypes.Billing, IsEnabled = true }; _userAddressDetailRepository.Save(addressDetail); } } } catch (Exception ex) { _logger.Log(Logging.Enums.LogCategory.Error, ex); } if (query.PaymentGateway != null) { List <FIL.Contracts.DataModels.TransactionDetail> transactionDetails = _transactionDetailRepository.GetByTransactionId(transaction.Id).ToList(); if (transactionDetails.Any()) { List <FIL.Contracts.DataModels.TransactionSeatDetail> transactionSeatDetails = _transactionSeatDetailRepository.GetByTransactionDetailIds(transactionDetails.Select(s => s.Id)).ToList(); if (transactionSeatDetails != null) { var matchSeatTicketDetail = _matchSeatTicketDetailRepository.GetByMatchSeatTicketDetailIds(transactionSeatDetails.Select(s => s.MatchSeatTicketDetailId)).ToList(); if (matchSeatTicketDetail != null && matchSeatTicketDetail.Any()) { return(new PaymentCommandResult { TransactionAltId = transaction.AltId, PaymentResponse = new PaymentResponse { Success = false, PaymentGatewayError = PaymentGatewayError.Unknown } }); } } } } if (query.PaymentGateway == PaymentGateway.Stripe) { bool isIntentConfirm = false; if (query.PaymentCard.NameOnCard != null) { isIntentConfirm = query.PaymentCard.NameOnCard.Equals("intent", StringComparison.InvariantCultureIgnoreCase); } var paymentResponse = await _stripeCharger.Charge(new StripeCharge { TransactionId = transaction.Id, Currency = currency.Code, Amount = Convert.ToDecimal(transaction.NetTicketAmount), UserCardDetailId = userCardDetail.Id, Token = query.Token, ChannelId = query.ChannelId, IsIntentConfirm = isIntentConfirm }); return(new PaymentCommandResult { TransactionAltId = transaction.AltId, PaymentResponse = paymentResponse }); } if (query.PaymentGateway != null && query.PaymentGateway == PaymentGateway.NabTransact) { var paymentHtmlPostResponse = await _nabTransactCharger.Charge(new NabTransactCharge { TransactionId = transaction.Id, Currency = currency.Code, Amount = Convert.ToDecimal(transaction.NetTicketAmount), UserCardDetailId = userCardDetail.Id, PaymentCard = new FIL.Contracts.Models.PaymentChargers.PaymentCard { CardNumber = query.PaymentCard.CardNumber, NameOnCard = query.PaymentCard.NameOnCard, Cvv = query.PaymentCard.Cvv, ExpiryMonth = query.PaymentCard.ExpiryMonth, ExpiryYear = query.PaymentCard.ExpiryYear, CardType = query.PaymentCard.CardType }, BillingAddress = new FIL.Contracts.Models.PaymentChargers.BillingAddress { FirstName = user.FirstName, LastName = user.LastName, PhoneCode = user.PhoneCode, PhoneNumber = user.PhoneNumber, Email = user.Email, AddressLine1 = !string.IsNullOrWhiteSpace(query.BillingAddress.Address) ? query.BillingAddress.Address : "Zoonga", Zipcode = !string.IsNullOrWhiteSpace(query.BillingAddress.Zipcode.ToString()) ? query.BillingAddress.Zipcode.ToString() : "3032", City = !string.IsNullOrWhiteSpace(query.BillingAddress.City) ? query.BillingAddress.City : "Delhi", State = !string.IsNullOrWhiteSpace(query.BillingAddress.State) ? query.BillingAddress.State : "Delhi", Country = !string.IsNullOrWhiteSpace(query.BillingAddress.Country) ? query.BillingAddress.Country : "India" }, PaymentOption = PaymentOptions.CreditCard, User = new FIL.Contracts.Models.User { Email = user.Email }, //IPAddress = ipDetail.IPAddress }); return(new PaymentCommandResult { TransactionAltId = transaction.AltId, PaymentHtmlPostResponse = paymentHtmlPostResponse }); } if (PaymentOptions.CreditCard == query.PaymentOption || PaymentOptions.DebitCard == query.PaymentOption) { IHdfcEnrollmentResponse hdfcEnrollmentResponse = _hdfcChargerResolver.HdfcEnrollmentVerification(new HdfcCharge { TransactionId = transaction.Id, Currency = currency.Code, Amount = Convert.ToDecimal(transaction.NetTicketAmount), UserCardDetailId = userCardDetail.Id, PaymentCard = new FIL.Contracts.Models.PaymentChargers.PaymentCard { CardNumber = query.PaymentCard.CardNumber, NameOnCard = query.PaymentCard.NameOnCard, Cvv = query.PaymentCard.Cvv, ExpiryMonth = query.PaymentCard.ExpiryMonth, ExpiryYear = query.PaymentCard.ExpiryYear, CardType = query.PaymentCard.CardType } }); if (hdfcEnrollmentResponse.PaymentGatewayError == PaymentGatewayError.None) { if (hdfcEnrollmentResponse.HdfcEnrolledCharge.Result.ToString() == "ENROLLED") { var paymentHtmlPostResponse = await _hdfcPaymentHtmlPostCharger.Charge(hdfcEnrollmentResponse.HdfcEnrolledCharge); return(new PaymentCommandResult { TransactionAltId = transaction.AltId, PaymentHtmlPostResponse = paymentHtmlPostResponse }); } if (hdfcEnrollmentResponse.HdfcEnrolledCharge.Result.ToString() == "NOT ENROLLED") { var paymentResponse = await _hdfcCharger.Charge(new HdfcCharge { TransactionId = transaction.Id, Currency = currency.Code, Amount = Convert.ToDecimal(transaction.NetTicketAmount), UserCardDetailId = userCardDetail.Id, PaymentCard = new FIL.Contracts.Models.PaymentChargers.PaymentCard { CardNumber = query.PaymentCard.CardNumber, NameOnCard = query.PaymentCard.NameOnCard, Cvv = query.PaymentCard.Cvv, ExpiryMonth = query.PaymentCard.ExpiryMonth, ExpiryYear = query.PaymentCard.ExpiryYear, CardType = query.PaymentCard.CardType } }); return(new PaymentCommandResult { TransactionAltId = transaction.AltId, PaymentResponse = paymentResponse }); } } return(new PaymentCommandResult { TransactionAltId = transaction.AltId, PaymentResponse = new PaymentResponse { Success = false, PaymentGatewayError = hdfcEnrollmentResponse.PaymentGatewayError } }); } if (PaymentOptions.NetBanking == query.PaymentOption || PaymentOptions.CashCard == query.PaymentOption) { var paymentHtmlPostResponse = await _ccavenuePaymentHtmlPostCharger.Charge(new CcavenueCharge { TransactionId = transaction.Id, Currency = currency.Code, Amount = Convert.ToDecimal(transaction.NetTicketAmount), UserCardDetailId = userCardDetail.Id, PaymentCard = new FIL.Contracts.Models.PaymentChargers.PaymentCard { CardNumber = query.PaymentCard.CardNumber, NameOnCard = query.PaymentCard.NameOnCard, Cvv = query.PaymentCard.Cvv, ExpiryMonth = query.PaymentCard.ExpiryMonth, ExpiryYear = query.PaymentCard.ExpiryYear, CardType = query.PaymentCard.CardType }, PaymentOption = (PaymentOptions)query.PaymentOption, BillingAddress = new FIL.Contracts.Models.PaymentChargers.BillingAddress { FirstName = !string.IsNullOrWhiteSpace(transaction.FirstName) ? transaction.FirstName : "Zoonga", LastName = !string.IsNullOrWhiteSpace(transaction.LastName) ? transaction.LastName : "Zoonga", PhoneCode = !string.IsNullOrWhiteSpace(transaction.PhoneCode) ? transaction.PhoneCode : "91", PhoneNumber = !string.IsNullOrWhiteSpace(transaction.PhoneNumber) ? transaction.PhoneNumber : "9899704772", Email = !string.IsNullOrWhiteSpace(transaction.EmailId) ? transaction.EmailId : "*****@*****.**", //FirstName = "Gaurav", //LastName = "Bhardwaj", //PhoneCode = "91", //PhoneNumber = "9899704772", //Email = "*****@*****.**", AddressLine1 = !string.IsNullOrWhiteSpace(query.BillingAddress.Address) ? query.BillingAddress.Address : "Zoonga", Zipcode = !string.IsNullOrWhiteSpace(query.BillingAddress.Zipcode.ToString()) ? query.BillingAddress.Zipcode.ToString() : "110016", City = !string.IsNullOrWhiteSpace(query.BillingAddress.City) ? query.BillingAddress.City : "Delhi", State = !string.IsNullOrWhiteSpace(query.BillingAddress.State) ? query.BillingAddress.State : "Delhi", Country = !string.IsNullOrWhiteSpace(query.BillingAddress.Country) ? query.BillingAddress.Country : "India" }, BankAltId = query.BankAltId, CardAltId = query.CardAltId, ChannelId = query.ChannelId, }); return(new PaymentCommandResult { TransactionAltId = transaction.AltId, PaymentHtmlPostResponse = paymentHtmlPostResponse }); } return(new PaymentCommandResult { TransactionAltId = transaction.AltId, PaymentResponse = new PaymentResponse { Success = false, PaymentGatewayError = PaymentGatewayError.Unknown } }); }
protected override async Task <ICommandResult> Handle(GuideDetailsCommand command) { GuideDetailsCommandResult guideDetailsCommandResult = new GuideDetailsCommandResult(); try { var user = _UserRepository.GetByEmailAndChannel(command.EmailId, Contracts.Enums.Channels.Feel, Contracts.Enums.SignUpMethods.None); var country = _countryRepository.GetByAltId(new Guid(command.TaxCountry)); if (user == null) { user = new FIL.Contracts.DataModels.User { AltId = Guid.NewGuid(), Email = command.EmailId, Password = Guid.NewGuid().ToString(), RolesId = 20,// new guideID in Guid CreatedBy = command.ModifiedBy, CreatedUtc = DateTime.UtcNow, UserName = command.EmailId, FirstName = command.FirstName, LastName = command.LastName, PhoneCode = command.CountryCode, PhoneNumber = command.MobileNo, ChannelId = Contracts.Enums.Channels.Feel, SignUpMethodId = Contracts.Enums.SignUpMethods.None, IsEnabled = true, LockOutEnabled = false, AccessFailedCount = 0, LoginCount = 0, PhoneConfirmed = true, IsActivated = true }; user = _UserRepository.Save(user); } var zipCode = _zipcodeRepository.GetByZipcode(command.ZipCode); if (zipCode == null) { zipCode = new Zipcode { AltId = Guid.NewGuid(), CityId = command.CityId, CreatedBy = command.ModifiedBy, CreatedUtc = DateTime.UtcNow, IsEnabled = true, Postalcode = command.ZipCode, ModifiedBy = command.ModifiedBy }; zipCode = _zipcodeRepository.Save(zipCode); } var userAddress = _userAddressDetailRepository.GetByUserId(user.Id).FirstOrDefault(); UserAddressDetail userAddressDetail = new UserAddressDetail { Id = userAddress != null ? userAddress.Id : 0, AddressLine1 = command.AddressLineOne, AddressLine2 = command.AddressLineTwo, AddressTypeId = Contracts.Enums.AddressTypes.Billing, AltId = Guid.NewGuid(), FirstName = user.FirstName, LastName = user.LastName, IsEnabled = true, CityId = command.CityId, PhoneCode = user.PhoneCode, UserId = user.Id, IsDefault = true, PhoneNumber = user.PhoneNumber, Zipcode = zipCode.Id, CreatedBy = command.ModifiedBy, CreatedUtc = DateTime.UtcNow }; if (userAddress != null) { userAddress.UpdatedUtc = DateTime.UtcNow; userAddress.ModifiedBy = command.ModifiedBy; userAddress.UpdatedBy = command.ModifiedBy; } userAddressDetail = _userAddressDetailRepository.Save(userAddressDetail); var guideDetails = _GuideDetailsRepository.GetByUserId(user.Id); Redemption_GuideDetails GuideDetails = new Redemption_GuideDetails { ApproveStatusId = Contracts.Enums.ApproveStatus.Pending, Id = guideDetails != null ? guideDetails.Id : 0, IsEnabled = false, UserAddressDetailId = userAddressDetail.Id, LanguageId = String.Join(",", command.LanguageIds.ToArray()), UserId = user.Id, CreatedBy = command.ModifiedBy, ModifiedBy = command.ModifiedBy, CreatedUtc = DateTime.UtcNow }; if (guideDetails != null) { guideDetails.UpdatedUtc = DateTime.UtcNow; guideDetails.ModifiedBy = command.ModifiedBy; guideDetails.UpdatedBy = command.ModifiedBy; } GuideDetails = _GuideDetailsRepository.Save(GuideDetails); foreach (int eventId in command.EventIDs) { Redemption_GuidePlaceMappings GuidePlaceMappings = new Redemption_GuidePlaceMappings { ApproveStatusId = 1, EventId = Convert.ToInt64(eventId), GuideId = GuideDetails.Id, IsEnabled = true, CreatedBy = command.ModifiedBy, ModifiedBy = command.ModifiedBy, CreatedUtc = DateTime.UtcNow }; GuidePlaceMappings = _GuidePlaceMappings.Save(GuidePlaceMappings); } var guideServices = _GuideServicesRepository.GetAllByGuideId(GuideDetails.Id); if (guideServices != null) { foreach (Contracts.DataModels.Redemption.Redemption_GuideServices service in guideServices) { _GuideServicesRepository.Delete(service); } } foreach (Contracts.DataModels.Redemption.Services service in command.Services) { var currentService = service; currentService.Id = 0; currentService.IsEnabled = true; currentService.CreatedBy = command.ModifiedBy; currentService.CreatedUtc = DateTime.UtcNow; currentService = _ServicesRepository.Save(service); Redemption_GuideServices GuideServices = new Redemption_GuideServices { GuideId = GuideDetails.Id, IsEnabled = true, Notes = command.Notes, ServiceId = currentService.Id, CreatedBy = command.ModifiedBy, ModifiedBy = command.ModifiedBy, CreatedUtc = DateTime.UtcNow }; GuideServices = _GuideServicesRepository.Save(GuideServices); } MasterFinanceDetails masterFinanceDetails = new MasterFinanceDetails { AccountNumber = command.AccountNumber, AccountTypeId = command.AccountType, BankAccountTypeId = command.BankAccountType, BankName = command.BankName, BranchCode = command.SwiftCode, CountryId = country.Id, CurrenyId = command.CurrencyId, IsEnabled = true, StateId = command.State, TaxId = command.TaxNumber, RoutingNumber = command.RoutingNumber, CreatedBy = command.ModifiedBy, ModifiedBy = command.ModifiedBy, CreatedUtc = DateTime.UtcNow }; masterFinanceDetails = _MasterFinanceDetailsRepository.Save(masterFinanceDetails); var AllGuideFinanceMappings = _GuideFinanceMappingsRepository.GetAllByGuideId(GuideDetails.Id); foreach (Contracts.DataModels.Redemption.Redemption_GuideFinanceMappings guideFinanceMappings in AllGuideFinanceMappings) { _GuideFinanceMappingsRepository.Delete(guideFinanceMappings); } Redemption_GuideFinanceMappings GuideFinanceMappings = new Redemption_GuideFinanceMappings { GuideId = GuideDetails.Id, IsEnabled = true, CreatedBy = command.ModifiedBy, CreatedUtc = DateTime.UtcNow, MasterFinanceDetailId = masterFinanceDetails.Id }; GuideFinanceMappings = _GuideFinanceMappingsRepository.Save(GuideFinanceMappings); var guideDocuments = _guideDocumentMappingsRepository.GetAllByGuideId(GuideDetails.Id); foreach (Contracts.DataModels.Redemption.Redemption_GuideDocumentMappings guideDocumentMappings in guideDocuments) { _guideDocumentMappingsRepository.Delete(guideDocumentMappings); } var guideDocument = new Redemption_GuideDocumentMappings { GuideId = GuideDetails.Id, IsEnabled = true, CreatedBy = command.ModifiedBy, ModifiedBy = command.ModifiedBy, CreatedUtc = DateTime.UtcNow, DocumentID = command.Document, DocumentSouceURL = "", }; _guideDocumentMappingsRepository.Save(guideDocument); return(new GuideDetailsCommandResult { UserId = user.Id, Success = true }); } catch (Exception ex) { _logger.Log(Logging.Enums.LogCategory.Error, ex); return(new GuideDetailsCommandResult { Success = false }); } }