static bool createStandard(Standard stndrd) { //Add standard to db using (var contxt = new SchoolDBEntities()) { contxt.Standards.Add(stndrd); contxt.SaveChanges(); } return(true); }
static bool createStudent(Student student) { //Adds student to db using (var contxt = new SchoolDBEntities()) { contxt.Students.Add(student); contxt.SaveChanges(); } return(true); }
static bool createTeacher(Teacher teach) { //Add teacher to db using (var contxt = new SchoolDBEntities()) { contxt.Teachers.Add(teach); contxt.SaveChanges(); } return true; }
static bool createStudent(Student student) { //Adds student to db using (var contxt = new SchoolDBEntities()) { contxt.Students.Add(student); contxt.SaveChanges(); } return true; }
static bool createStandard(Standard stndrd) { //Add standard to db using (var contxt = new SchoolDBEntities()) { contxt.Standards.Add(stndrd); contxt.SaveChanges(); } return true; }
static bool deleteStudentAddr(String studentName) { //Removes a particular students address Student toDel; var contxt = new SchoolDBEntities(); toDel = contxt.Students.Where(st => st.StudentName == studentName).FirstOrDefault <Student>(); contxt.Entry(toDel.StudentAddress).State = System.Data.Entity.EntityState.Deleted; contxt.SaveChanges(); return(true); }
static bool deleteStudentAddr(String studentName) { //Removes a particular students address Student toDel; var contxt = new SchoolDBEntities(); toDel = contxt.Students.Where(st => st.StudentName == studentName).FirstOrDefault<Student>(); contxt.Entry(toDel.StudentAddress).State = System.Data.Entity.EntityState.Deleted; contxt.SaveChanges(); return true; }
static bool updateStandard(String standardName, String newDescription) { //Change standard description based on what is passed in var contxt = new SchoolDBEntities(); Standard toUpdate; toUpdate = contxt.Standards.Where(st => st.StandardName == standardName).FirstOrDefault <Standard>(); if (toUpdate != null) { toUpdate.Description = newDescription; } else { return(false); } contxt.Entry(toUpdate).State = System.Data.Entity.EntityState.Modified; contxt.SaveChanges(); return(true); }
static bool updateStudent(String studentName, String newAddr) { //Updates a student based on whats passed in to the function var contxt = new SchoolDBEntities(); Student toUpdate; toUpdate = contxt.Students.Where(st => st.StudentName == studentName).FirstOrDefault <Student>(); if (toUpdate != null) { toUpdate.StudentAddress.Address1 = newAddr; } else { return(false); } contxt.Entry(toUpdate).State = System.Data.Entity.EntityState.Modified; contxt.SaveChanges(); return(true); }
static bool updateStudentDisconnect(String studentName, String newAddr) { Student toUpdate; //Update student address in disconnected mode using (var contxt = new SchoolDBEntities()) { toUpdate = contxt.Students.Where(st => st.StudentName == studentName).FirstOrDefault <Student>(); } if (toUpdate != null) { toUpdate.StudentAddress.Address1 = newAddr; } else { return(false); } using (var contxt1 = new SchoolDBEntities()) { contxt1.Entry(toUpdate).State = System.Data.Entity.EntityState.Modified; contxt1.SaveChanges(); } return(true); }
static bool updateTeachIDDisconnect(Teacher toChange, Teacher changeTo) { //Change standard description based on what is passed in //Disconnected mode Teacher toUpdate; Teacher change; using (var contxt = new SchoolDBEntities()) { toUpdate = contxt.Teachers.Where(st => st.TeacherName == toChange.TeacherName).FirstOrDefault<Teacher>(); change = contxt.Teachers.Where(st => st.TeacherName == changeTo.TeacherName).FirstOrDefault<Teacher>(); } if (toUpdate != null && change != null) { toUpdate.StandardId = change.StandardId; } else { return false; } using (var contxt1 = new SchoolDBEntities()) { contxt1.Entry(toUpdate).State = System.Data.Entity.EntityState.Modified; contxt1.SaveChanges(); } return true; }
static bool updateTeachID(Teacher toChange, Teacher changeTo) { //Change standard description based on what is passed in var contxt = new SchoolDBEntities(); Teacher toUpdate; Teacher change; toUpdate = contxt.Teachers.Where(st => st.TeacherName== toChange.TeacherName).FirstOrDefault<Teacher>(); change = contxt.Teachers.Where(st => st.TeacherName == changeTo.TeacherName).FirstOrDefault<Teacher>(); if (toUpdate != null) { toUpdate.StandardId = change.StandardId; } else { return false; } contxt.Entry(toUpdate).State = System.Data.Entity.EntityState.Modified; contxt.SaveChanges(); return true; }
static bool updateStudentDisconnect(String studentName, String newAddr) { Student toUpdate; //Update student address in disconnected mode using (var contxt = new SchoolDBEntities()) { toUpdate = contxt.Students.Where(st => st.StudentName == studentName).FirstOrDefault<Student>(); } if (toUpdate != null) { toUpdate.StudentAddress.Address1 = newAddr; } else { return false; } using (var contxt1 = new SchoolDBEntities()) { contxt1.Entry(toUpdate).State = System.Data.Entity.EntityState.Modified; contxt1.SaveChanges(); } return true; }
static bool updateStudent(String studentName, String newAddr) { //Updates a student based on whats passed in to the function var contxt = new SchoolDBEntities(); Student toUpdate; toUpdate = contxt.Students.Where(st => st.StudentName == studentName).FirstOrDefault<Student>(); if(toUpdate != null) { toUpdate.StudentAddress.Address1 = newAddr; } else { return false; } contxt.Entry(toUpdate).State = System.Data.Entity.EntityState.Modified; contxt.SaveChanges(); return true; }
static bool updateStandard(String standardName, String newDescription) { //Change standard description based on what is passed in var contxt = new SchoolDBEntities(); Standard toUpdate; toUpdate = contxt.Standards.Where(st => st.StandardName == standardName).FirstOrDefault<Standard>(); if (toUpdate != null) { toUpdate.Description = newDescription; } else { return false; } contxt.Entry(toUpdate).State = System.Data.Entity.EntityState.Modified; contxt.SaveChanges(); return true; }