コード例 #1
0
        public IActionResult GetAvailableProblems()
        {
            if (User.Identity.Name == null)
            {
                return(Ok());
            }

            var user = UserService.Get(long.Parse(User.Identity.Name));

            if (user == null)
            {
                return(NotFound(new ResponseModel
                {
                    Success = false,
                    Message = "Пользователь не найден"
                }));
            }

            var problems = ProblemService.GetAll()
                           .Where(x => x.User == user)
                           .ToList()
                           .Where(x => !IsProblemInWork(x))
                           .OrderByDescending(x => x.CreatedDate)
                           .Select(x => new ProblemViewModel(x))
                           .ToList();

            return(Ok(new DataResponse <List <ProblemViewModel> >
            {
                Data = problems
            }));
        }
コード例 #2
0
ファイル: HomeController.cs プロジェクト: p-dim-popov/SoftUni
        public HttpResponse Index()
        {
            if (IsUserSignedIn())
            {
                return(View(_problemService.GetAll(), "/IndexLoggedIn"));
            }

            return(View());
        }