예제 #1
0
        public ActionResult Register(Register register)
        {
            var succeeded = _accountService.RegisterUser(register);

            var message = succeeded ? "User successfully registered" : string.Format("User with email '{0}' already exist.", register.Email);

            return  Json(new { succeeded = succeeded, message = message});
        }
예제 #2
0
 public User Map(Register register)
 {
     return new User
     {
         Email    = register.Email,
         Password = register.Password
     };
 }
예제 #3
0
        public static Register MakeRegister(string email, string password)
        {
            var register = new Register
            {
                Email = email,
                Password = password,
                ConfirmPassword = password
            };

            return register;
        }
예제 #4
0
        public bool RegisterUser(Register register)
        {
            var succeeded = false;

            var user = _userMapper.Map(register);

            using (var session = _documentStore.OpenSession())
            {
                var alreadyregistered = (session.Query<User>()
                                            .Customize(x => x.WaitForNonStaleResultsAsOfLastWrite())
                                            .Count(u => u.Email == register.Email)) > 0;

                if (!alreadyregistered)
                {
                    session.Store(user);
                    session.SaveChanges();

                    succeeded = true;
                }

            }
            return succeeded;
        }