public IEnumerable <CandidateQuestionDto> GetQuestionStatistics(int questionId) { IEnumerable <CandidateQuestionDto> result = null; try { CandidateQuestionsRepository repository = new CandidateQuestionsRepository(_appDbContext); var candidateQuestions = repository.Find(cq => cq.QuestionId == questionId && cq.CandidateUserId != _clientData.ChildId && cq.IsDone == true && (cq.Solution != null || cq.Ranked != null)); if (candidateQuestions != null) { result = _mapper.Map <IEnumerable <CandidateQuestionDto> >(candidateQuestions); } } catch (Exception e) { _log.LogError(e, "Error getting candidate question"); } return(result); }
public IActionResult RemoveFromTodoList(int questionId) { try { CandidateQuestionsRepository repository = new CandidateQuestionsRepository(_appDbContext); repository.Remove(_clientData.ChildId, questionId); } catch (Exception e) { _log.LogError(e, "Error removing from todo list"); return(BadRequest(e.Message)); } return(Ok()); }
public CandidateQuestionDto PostReview([FromBody] ReviewQuestionData obj) { CandidateQuestionDto result = null; try { // Post the question review CandidateQuestionsRepository cqRepository = new CandidateQuestionsRepository(_appDbContext); result = cqRepository.UpdateQuestionReview(obj, _clientData.ChildId); // Update the Rank of the question QuestionsRepository questionsRepository = new QuestionsRepository(_appDbContext); questionsRepository.UpdateRank(obj.QuestionId, obj.Rank); } catch (Exception e) { _log.LogError(e, "Error posting the review"); } return(result); }
public CandidateQuestionDto PostSolution([FromBody] SolutionQuestionData obj) { CandidateQuestionDto result = null; try { // Post the question solution CandidateQuestionsRepository cqRepository = new CandidateQuestionsRepository(_appDbContext); result = cqRepository.UpdateQuestionSolution(obj, _clientData.ChildId); // Increment number of solves count QuestionsRepository questionsRepository = new QuestionsRepository(_appDbContext); questionsRepository.IncrementSolvedCount(obj.QuestionId); } catch (Exception e) { _log.LogError(e, "Error posting the solution"); } return(result); }
public CandidateQuestionDto GetCandidateQuestion(int questionId) { CandidateQuestionDto result = null; try { CandidateQuestionsRepository repository = new CandidateQuestionsRepository(_appDbContext); var candidateQuestion = repository.GetSingleOrDefault(cq => cq.QuestionId == questionId && cq.CandidateUserId == _clientData.ChildId); if (candidateQuestion != null) { result = _mapper.Map <CandidateQuestionDto>(candidateQuestion); } } catch (Exception e) { _log.LogError(e, "Error getting candidate question"); } return(result); }
public CandidateDashboardData GetCandidateDashboardData() { var candidateDashbaordData = new CandidateDashboardData(); try { var questionsRepository = new QuestionsRepository(_appDbContext); var candidateQuestionsRepository = new CandidateQuestionsRepository(_appDbContext); candidateDashbaordData.NumOfQuestions = questionsRepository.GetPublicQuestionsCount(); candidateDashbaordData.TodoListQuestions = Mapper.Map <IEnumerable <QuestionDto> >(candidateQuestionsRepository.Get(false, _clientData.ChildId).Select(cq => cq.Question).Take(Consts.DASHBOARD_DATA_TODO_LIST_COUNT)); candidateDashbaordData.PublishedQuestions = Mapper.Map <IEnumerable <QuestionDto> >(questionsRepository.Find(p => p.CreatedBy == _clientData.Id).Take(Consts.DASHBOARD_DATA_PUBLISHED_QUESTIONS_COUNT).OrderByDescending(q => q.DateCreated)); candidateDashbaordData.TodoListQuestions = questionsRepository.IncludeSkills(candidateDashbaordData.TodoListQuestions); candidateDashbaordData.PublishedQuestions = questionsRepository.IncludeSkills(candidateDashbaordData.PublishedQuestions); } catch (Exception e) { _log.LogError(e, "Error in GetCandidateDashboardData()"); } return(candidateDashbaordData); }
public IEnumerable <QuestionDto> GetDoneOrTodoList(bool isDone) { IEnumerable <QuestionDto> results = null; List <Question> doneOrTodoList = null; try { CandidateQuestionsRepository repository = new CandidateQuestionsRepository(_appDbContext); var candidateQuestions = repository.Get(isDone, _clientData.ChildId); doneOrTodoList = candidateQuestions.Select(q => q.Question).ToList(); results = _mapper.Map <IEnumerable <Question>, IEnumerable <QuestionDto> >(doneOrTodoList); results = new QuestionsRepository(_appDbContext).IncludeSkills(results); } catch (Exception e) { _log.LogError(e, "Error getting done/todo list"); } return(results); }