private HlpResult ComputeResult(string tret) { var point = m_sesi.JawapanCollection.Where(a => a.Trait == tret).Sum(a => a.Nilai); var list = m_scoreTables .Where(x => x.Jantina == m_pengguna.Jantina) .Where(x => x.Tret == tret && point >= x.NilaiMin && point <= x.NilaiMax) .ToList(); if (list.Count != 1) { throw new Exception($"Overlap score tables [{list.Count}] {string.Join(";", list.Select(x => x.Id).ToArray())} -> Tret :{tret}, Point : {point}, Jantina :{m_pengguna.Jantina}"); } var percent = m_scoreTables .Where(x => x.Jantina == m_pengguna.Jantina) .Single(x => x.Tret == tret && point >= x.NilaiMin && point <= x.NilaiMax) .Percentile; var score = m_scoreTables.Where(x => x.Tret == tret) .Where(x => point >= x.NilaiMin && point <= x.NilaiMax) .Where(x => x.Jantina == m_pengguna.Jantina) .Select(x => x.Skor).Single(); var result = new HlpResult { Tret = tret, Skor = score, Percentile = percent, Point = point }; result.Recommendation = m_recommendations.Where(x => x.Tret == tret && x.Skor == result.Skor) .Select(x => x.Text) .SingleOrDefault(); return(result); }
private HlpResult ComputeResultNoJantina(string tret) { var point = m_sesi.JawapanCollection.Where(a => a.Trait == tret).Sum(a => a.Nilai); var temps = m_scoreTables .Where(x => x.Tret == tret && point >= x.NilaiMin && point <= x.NilaiMax) .ToList(); if (temps.Count < 1) { throw new Exception($"TRET:{tret} and point: {point} have {temps.Count} entries"); } if (temps.Count > 1) { var itemsx = string.Join(",", temps.Select(x => x.Id)); throw new Exception($"TRET:{tret} and point: {point} have {temps.Count} entries : {itemsx}"); } var percent = m_scoreTables .Single(x => x.Tret == tret && point >= x.NilaiMin && point <= x.NilaiMax) .Percentile; var score = m_scoreTables.Where(x => x.Tret == tret) .Where(x => point >= x.NilaiMin && point <= x.NilaiMax) .Select(x => x.Skor).Single(); var result = new HlpResult { Tret = tret, Skor = score, Percentile = percent, Point = point }; result.Recommendation = m_recommendations.Where(x => x.Tret == tret && x.Skor == result.Skor) .Select(x => x.Text) .SingleOrDefault(); return(result); }