public StudentModel InsertStudent(tblStudent tblstudobj , tblStudentHistory tblhisobj) { using (StudentInformationSystemEntities db = new StudentInformationSystemEntities()) { tblstudobj.ID = Guid.NewGuid(); tblhisobj.ID = Guid.NewGuid(); db.tblStudent.Add(tblstudobj); int j = db.SaveChanges(); var studid = (from t in db.tblStudent orderby t.ID select t ).ToList().Last(); tblhisobj.StudentID = studid.ID; db.tblStudentHistory.Add(tblhisobj); int i = db.SaveChanges(); if (i == 1&&j==0) return new StudentModel(); else return null; ; } }
public bool DeleteStudent(tblStudent tblstudobj, tblStudentHistory tblstudhisobj { bool result = false; using (StudentInformationSystemEntities db = new StudentInformationSystemEntities()) { StudentModel student = db.tblStudent.Where(x => x.ID == tblstudobj.ID).Select(x => x).FirstOrDefault(); db.tblStudent.DeleteObject(student); db.SaveChanges(); result = true; } return result; }