public async Task <ActionResult> PostResult([FromBody] BulkCandidateWiseResult candidateResult) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } foreach (var item in candidateResult.Candidates) { CandidateResultAddVM cavm = new CandidateResultAddVM(); cavm.CandidateId = item.CandidateId; cavm.ExamId = candidateResult.ExamId; List <SubjectWiseMark> lswvm = new List <SubjectWiseMark>(); foreach (var it in item.Subjects) { SubjectWiseMark swm = new SubjectWiseMark(); swm.SubjectId = it.SubjectId; swm.ObtainMark = it.ObtainMark; lswvm.Add(swm); } cavm.SubjectWiseResults = lswvm; _candidateRepo.Addresult(cavm); await _repo.SaveAsync(); } return(Ok()); }
public void Addresult(CandidateResultAddVM entity) { foreach (var item in entity.SubjectWiseResults) { SubjectWiseResult res = new SubjectWiseResult { CandidateId = entity.CandidateId, ExamId = entity.ExamId, SubjectId = item.SubjectId, ObtainMarks = item.ObtainMark, IsPass = IsPass(item.ObtainMark, entity.ExamId, item.SubjectId) }; _context.SubjectWiseResults.Add(res); } }
public async Task <ActionResult> PostResult([FromBody] CandidateResultAddVM candidateResult) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _candidateRepo.Addresult(candidateResult); try { await _repo.SaveAsync(); } catch (Exception ex) { return(Ok(ex.InnerException)); } return(Ok()); }
public async Task <CandidateResultAddVM> SubjectWiseResults(int examId, int candidateId) { //List<SubjectWiseResult> results = await _context.SubjectWiseResults.Where(x => x.ExamId == examId && x.CandidateId == candidateId).ToListAsync(); //return results; List <SubjectWiseMark> subjectWiseMarks = new List <SubjectWiseMark>(); List <SubjectWiseResult> results = await _context.SubjectWiseResults.Where(x => x.ExamId == examId && x.CandidateId == candidateId).ToListAsync(); foreach (var item in results) { SubjectWiseMark mark = new SubjectWiseMark { SubjectId = item.SubjectId, ObtainMark = item.ObtainMarks, IsPass = item.IsPass }; subjectWiseMarks.Add(mark); } CandidateResultAddVM resultOutput = new CandidateResultAddVM { ExamId = examId, CandidateId = candidateId, SubjectWiseResults = subjectWiseMarks }; return(resultOutput); }