コード例 #1
0
 /// <summary>
 /// Get the User object from the AppUser collection
 /// </summary>
 private void PopulateUserProperty(Sitter s)
 {
     s.User = _appUserDal.GetById(s.Id);
     if (s.User == null)
     {
         throw new ValidationException("Unable to set User prop");
     }
 }
コード例 #2
0
        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;
        }
コード例 #3
0
 public void Update(Sitter sitter)
 {
     MongoCnn.GetSitterCollection().Save(sitter);
 }
コード例 #4
0
 public void Insert(Sitter sitter)
 {
     MongoCnn.GetSitterCollection().Insert(sitter);
 }