//public static QuestionPercentage GetQuestionPercentage(int CertificationID) //{ // QuestionPercentage questionPercentage = null; // try // { // questionPercentage = questionPercentage = cntxt.QuestionPercentages.Where(x => x.CertificationId == CertificationID).First(); // } // catch (Exception) // { // } // return questionPercentage; //} //public static Decimal GetKnowledgeAreaQuestionPercentageofCertification(int questionpercentageid, int knowledgeareaid) //{ // Decimal percentage = 0; // try // { // var q = cntxt.QuestionPercentageDetails.Where(x => x.QuestionPercentageId == questionpercentageid && x.KnowledgeAreaId == knowledgeareaid).First(); // } // catch (Exception) // { // } // return percentage; //} //public static QuestionPercentage CreateQuestionPercentage(int CertificationID) //{ // QuestionPercentage questionPercentage = null; // if (CertificationID != 0) // { // questionPercentage = GetQuestionPercentage(CertificationID); // if (questionPercentage == null) // { // questionPercentage = new QuestionPercentage(); // questionPercentage.QuestionPercentageId = 0; // questionPercentage.CertificationId = CertificationID; // } // List<KnowledgeArea> knowledgeArealist = KnowledgeAreaRepository.GetAllknowledgeAreaOfCertification(CertificationID); // foreach (KnowledgeArea element in knowledgeArealist) // { // if (!questionPercentage.QuestionPercentageDetails.Any(f => f.KnowledgeAreaId == element.KnowledgeAreaId)) // { // QuestionPercentageDetail det = new QuestionPercentageDetail(); // det.KnowledgeAreaId = element.KnowledgeAreaId; // det.KnowledgeArea = element; // det.TotalPercentage = 0; // questionPercentage.QuestionPercentageDetails.Add(det); // } // } // } // return questionPercentage; //} public static void InsertQuestionPercentageDetails(QuestionPercentageDetail questionPercentageDetail) { if (questionPercentageDetail.QuestionPercentageDetailId != 0) { } else { cntxt.QuestionPercentageDetails.Add(questionPercentageDetail); cntxt.SaveChanges(); } }
public static QuestionPercentage CreateQuestionPercentage(int CertificationID) { QuestionPercentage questionPercentage = null; if (CertificationID != 0) { questionPercentage = GetQuestionPercentage(CertificationID); if (questionPercentage == null) { questionPercentage = new QuestionPercentage(); questionPercentage.QuestionPercentageId = 0; questionPercentage.CertificationId = CertificationID; } List <KnowledgeArea> knowledgeArealist = KnowledgeAreaRepository.GetAllknowledgeAreaOfCertification(CertificationID); foreach (KnowledgeArea element in knowledgeArealist) { if (!questionPercentage.QuestionPercentageDetails.Any(f => f.KnowledgeAreaId == element.KnowledgeAreaId)) { QuestionPercentageDetail det = new QuestionPercentageDetail(); det.KnowledgeAreaId = element.KnowledgeAreaId; det.KnowledgeArea = element; det.TotalPercentage = 0; questionPercentage.QuestionPercentageDetails.Add(det); } } } return(questionPercentage); }