Ejemplo n.º 1
0
        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());
        }
Ejemplo n.º 2
0
        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());
        }
Ejemplo n.º 3
0
        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));
        }