示例#1
0
        public SchedulingCustomerEditModel UpdateCartwithReturningCustomer(string guid, long customerId)
        {
            var customerEditModel            = new SchedulingCustomerEditModel();
            var onlineRequestValidationModel = _tempcartService.ValidateOnlineRequest(guid);

            customerEditModel.RequestValidationModel = onlineRequestValidationModel;

            if (onlineRequestValidationModel.RequestStatus != OnlineRequestStatus.Valid)
            {
                return(customerEditModel);
            }

            var tempCart = onlineRequestValidationModel.TempCart;

            if (tempCart != null)
            {
                tempCart.CustomerId         = customerId;
                tempCart.IsExistingCustomer = true;
                tempCart.ProspectCustomerId = null;

                _tempcartService.SaveTempCart(tempCart);
            }

            var customer = _customerRepository.GetCustomer(customerId);

            customerEditModel                 = Mapper.Map <Customer, SchedulingCustomerEditModel>(customer);
            customerEditModel.PhoneCell       = PhoneNumber.ToNumber(customer.MobilePhoneNumber.ToString());
            customerEditModel.ShippingAddress = Mapper.Map <Address, AddressEditModel>(customer.BillingAddress ?? customer.Address);
            customerEditModel.MarketingSource = tempCart.MarketingSource;
            customerEditModel.EnableTexting   = _enableTexting;
            customerEditModel.EnableVoiceMail = _enableVoiceMail;
            return(customerEditModel);
        }
示例#2
0
        public SchedulingCustomerEditModel RegisterCustomer(String guid, SchedulingCustomerEditModel customerEditModel)
        {
            if (!string.IsNullOrEmpty(customerEditModel.HomeNumber))// To eliminate masking
            {
                customerEditModel.HomeNumber = customerEditModel.HomeNumber.Replace("-", "").Replace("(", "").Replace(")", "").Replace(" ", "");
            }

            if (!string.IsNullOrEmpty(customerEditModel.PhoneCell))// To eliminate masking
            {
                customerEditModel.PhoneCell = customerEditModel.PhoneCell.Replace("-", "").Replace("(", "").Replace(")", "").Replace(" ", "");
            }

            var onlineRequestValidationModel = _tempcartService.ValidateOnlineRequest(guid);

            customerEditModel.RequestValidationModel = onlineRequestValidationModel;
            if (onlineRequestValidationModel.RequestStatus != OnlineRequestStatus.Valid)
            {
                return(customerEditModel);
            }

            if (!customerEditModel.DateofBirth.HasValue)
            {
                throw new Exception("Please enter Date of Birth!");
            }

            if (customerEditModel.DateofBirth.Value.GetAge() < _settings.MinimumAgeForScreening)
            {
                throw new Exception(string.Format("Customers below {0} years of age are not allowed for screening.In case of any queries, please call us at {1}", _settings.MinimumAgeForScreening, _settings.PhoneTollFree));
            }

            var customer  = _customerService.SaveCustomer(customerEditModel, onlineRequestValidationModel.TempCart.IsExistingCustomer);
            var userLogin = _userLoginRepository.GetByUserId(customer.Id);

            _passwordChangeLogService.Update(userLogin.Id, new SecureHash(userLogin.Password, userLogin.Salt), customer.CustomerId);
            onlineRequestValidationModel.TempCart.CustomerId      = customer.CustomerId;
            onlineRequestValidationModel.TempCart.MarketingSource = customerEditModel.MarketingSource;

            var tempCart = onlineRequestValidationModel.TempCart;

            _tempcartService.SaveTempCart(tempCart);


            var doesEventCustomerAlreadyExists = tempCart.CustomerId.HasValue ? _eventSchedulerService.DoesEventCustomerAlreadyExists(tempCart.CustomerId.Value, tempCart.EventId.Value) : null;

            if (doesEventCustomerAlreadyExists != null && doesEventCustomerAlreadyExists.FirstValue)
            {
                throw new Exception(doesEventCustomerAlreadyExists.SecondValue);
            }

            customer = tempCart.CustomerId.HasValue ? _customerRepository.GetCustomer(tempCart.CustomerId.Value) : null;
            if (tempCart.ProspectCustomerId.HasValue)
            {
                var prospectCustomer = _prospectCustomerRepository.GetById(tempCart.ProspectCustomerId.Value);
                prospectCustomer.CustomerId                 = customer.CustomerId;
                prospectCustomer.Tag                        = ProspectCustomerTag.OnlineSignup;
                prospectCustomer.IsConverted                = false;
                prospectCustomer.Status                     = (long)ProspectCustomerConversionStatus.NotConverted;
                prospectCustomer.ConvertedOnDate            = DateTime.Now;
                prospectCustomer.Address.StreetAddressLine1 = customer.Address.StreetAddressLine1;
                prospectCustomer.Address.StreetAddressLine2 = customer.Address.StreetAddressLine2;
                prospectCustomer.Address.City               = customer.Address.City;
                prospectCustomer.Address.State              = _stateRepository.GetState(customer.Address.StateId).Name;
                prospectCustomer.Address.ZipCode.Zip        = customer.Address.ZipCode.Zip;
                prospectCustomer.MarketingSource            = customer.MarketingSource;
                prospectCustomer.CallBackPhoneNumber        = customer.HomePhoneNumber;
                prospectCustomer.Email                      = customer.Email;
                prospectCustomer.TagUpdateDate              = DateTime.Now;
                _prospectCustomerRepository.Save(prospectCustomer);
            }
            else
            {
                var prospectCustomer = ((IProspectCustomerRepository)_prospectCustomerRepository).GetProspectCustomerByCustomerId(customer.CustomerId);
                if (prospectCustomer != null)
                {
                    prospectCustomer.CustomerId                 = customer.CustomerId;
                    prospectCustomer.Tag                        = ProspectCustomerTag.OnlineSignup;
                    prospectCustomer.IsConverted                = false;
                    prospectCustomer.Status                     = (long)ProspectCustomerConversionStatus.NotConverted;
                    prospectCustomer.ConvertedOnDate            = DateTime.Now;
                    prospectCustomer.Address.StreetAddressLine1 = customer.Address.StreetAddressLine1;
                    prospectCustomer.Address.StreetAddressLine2 = customer.Address.StreetAddressLine2;
                    prospectCustomer.Address.City               = customer.Address.City;
                    prospectCustomer.Address.State              = _stateRepository.GetState(customer.Address.StateId).Name;
                    prospectCustomer.Address.ZipCode.Zip        = customer.Address.ZipCode.Zip;
                    prospectCustomer.MarketingSource            = customer.MarketingSource;
                    prospectCustomer.CallBackPhoneNumber        = customer.HomePhoneNumber;
                    prospectCustomer.Email                      = customer.Email;
                    prospectCustomer.TagUpdateDate              = DateTime.Now;
                    _prospectCustomerRepository.Save(prospectCustomer);
                }
            }
            return(customerEditModel);
        }
