Exemplo n.º 1
0
        // POST: Roles/Create
        public async Task AddAndSave(User user)
        {
            _userRepo.Add(user);
            await _userRepo.Save();

            //_context.Roles.Add(role);
            //await _context.SaveChangesAsync();
        }
Exemplo n.º 2
0
        public void Create()
        {
            Task.WaitAny();
            var x         = new StreamReader(Request.Body).ReadToEnd();
            var userToAdd = JsonConvert.DeserializeObject <Users>(x);

            Task.WaitAny();

            _usersRepo.Add(userToAdd);
        }
Exemplo n.º 3
0
        public ActionResult <User> Register(string username, string password)
        {
            //Check if user exists
            var user = _userRepo.Set.FirstOrDefault(a => a.Username == username);

            if (user != null)
            {
                return(user);
            }

            //Create a new user
            var newUser = new User
            {
                Username     = username,
                PasswordHash = password
            };

            //AddToDb
            newUser = _userRepo.Add(newUser);

            return(newUser);
        }