Exemplo n.º 1
0
        public IActionResult GetAllProblems()
        {
            var list = rep.getAllProblems();
            List <ProblemCompleteViewModel> problems = new List <ProblemCompleteViewModel>();

            foreach (var item in list)
            {
                ProblemCompleteViewModel problemListViewModel = new ProblemCompleteViewModel();
                problemListViewModel.Problem     = Mapper.Map <Problem, ProblemViewModel>(item);
                problemListViewModel.Difficulty  = Mapper.Map <Difficulty, DifficultyViewModel>(item.Difficulty);
                problemListViewModel.ProblemType = Mapper.Map <ProblemType, ProblemTypeViewModel>(item.ProblemType);
                problems.Add(problemListViewModel);
            }


            return(Ok(problems));
        }
Exemplo n.º 2
0
        public IActionResult GetProblemBId(Guid id)
        {
            Problem problem = rep.getProblemById(id);

            if (problem == null)
            {
                RequestStatus requestStatus = new RequestStatus();
                requestStatus.Error      = "Problem Does not exist";
                requestStatus.Success    = false;
                requestStatus.StatusCode = 404;

                return(Ok(requestStatus));
            }
            ProblemCompleteViewModel problemComplete = new ProblemCompleteViewModel();

            problemComplete.Problem     = Mapper.Map <Problem, ProblemViewModel>(problem);
            problemComplete.Difficulty  = Mapper.Map <Difficulty, DifficultyViewModel>(problem.Difficulty);
            problemComplete.ProblemType = Mapper.Map <ProblemType, ProblemTypeViewModel>(problem.ProblemType);
            problemComplete.makeSuccess();
            return(Ok(problemComplete));
        }