Esempio n. 1
0
        public virtual APIResult <FidelityCustomer> CreateFidelityAccount(FidelityUserPart fidelityPart, string username, string email, string campaignId)
        {
            if (fidelityPart != null && !String.IsNullOrWhiteSpace(username))
            {
                FidelityCustomer customer = new FidelityCustomer(email, username, Membership.GeneratePassword(12, 4));

                APIResult <FidelityCustomer> creationRequest = _sendService.SendCustomerRegistration(settingsPart, customer, campaignId);

                if (creationRequest.success)
                {
                    fidelityPart.FidelityUsername = customer.Username;

                    fidelityPart.FidelityPassword = Convert.ToBase64String(_encryptionService.Encode(Encoding.UTF8.GetBytes(customer.Password)));
                    if (!string.IsNullOrWhiteSpace(customer.Id))
                    {
                        fidelityPart.CustomerId = customer.Id;
                    }
                }
                return(creationRequest);
            }
            else
            {
                return new APIResult <FidelityCustomer> {
                           success = false, data = null, message = "The user is not configured to use " + GetProviderName()
                }
            };
        }