Exemplo n.º 1
0
        public ActionResult <Unlocks> PostUnlocks(Unlocks unlocks)
        {
            _context.Unlocks.Add(unlocks);
            _context.SaveChanges();

            return(CreatedAtAction("GetUnlocks", new { id = unlocks.Id }, unlocks));
        }
Exemplo n.º 2
0
        public ActionResult <Achievements> PostAchievements(Achievements achievements)
        {
            _context.Achievements.Add(achievements);
            _context.SaveChanges();

            return(achievements);
        }
Exemplo n.º 3
0
        public ActionResult <Games> PostGames(Games game)
        {
            if (game != _context.Games.FirstOrDefault(g => g.Id == game.Id))
            {
                ObjectResult result = new ObjectResult("game_already_exist");
                result.StatusCode = 406;
                return(result);
            }
            _context.Games.Add(game);
            _context.SaveChanges();

            return(game);
        }
Exemplo n.º 4
0
        public ActionResult <Ownership> PostOwnership(Ownership ownership)
        {
            if (OwnershipExists(ownership.Id))
            {
                ObjectResult o = new ObjectResult("ownership_has_already_been_set")
                {
                    StatusCode = 400
                };
            }

            _context.Ownership.Add(ownership);

            _context.SaveChanges();

            return(ownership);
        }
Exemplo n.º 5
0
        public ActionResult <string> DeleteUsers(string email)
        {
            var users = _context.Users.Find(email);

            if (users == null)
            {
                return(NotFound());
            }

            _context.Users.Remove(users);
            _context.SaveChanges();

            return($"{email} has been deleted");
        }
Exemplo n.º 6
0
        public ActionResult <string> CreateNewUser(string username, string password)
        {
            if (username == null || password == null)
            {
                ObjectResult objRes = new ObjectResult("invalid_parameters")
                {
                    StatusCode = 401
                };
                return(objRes);
            }
            if (!UsernameIsValid(username))
            {
                ObjectResult result = new ObjectResult("email_Not_Valid");
                result.StatusCode = 406;
                return(result);
            }
            if (UserExist(username))
            {
                ObjectResult result = new ObjectResult("user_already_exist");
                result.StatusCode = 406;
                return(result);
            }
            Users  user;
            Hasher hasher = new Hasher(password);
            string hash   = hasher.ComputeHash();
            string salt   = hasher.salt;

            user = new Users {
                Email = username, Salt = salt, Hash = hash
            };

            _db.Users.Add(user);
            _db.SaveChanges();

            return($"{username} has been created");
        }