示例#1
0
        public async Task AddFILMember(MCUserModel model, string country)
        {
            var listId = string.Empty;

            if (model.IsCreator)
            {
                listId = _settings.GetConfigSetting <string>(SettingKeys.Integration.MailChimp.CreatorListId);
            }
            else
            {
                listId = _settings.GetConfigSetting <string>(SettingKeys.Integration.MailChimp.BuyerListId);
            }

            var currentIp    = _clientIpProvider.Get();
            var mailChimpApi = GetMailChimp();

            var location = ListExtension.GetLocationByIp(currentIp);

            var member = new Member
            {
                EmailAddress    = model.Email,
                Status          = Status.Subscribed,
                StatusIfNew     = Status.Subscribed,
                TimestampSignup = DateTime.UtcNow.ToString("yyyy-MM-dd hh:mm:ss"),
                IpSignup        = currentIp,
                IpOpt           = currentIp
            };
            var subscriberDetails = new Dictionary <string, object>
            {
                { "FNAME", model.FirstName },
                { "LNAME", model.LastName },
                { "PHONE", "+" + model.PhoneCode.Split("~")[0] + "" + model.PhoneNumber },
                { "COUNTRY", country != null?country:"" },
                { "COUNTRYIP", location.country_name != null?location.country_name:"" },
                { "CITYIP", location.city != null?location.city:"" },
                { "STATEIP", location.state_prov != null?location.state_prov:"" },
                { "TZIP", location.time_zone != null?location.time_zone.name:"" },
                { "SUPMETD", model.SignUpType }
            };

            member.MergeFields = subscriberDetails;
            await mailChimpApi.Members.AddOrUpdateAsync(listId, member);
        }
示例#2
0
        public async Task <GoogleSignInResponseViewModel> SignInGoogle([FromBody] GoogleSignInFormDataViewModel model)
        {
            if (ModelState.IsValid)
            {
                var    result         = new { Succeeded = true };
                var    email          = model.Email;
                var    passwordHasher = new PasswordHasher <string>();
                string password       = new Random().NextDouble().ToString();
                string PasswordHash   = passwordHasher.HashPassword(model.Email, password);
                try
                {
                    var Email            = model.Email;
                    var userSearchResult = await _querySender.Send(new UserSearchQuery
                    {
                        Email          = model.Email,
                        ChannelId      = Channels.Feel,
                        SignUpMethodId = SignUpMethods.Google,
                    });

                    if (userSearchResult.Success)
                    {
                        var UserData = new LoginWithGoogleFormDataViewModel
                        {
                            Email          = model.Email,
                            SocialLoginId  = model.SocialLoginId,
                            ChannelId      = Channels.Feel,
                            SignUpMethodId = SignUpMethods.Google,
                        };

                        var authenticated = await _authenticationHelper.AuthenticateGoogleUser(UserData, u =>
                        {
                            return(Task.FromResult(true));
                        });

                        return(new GoogleSignInResponseViewModel
                        {
                            Success = authenticated,
                            Session = await _sessionProvider.Get()
                        });
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(model.Email))
                        {
                            return(new GoogleSignInResponseViewModel
                            {
                                Success = false,
                                IsEmailRequired = true,
                                Session = await _sessionProvider.Get()
                            });
                        }
                        await _commandSender.Send(new RasvRegisterUserCommand
                        {
                            Email          = model.Email,
                            PasswordHash   = PasswordHash,
                            UserName       = model.Email,
                            FirstName      = model.FirstName,
                            LastName       = model.LastName,
                            PhoneCode      = model.PhoneCode,
                            PhoneNumber    = model.PhoneNumber,
                            ChannelId      = Channels.Feel,
                            RolesId        = 11,
                            SocialLoginId  = model.SocialLoginId,
                            OptedForMailer = true,
                            Ip             = _clientIpProvider.Get(),
                            SignUpMethodId = SignUpMethods.Google,
                            ReferralId     = model.ReferralId
                        });

                        var UserData = new LoginWithGoogleFormDataViewModel
                        {
                            Email          = model.Email,
                            SocialLoginId  = model.SocialLoginId,
                            ChannelId      = Channels.Feel,
                            SignUpMethodId = SignUpMethods.Google,
                        };

                        var authenticated = await _authenticationHelper.AuthenticateGoogleUser(UserData, u =>
                        {
                            return(Task.FromResult(true));
                        });

                        // adding user to mailChimp contacts
                        try
                        {
                            var query = await _querySender.Send(new UserSearchQuery
                            {
                                Email          = model.Email,
                                ChannelId      = Channels.Feel,
                                SignUpMethodId = SignUpMethods.Google,
                            });

                            await _mailChimpProvider.AddFILMember(new MCUserModel
                            {
                                FirstName   = model.FirstName,
                                LastName    = model.LastName,
                                Email       = model.Email,
                                PhoneCode   = model.PhoneCode,
                                PhoneNumber = model.PhoneNumber,
                                IsCreator   = false,
                                SignUpType  = "Google"
                            }, query.Country);
                        }
                        catch (Exception e)
                        {
                            _logger.Log(Logging.Enums.LogCategory.Error, e);
                        }


                        return(new GoogleSignInResponseViewModel
                        {
                            Success = authenticated,
                            Session = await _sessionProvider.Get()
                        });
                    }
                }
                catch (Exception ex)
                {
                    _logger.Log(Logging.Enums.LogCategory.Error, ex);
                    return(new GoogleSignInResponseViewModel {
                        Success = false
                    });
                }
            }
            else
            {
                return(new GoogleSignInResponseViewModel {
                    Success = false
                });
            }
        }
