public ActionResult Register(UserViewModel user)
 {
     if (!ModelState.IsValid)
     {
         ShowError("Please provide all required fields!");
         MergeModelState();
         return RedirectToAction("Register");
     }
     var userItem = _userRepository.GetOne(u => u.Email == user.Email);
     if (userItem != null)
     {
         ShowError("User with the same email already exist!");
         MergeModelState();
         return RedirectToAction("Register");
     }
     _userRepository.Save(ToUser(user));
     FormsAuthentication.SetAuthCookie(user.Email, false);
     return RedirectToAction("Index", "Home");
 }
 private static User ToUser(UserViewModel userViewModel)
 {
     var hashData = PasswordHash.CreateHash(userViewModel.Password);
     return new User
                {
                    Name = userViewModel.Name,
                    Company = userViewModel.Company,
                    Email = userViewModel.Email,
                    Password = hashData.Hash,
                    Salt = hashData.Salt
                };
 }