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)); }