Beispiel #1
0
        public async Task <IActionResult> GetProblemAsync(int pid)
        {
            bool viewAll = await UserModel.Authorization.CanViewAllProblemsAsync(HttpContext.Session.GetString("user"));

            if (!viewAll)
            {
                if (await ProblemModel.IsProblemRestrictedAsync(pid))
                {
                    return(StatusCode(StatusCodes.Status403Forbidden, "This problem is private now."));
                }
            }
            var problem = await ProblemModel.GetProblemAsync(pid);

            if (problem is null)
            {
                return(NotFound("No such problem."));
            }
            return(Ok(problem));
        }