public SignupResult SaveNewSignup(SignupInfo signupInfo,bool requireValidEmail = true, bool requireSitterParentPhone = false)
        {
            var result = new SignupResult() ;
            ValidateSignup(signupInfo, result, requireValidEmail, requireSitterParentPhone);
            if (result.Error != null)
                return result;

            signupInfo.User.Email = signupInfo.User.Email.ToLower();

            _appUserDal.InsertUser(signupInfo.User);
            var userPass = new AppUserPass
            {
                Id = signupInfo.User.Id,
                PasswordHash = StringHasher.GetHashString(signupInfo.Pass),
                Token = Guid.NewGuid().ToString(),
                Email = signupInfo.User.Email.ToLower(),
                MobilePhone =  signupInfo.User.MobilePhone
            };

            _userPassDal.InsertUserPass(userPass);

            if (signupInfo.User.UserRole == UserRole.Parent)
            {
                var parent = new Parent {Id = signupInfo.User.Id};
                _parentDal.Insert(parent);
            }
            else if (signupInfo.User.UserRole == UserRole.Sitter)
            {
                var sitter = new Sitter
                {
                    Id = signupInfo.User.Id,
                    ParentEmail = signupInfo.SitterSignupInfo.ParentEmail,
                    ParentMobile = signupInfo.SitterSignupInfo.ParentMobile,
                    Age = signupInfo.SitterSignupInfo.Age
                };
                _sitterDal.Insert(sitter);
                result.NewId = sitter.Id;
            }
            else if (signupInfo.User.UserRole == UserRole.Admin)
            {                
            }
            else
            {
                throw new AppException(string.Format("userRole '{0}' not valid", signupInfo.User.UserRole));
            }

            string userName = signupInfo.User.Email.ToLower() != null ? signupInfo.User.Email.ToLower() : signupInfo.User.MobilePhone;
            result.newUserData =_authDal.AuthenticateUserByName(userName);
            result.IsSuccess = true;
            return result;
        }
Ejemplo n.º 2
0
 public void Update(AppUserPass appUserPass)
 {
     MongoCnn.GetUserPassCollection().Save(appUserPass);
 }
Ejemplo n.º 3
0
 public void InsertUserPass(AppUserPass appUserPass)
 {            
     MongoCnn.GetUserPassCollection().Insert(appUserPass);
 }