//Insert a certificate program with links to specific entrance requirements public void InsertCertificateProgram(DiplomaCertificate certProgram, List <EntranceRequirementList> entReqList) { using (Pathway_Model context = new Pathway_Model()) { DiplomaCertificate added = null; EntranceRequirement addedEntReq = null; added = context.DiplomaCertificates.Add(certProgram); if (entReqList != null) { // create entrance requirement entry for each row entered foreach (EntranceRequirementList entry in entReqList) { EntranceRequirement entReq = new EntranceRequirement() { ProgramID = added.ProgramID, CourseID = entry.CourseID, Marks = entry.Mark }; addedEntReq = context.EntranceRequirements.Add(entReq); } } // commits the add to the databas context.SaveChanges(); } }
public void EntReq_Delete(EntranceRequirementInfo item) { using (Pathway_Model context = new Pathway_Model()) { EntranceRequirement existing = context.EntranceRequirements.Find(item.ProgramID, item.CourseID); context.EntranceRequirements.Remove(existing); context.SaveChanges(); } }
public void EntReq_Update(EntranceRequirementInfo item) { using (Pathway_Model context = new Pathway_Model()) { EntranceRequirement entReq = new EntranceRequirement() { ProgramID = item.ProgramID, CourseID = item.CourseID, Marks = item.Mark }; context.Entry <EntranceRequirement>(context.EntranceRequirements.Attach(entReq)).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } }
public void EntReq_Add(EntranceRequirementInfo item) { using (Pathway_Model context = new Pathway_Model()) { EntranceRequirement entReq = new EntranceRequirement() { ProgramID = item.ProgramID, CourseID = item.CourseID, Marks = item.Mark }; context.EntranceRequirements.Add(entReq); context.SaveChanges(); } }
//Insert a diploma program with entrance requirements for specific courses, and links to degree programs public void InsertDiplomaProgram(DiplomaCertificate diplomaProgram, List <EntranceRequirementList> entReqList, List <int> degreeIDs) { using (Pathway_Model context = new Pathway_Model()) { DiplomaCertificate added = null; EntranceRequirement addedEntReq = null; added = context.DiplomaCertificates.Add(diplomaProgram); if (entReqList.Count != 0) { // create entrance requirement entry for each row entered foreach (EntranceRequirementList entry in entReqList) { EntranceRequirement entReq = new EntranceRequirement() { ProgramID = added.ProgramID, CourseID = entry.CourseID, Marks = entry.Mark }; addedEntReq = context.EntranceRequirements.Add(entReq); } } if (degreeIDs.Count != 0) { //create degree diploma entry for each row entered foreach (int entry in degreeIDs) { Degree selectedDegree = context.Degrees.SingleOrDefault(d => d.DegreeID == entry); selectedDegree.DiplomaCertificates.Add(diplomaProgram); } } // commits the add to the databas context.SaveChanges(); } }