示例#1
0
        public void Add(User user)
        {
            DbContext.Users.Add(user);
            DbContext.SaveChanges();

            var users = DbContext.Users.Where(x => x.Id < 9).ToList();
        }
 private ActionResult RegisterUser(RegisterViewModel model)
 {
     model.Email = model.Email.ToLower();
     lock (_registerUserSyncRoot)
     {
         var user = _context.Users.Where(x => x.Email == model.Email).AsNoTracking().FirstOrDefault();
         if (user == null)
         {
             var securePassword = _passwordManager.EncryptPassword(model.Password);
             user = new User(model.Email, model.FirstName, model.LastName, securePassword.HashedPassword, securePassword.Salt);
             _context.Users.Add(user);
             _context.SaveChanges();
             var loginViewModel = new LoginViewModel();
             loginViewModel.ShowMessage(ToastrType.Success, "Sukces", "Twoje konto zostało utworzone. Możesz się zalogować.");
             return(View("Login", loginViewModel));
         }
     }
     model.ShowMessage(ToastrType.Error, "Błąd", "Podany email istanieje już w bazie.");
     model.Password = model.PasswordConfirmation = string.Empty;
     return(View(model));
 }