public ActionResult <FreehandMatchesReadDto> GetFreehandMatchById()
        {
            try
            {
                string matchId = RouteData.Values["matchId"].ToString();
                string userId  = User.Identity.Name;

                bool hasPermission = _matchService.CheckFreehandMatchPermission(int.Parse(matchId), int.Parse(userId));

                if (!hasPermission)
                {
                    return(Forbid());
                }

                var allMatches = _matchService.GetFreehandMatchById(int.Parse(matchId));

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

                return(Ok(_mapper.Map <FreehandMatchesReadDto>(allMatches)));
            }
            catch (Exception e)
            {
                return(StatusCode(500, e.Message));
            }
        }
예제 #2
0
        public ActionResult <IEnumerable <FreehandGoalReadDto> > GetFreehandGoalsByMatchId()
        {
            try
            {
                string matchId = RouteData.Values["matchId"].ToString();
                string userId  = User.Identity.Name;
                bool   access  = _matchService.CheckFreehandMatchPermission(int.Parse(matchId), int.Parse(userId));

                if (!access)
                {
                    return(Forbid());
                }

                var allGoals = _goalService.GetFreehandGoalsByMatchId(int.Parse(matchId), int.Parse(userId));

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

                return(Ok(_mapper.Map <IEnumerable <FreehandGoalReadDto> >(allGoals)));
            }
            catch (Exception e)
            {
                return(StatusCode(500, e.Message));
            }
        }