示例#3
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,
                });
            }
        }
示例#4
0
        public async Task <TicketAlertUserMappingResponseDataViewModel> saveSignUp([FromBody] TicketAlertUserMappingRequestDataViewModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    model.CountriesAltIds         = model.CountriesAltIds.Distinct().ToList();
                    model.TicketAlertEventMapping = model.TicketAlertEventMapping.Distinct().ToList();
                    var queryResult = await _querySender.Send(new TicketAlertUesrMappingQuery
                    {
                        Countries         = model.CountriesAltIds,
                        Email             = model.Email,
                        EventAltId        = model.EventAltId,
                        EventDetailId     = 0,
                        TicketAlertEvents = model.TicketAlertEventMapping
                    });

                    if (queryResult.IsAlredySignUp)
                    {
                        return(new TicketAlertUserMappingResponseDataViewModel
                        {
                            IsAlreadySignUp = true,
                            Success = false
                        });
                    }
                    else
                    {
                        FIL.Contracts.Enums.TourTravelPackages TourTravelPackages = FIL.Contracts.Enums.TourTravelPackages.No;
                        if (model.TourAndTavelPackage == 1)
                        {
                            TourTravelPackages = FIL.Contracts.Enums.TourTravelPackages.Yes;
                        }
                        await _commandSender.Send(new TicketAlertUserMappingCommand
                        {
                            CountriesAltId     = model.CountriesAltIds,
                            EventAltId         = model.EventAltId,
                            EventDetailId      = 0,
                            FirstName          = model.FirstName,
                            TourTravelPackages = TourTravelPackages,
                            LastName           = model.LastName,
                            PhoneCode          = model.PhoneCode,
                            PhoneNumber        = model.PhoneNumber,
                            Email             = model.Email,
                            NumberOfTickets   = model.NoOfTickets,
                            TicketAlertEvents = model.TicketAlertEventMapping,
                            Ip = _clientIpProvider.Get()
                        });

                        try
                        {
                            var   siteUrls = _siteUrlsProvider.GetSiteUrl(_siteIdProvider.GetSiteId());
                            Email email    = new Email();
                            email.To           = model.Email;
                            email.From         = "FeelitLIVE  <*****@*****.**>";
                            email.TemplateName = "FILTicketAlert";

                            email.Variables = new Dictionary <string, object>
                            {
                                ["eventname"] = model.EventName
                            };
                            await _confirmationEmailSender.Send(email);

                            return(new TicketAlertUserMappingResponseDataViewModel
                            {
                                IsAlreadySignUp = false,
                                Success = true
                            });
                        }
                        catch (Exception e)
                        {
                            return(new TicketAlertUserMappingResponseDataViewModel
                            {
                                IsAlreadySignUp = false,
                                Success = true
                            });
                        }
                    }
                }
                catch (Exception e)
                {
                    return(new TicketAlertUserMappingResponseDataViewModel
                    {
                        IsAlreadySignUp = false,
                        Success = false
                    });
                }
            }
            else
            {
                return(new TicketAlertUserMappingResponseDataViewModel
                {
                    IsAlreadySignUp = false,
                    Success = false
                });
            }
        }
