public IActionResult Update([FromBasicAuth] string auth, [FromBody] ScoreItem item, string id) { if (item == null) { return(BadRequest()); } var score = ScoreItems.Find(id); if (score == null) { return(NotFound()); } if (!Auth.IsAllowed(auth, score.Game, UserPermission.UpdateScores)) { return(Auth.Result); } item.Key = score.Key; if (GameItems.Find(item.Game) == null) { return(BadRequest("Game not found")); } ScoreItems.Update(item); return(new NoContentResult()); }
public IActionResult Delete([FromBasicAuth] string auth, string id) { var score = ScoreItems.Find(id); if (score == null) { return(NotFound()); } if (!Auth.IsAllowed(auth, score.Game, UserPermission.UpdateScores)) { return(Auth.Result); } ScoreItems.Remove(id); return(new NoContentResult()); }
public IActionResult GetById([FromBasicAuth] string auth, string id) { var item = ScoreItems.Find(id); if (item != null) { if (!Auth.IsAllowed(auth, item.Game, UserPermission.ReadScores)) { return(Auth.Result); } } else { return(NotFound()); } return(new ObjectResult(item)); }