示例#3
0
        public Customer SaveCustomer(SchedulingCustomerEditModel model, bool isExistingCustomer)
        {
            Customer customer;

            model.FullName.FirstName  = model.FullName.FirstName.ToUppercaseInitalLetter();
            model.FullName.LastName   = model.FullName.LastName.ToUppercaseInitalLetter();
            model.FullName.MiddleName = model.FullName.MiddleName.ToUppercaseInitalLetter();

            if (model.Id > 0)
            {
                customer = _customerRepository.GetCustomer(model.Id);
                customer.DateModified = DateTime.Now;
                customer.DateOfBirth  = model.DateofBirth;
                customer.Gender       = (Gender)(model.Gender != null && model.Gender > 0 ? model.Gender.Value : 0);

                var addressId = customer.Address.Id;
                customer.Address    = Mapper.Map <AddressEditModel, Address>(model.ShippingAddress);
                customer.Address.Id = addressId;

                if (!isExistingCustomer)
                {
                    customer.MarketingSource = model.MarketingSource;
                }
            }
            else
            {
                customer = new Customer
                {
                    UserLogin = new UserLogin
                    {
                        UserName     = !string.IsNullOrEmpty(model.UserName) ? model.UserName : _userNameGenerator.Generate(model.FullName),
                        Password     = model.Password,
                        HintAnswer   = null,
                        HintQuestion = null,
                        IsSecurityQuestionVerified = false,
                        UserVerified = true
                    },
                    AddedByRoleId   = (long)Roles.Customer,
                    DateCreated     = DateTime.Now,
                    DateOfBirth     = model.DateofBirth,
                    Gender          = (Gender)(model.Gender != null && model.Gender > 0 ? model.Gender.Value : 0),
                    Address         = Mapper.Map <AddressEditModel, Address>(model.ShippingAddress),
                    MarketingSource = model.MarketingSource,
                    EnableTexting   = model.ConfirmationToEnablTexting != null && model.ConfirmationToEnablTexting.Value,
                    EnableVoiceMail = model.ConfirmationToEnableVoiceMail != null && model.ConfirmationToEnableVoiceMail.Value
                };

                //customer.Address.Id = 0;
            }

            customer.Name = model.FullName;

            if (!string.IsNullOrEmpty(model.Email))
            {
                customer.Email = new Email(model.Email);
            }
            else
            {
                customer.Email = null;
            }

            customer.HomePhoneNumber = new PhoneNumber
            {
                PhoneNumberType = PhoneNumberType.Home,
                Number          = model.HomeNumber
            };
            customer.MobilePhoneNumber = new PhoneNumber
            {
                PhoneNumberType = PhoneNumberType.Mobile,
                Number          = model.PhoneCell
            };
            customer.EnableTexting   = model.ConfirmationToEnablTexting != null && model.ConfirmationToEnablTexting.Value;
            customer.EnableVoiceMail = model.ConfirmationToEnableVoiceMail != null && model.ConfirmationToEnableVoiceMail.Value;

            customer.InsuranceId = model.InsuranceId;
            customer.Ssn         = model.Ssn;

            var result = SaveCustomer(customer, model.Id);

            return(result ? customer : null);
        }