public bool Create(string email, string password, string name)
        {
            if (string.IsNullOrEmpty(password)) password = GeneratePassword();

            User user = new User();
            email = email.ToLower();
            String passwd = CreatePasswordHash(password, CreateSalt(email));
            user.Email = email;
            user.Password = passwd;
            user.Name = name;
            context.AddToUsers(user);
            context.SaveChanges();
            return true;
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the Users EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToUsers(User user)
 {
     base.AddObject("Users", user);
 }
 /// <summary>
 /// Create a new User object.
 /// </summary>
 /// <param name="email">Initial value of the Email property.</param>
 public static User CreateUser(global::System.String email)
 {
     User user = new User();
     user.Email = email;
     return user;
 }
        public void Can_Register_With_Capgemini_Email()
        {
            //Arrange
            User model = new User
            {
                Email = "*****@*****.**",
                Password = "******",
                PasswordAgain = "WeAreTheOnes",
                Name = "name"
            };

            // Act
            ActionResult res = accountController.Register(model);

            // Assert
            mock.Verify(m => m.Create(model.Email, model.Password, model.Name));
            Assert.IsInstanceOf(typeof(RedirectToRouteResult), res);
        }
        public void Can_Not_Register_Without_Valid_Email()
        {
            //Arrange
            User model = new User
            {
                Email = "test",
                Password = "******"
            };

            // Act
            accountController.ModelState.AddModelError("error", "Email must end with @capgemini.com");
            ActionResult res = accountController.Register(model);

            // Assert
            Assert.IsInstanceOf(typeof(ViewResult), res);
            Assert.IsFalse(((ViewResult)res).ViewData.ModelState.IsValid);
        }
 public ActionResult Register(User user)
 {
     if (ModelState.IsValid)
     {
        if (accountRepository.Create(user.Email, user.Password, user.Name))
             {
                 this.Success(string.Format("Account for {0} has been registered", user.Email));
                 accountRepository.Authenticate(user.Email, user.Password);
                 return RedirectToAction("Index", "Event");
             }
         }
     return View();
 }