コード例 #1
0
        public IActionResult DeleteScore(string id, string userId)
        {
            if (userId == "self")
            {
                userId = _memoryRepository.GetUserId(this.User);
            }
            if (_memoryRepository.GetUser(userId).Result == null)
            {
                return(NotFound());
            }
            var scoreEntity = _memoryRepository.GetScoreForUser(userId, id);

            if (scoreEntity == null)
            {
                return(NotFound());
            }
            _memoryRepository.DeleteScore(scoreEntity);
            if (!_memoryRepository.Save())
            {
                throw new Exception($"Deleting a score failed for user {userId} and score {id}");
            }
            return(NoContent());
        }