示例#5
0
        public async Task <LoginWithOTPResponseModel> LoginWithOTP([FromBody] LoginWithOTPFormModel model)
        {
            if (ModelState.IsValid)
            {
                if (string.IsNullOrEmpty(model.Email))
                {
                    var userAuthenticate = AuthenticateUser(model.PhoneCode.Split("~")[0], model.PhoneNumber).Result;
                    return(new LoginWithOTPResponseModel
                    {
                        Success = userAuthenticate.Success,
                        Session = await _sessionProvider.Get(),
                        IsAdditionalFieldsReqd = userAuthenticate.IsAdditionalFieldsReqd
                    });
                }
                else
                {
                    //new user or new phoneNumber
                    var    passwordHasher = new PasswordHasher <string>();
                    string password       = new Random().NextDouble().ToString();
                    string PasswordHash   = passwordHasher.HashPassword(model.Email, password);
                    RegisterUserWithOTPCommandCommandResult registerUserResult = await _commandSender.Send <RegisterUserWithOTPCommand, RegisterUserWithOTPCommandCommandResult>(new RegisterUserWithOTPCommand
                    {
                        Email          = model.Email,
                        PasswordHash   = PasswordHash,
                        UserName       = model.Email,
                        FirstName      = model.FirstName,
                        LastName       = model.LastName,
                        PhoneCode      = model.PhoneCode,
                        PhoneNumber    = model.PhoneNumber,
                        ChannelId      = Contracts.Enums.Channels.Feel,
                        SignUpMethodId = Contracts.Enums.SignUpMethods.OTP,
                        ReferralId     = model.ReferralId,
                        Ip             = _clientIpProvider.Get(),
                    });

                    if (registerUserResult.Success)
                    {
                        var userAuthenticate = AuthenticateUser(model.PhoneCode.Split("~")[0], model.PhoneNumber).Result;
                        return(new LoginWithOTPResponseModel
                        {
                            Success = userAuthenticate.Success,
                            Session = await _sessionProvider.Get()
                        });
                    }
                    else if (Convert.ToBoolean(registerUserResult.EmailAlreadyRegistered))
                    {
                        return(new LoginWithOTPResponseModel
                        {
                            Success = false,
                            EmailAlreadyRegistered = true
                        });
                    }
                    else
                    {
                        return(new LoginWithOTPResponseModel
                        {
                            Success = false,
                        });
                    }
                }
            }
            else
            {
                return(new LoginWithOTPResponseModel {
                    Success = false
                });
            }
        }
示例#6
0
        public async Task <RegistrationResponseViewModel> Register([FromBody] RegistrationFormDataViewModel model)
        {
            if (ModelState.IsValid)
            {
                var hostName       = GetHostName();
                var passwordHasher = new PasswordHasher <string>();
                try
                {
                    var queryResult = await _querySender.Send(new UserSearchQuery
                    {
                        Email          = model.Email,
                        ChannelId      = Channels.Feel,
                        SignUpMethodId = SignUpMethods.Regular,
                        PhoneCode      = model.PhoneCode
                    });

                    if (queryResult.Success)
                    {
                        return(new RegistrationResponseViewModel
                        {
                            Success = false,
                            IsExisting = true,
                        });
                    }
                    else
                    {
                        await _commandSender.Send(new RegisterUserCommand
                        {
                            Email          = model.Email,
                            PasswordHash   = passwordHasher.HashPassword(model.Email, model.Password),
                            UserName       = model.UserName,
                            FirstName      = model.FirstName,
                            LastName       = model.LastName,
                            ChannelId      = Channels.Feel,
                            SignUpMethodId = SignUpMethods.Regular,
                            PhoneCode      = model.PhoneCode,
                            PhoneNumber    = model.PhoneNumber,
                            Ip             = _clientIpProvider.Get(),
                            ReferralId     = model.ReferralId,
                            IsMailOpt      = model.IsMailOpt
                        });

                        var query = await _querySender.Send(new UserSearchQuery
                        {
                            Email          = model.Email,
                            ChannelId      = Channels.Feel,
                            SignUpMethodId = SignUpMethods.Regular,
                            PhoneCode      = model.PhoneCode
                        });

                        Messaging.Models.Emails.Email email = new Messaging.Models.Emails.Email();
                        email.To                   = model.Email;
                        email.From                 = "FeelitLIVE  <*****@*****.**>"; // XXX: TODO: Add feel email template
                        email.TemplateName         = "feelUserSignUp";
                        email.ConfigurationSetName = "FIL-Signup";
                        email.Variables            = new Dictionary <string, object>
                        {
                            ["activationurl"] = "<a href='https://" + hostName + "/activate/" + query.User.AltId.ToString() + "' style='margin -right:100px;'><img src='https://static1.feelitlive.com/images/feel-mail/activate-account.png' width='215' height='36' style='border:0' alt='Activate Your Account' /></a>",
                            ["sitename"]      = "feelitLIVE"
                        };
                        await _confirmationEmailSender.Send(email);

                        // adding user to MailChimp contacts
                        try
                        {
                            await _mailChimpProvider.AddFILMember(new MCUserModel
                            {
                                FirstName   = model.FirstName,
                                LastName    = model.LastName,
                                Email       = model.Email,
                                PhoneCode   = model.PhoneCode,
                                PhoneNumber = model.PhoneNumber,
                                IsCreator   = false,
                                SignUpType  = "Regular"
                            }, query.Country);
                        }
                        catch (Exception e)
                        {
                            _logger.Log(Logging.Enums.LogCategory.Error, e);
                        }

                        return(new RegistrationResponseViewModel {
                            Success = true, IsExisting = false,
                        });
                    }
                }
                catch (Exception ex)
                {
                    _logger.Log(Logging.Enums.LogCategory.Error, ex);
                    return(new RegistrationResponseViewModel
                    {
                        Success = false,
                        IsExisting = false,
                    });
                }
            }
            else
            {
                return(new RegistrationResponseViewModel
                {
                    Success = false,
                    IsExisting = false,
                });
            }
        }