Beispiel #1
0
        private void SetUser(SkinnyProfile profile, bool login)
        {
            SetAccountId(profile.AccountId);
            SetCrmId(profile.CrmId);
            SetUserIsLoggedIn(login);

            var userProfile = GetProfile(profile.CommerceId);

            SetUserName(userProfile.FirstName, userProfile.Surname);

            var newCustomerId = profile.CommerceId;

            if (newCustomerId != GetCommerceId())
            {
                _basketService.TransferBasket(GetCommerceId(), newCustomerId, false);
                SetCommerceCustomerId(newCustomerId);
            }

            SetBasketCount(profile.CommerceId);
        }
Beispiel #2
0
        public SkinnyProfile Login(string email, string password)
        {
            // Try and retrieve the account based on the email and password provided
            var profile = _accountRepository.GetAccount(email, password);

            // If profile found
            if (profile != null)
            {
                // Check the profile has the necessary profiles
                if (CheckProfile(ref profile))
                {
                    // If a match not found in the CRM
                    if (profile.Status != AccountStatus.RequiresMatching)
                    {
                        profile.Status = AccountStatus.Success;
                    }
                }
                else
                {
                    // Return blank profile project with a failure message
                    profile = new SkinnyProfile
                    {
                        Result = new Result {
                            Success = false, ErrorMessage = "CheckProfile returned false"
                        }
                    };
                }
            }
            else
            {
                // Return blank profile project with a failure message
                profile = new SkinnyProfile {
                    Result = new Result {
                        Success = false, ErrorMessage = "Profile is null"
                    }
                };
            }

            return(profile);
        }
Beispiel #3
0
        private bool CheckProfile(ref SkinnyProfile skinnyProfile)
        {
            var isValid = true;

            // Check commerce is null
            if (skinnyProfile.CommerceId == Guid.Empty)
            {
                // Bad account - delete it
                _accountRepository.DeleteAccount(skinnyProfile.AccountId);
                isValid = false;
            }
            else
            {
                var userProfile = _profileService.GetUserProfile(skinnyProfile.CommerceId);
                if (userProfile == null)
                {
                    // Could not load the commerce profile, an error may have occurred, or worse the account no longer exists...
                    isValid = false;
                }
            }

            return(isValid);
        }