public ActionResult <Unlocks> PostUnlocks(Unlocks unlocks) { _context.Unlocks.Add(unlocks); _context.SaveChanges(); return(CreatedAtAction("GetUnlocks", new { id = unlocks.Id }, unlocks)); }
public ActionResult <Achievements> PostAchievements(Achievements achievements) { _context.Achievements.Add(achievements); _context.SaveChanges(); return(achievements); }
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); }
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); }
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"); }
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"); }