示例#1
0
        public async Task <User> CreateUser(User user)
        {
            var newEntity = await _usersDataContext.AddAsync(user);

            await _usersDataContext.SaveChangesAsync();

            return(newEntity.Entity);
        }
        public IActionResult SignUp(string email, string username, string password, string passwordverification)
        {
            SaltRevision salt = (SaltRevision)Enum.GetValues(typeof(SaltRevision)).GetValue(rng.Next(Enum.GetValues(typeof(SaltRevision)).Length));

            if (password.Equals(passwordverification))
            {
                User u = new User();
                u.Username = username;
                u.Email    = email;
                u.Password = BCrypt.Net.BCrypt.HashPassword(password, 12, salt);
                u.UserId   = database.Users.Count() + 1;
                database.AddAsync(u);
                database.SaveChangesAsync();
                //HttpContext.Session.Set("UserID", Encoding.UTF8.GetBytes(u.UserId.ToString()));
                //return to the index with the user
                return(View("Index", null));
            }
            else
            {
                return(View("Index"));
            }
            //return RedirectToAction("Characters");
        }