public static Schedule deleteLesson(int scheduleId) { using (RacheliandDiniEntities3 db = new RacheliandDiniEntities3()) { Schedule schedule = new Schedule(); foreach (var item in db.Schedules) { if (item.ScheduleId == scheduleId) { schedule = item; db.Schedules.Remove(item); if (schedule != null) { break; } } } try { db.SaveChanges(); return(schedule); } catch (Exception e) { return(null); } } }
public static void updateStudent(StudentDTO.UserAndStudentDTO userAndStudentDTO, int id) { using (RacheliandDiniEntities3 db = new RacheliandDiniEntities3()) { foreach (var user in db.Users) { if (user.userId == id) { user.firstName = userAndStudentDTO.firstName; user.city = userAndStudentDTO.city; user.lastName = userAndStudentDTO.lastName; user.street = userAndStudentDTO.street; user.numhouse = userAndStudentDTO.numhouse; user.phone = userAndStudentDTO.phone; user.password = userAndStudentDTO.password; user.email = userAndStudentDTO.email; user.tz = userAndStudentDTO.tz; } ; } foreach (var student in db.Students) { if (student.StudentId == id) { student.IdGrade = userAndStudentDTO.IdGrade; student.Level = userAndStudentDTO.Level; } } db.SaveChanges(); } }
public static List <Schedule> GetLessons() { using (RacheliandDiniEntities3 db = new RacheliandDiniEntities3()) { return(db.Schedules.ToList()); } }
public static bool UpdateSubject(SubjectToTeacherDTO subject) { bool flag = false; using (RacheliandDiniEntities3 db = new RacheliandDiniEntities3()) { foreach (var i in db.SubjectToTeachers) { if (i.TeacherId == subject.TeacherId && i.Subject.Contains(subject.SubjectName)) { i.GradesRange = subject.GradesRange; i.PriceForLesson = subject.PriceForLesson; flag = true; break; } } db.SaveChanges(); if (flag == true) { return(true); } } return(false); }
public static List <Lesson> GetNotes(int id) { using (RacheliandDiniEntities3 db = new RacheliandDiniEntities3()) { return(db.Lessons.ToList()); } }
public static List <Student> GetStudents() { using (RacheliandDiniEntities3 db = new RacheliandDiniEntities3()) { return(db.Students.ToList()); } }
public static void updateTeacher(TeacherDTO.UserAndTeacherDTO userAndTeacherDTO, int id) { using (RacheliandDiniEntities3 db = new RacheliandDiniEntities3()) { foreach (var user in db.Users) { if (user.userId == id) { user.firstName = userAndTeacherDTO.firstName; user.city = userAndTeacherDTO.city; user.lastName = userAndTeacherDTO.lastName; user.street = userAndTeacherDTO.street; user.numhouse = userAndTeacherDTO.numhouse; user.phone = userAndTeacherDTO.phone; user.password = userAndTeacherDTO.password; user.email = userAndTeacherDTO.email; user.tz = userAndTeacherDTO.tz; break; } ; } foreach (var teacher in db.Teachers) { if (teacher.TeacherId == id) { teacher.Qualifications = userAndTeacherDTO.Qualifications; break; } } db.SaveChanges(); } }
public static List <Hour> getHours() { using (RacheliandDiniEntities3 db = new RacheliandDiniEntities3()) { return(db.Hours.ToList()); } }
public static List <Recommendation> GetRecrecommendationById() { using (RacheliandDiniEntities3 db = new RacheliandDiniEntities3()) { return(db.Recommendations.ToList()); } }
public static List <Teacher> GetTeachers() { using (RacheliandDiniEntities3 db = new RacheliandDiniEntities3()) { return(db.Teachers.ToList()); } }
public static void addTeacher(Teacher teacher, User user) { using (RacheliandDiniEntities3 db = new RacheliandDiniEntities3()) { db.Teachers.Add(teacher); db.Users.Add(user); try { db.SaveChanges(); //_context.SaveChanges(); } catch (System.Data.Entity.Validation.DbEntityValidationException dbEx) { Exception raise = dbEx; foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { string message = string.Format("{0}:{1}", validationErrors.Entry.Entity.ToString(), validationError.ErrorMessage); // raise a new exception nesting // the current instance as InnerException raise = new InvalidOperationException(message, raise); } } throw raise; } db.SaveChanges(); } }
public static List <Vacation> getVacation() { using (RacheliandDiniEntities3 db = new RacheliandDiniEntities3()) { return(db.Vacations.ToList()); } }
public static void AddStudent(Student student, User user) { using (RacheliandDiniEntities3 db = new RacheliandDiniEntities3()) { db.Users.Add(user); db.Students.Add(new Student() { IdGrade = student.IdGrade, Level = student.Level, StudentId = user.userId }); try { db.SaveChanges(); } catch (System.Data.Entity.Validation.DbEntityValidationException dbEx) { Exception raise = dbEx; foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { string message = string.Format("{0}:{1}", validationErrors.Entry.Entity.ToString(), validationError.ErrorMessage); raise = new InvalidOperationException(message, raise); } } throw raise; } db.SaveChanges(); } }
public static List <SubjectToTeacher> GetSubjectToTeachers() { using (RacheliandDiniEntities3 db = new RacheliandDiniEntities3()) { var q = db.SubjectToTeachers.ToList(); return(q); } }
public static void AddTeacher(Teacher teacher) { using (RacheliandDiniEntities3 db = new RacheliandDiniEntities3()) { db.Teachers.Add(teacher); db.SaveChanges(); } }
public static void AddLesson(Hour hour) { using (RacheliandDiniEntities3 db = new RacheliandDiniEntities3()) { db.Hours.Add(hour); db.SaveChanges(); } }
public static void AddLesson(Schedule schedule) { using (RacheliandDiniEntities3 db = new RacheliandDiniEntities3()) { db.Schedules.Add(schedule); db.SaveChanges(); } }
public static void HoursForTeacherAdd(HoursForTeacher hoursForTeacher) { using (RacheliandDiniEntities3 db = new RacheliandDiniEntities3()) { db.HoursForTeachers.Add(hoursForTeacher); db.SaveChanges(); } }
public static void AddUser(User User) { using (RacheliandDiniEntities3 db = new RacheliandDiniEntities3()) { db.Users.Add(User); db.SaveChanges(); } }
public static void AddRecommendation(string value, int id) { using (RacheliandDiniEntities3 db = new RacheliandDiniEntities3()) { Recommendation recommendation = new Recommendation() { TeacherId = id, RecommendationContents = value, }; db.Recommendations.Add(recommendation); db.SaveChanges(); } }
public static void DeleteHoursAndDaysForTeacher(int id) { using (RacheliandDiniEntities3 db = new RacheliandDiniEntities3()) { foreach (var item in db.HoursForTeachers) { if (item.HoursForTeacherId == id) { db.HoursForTeachers.Remove(item); db.SaveChanges(); } } } }
public static void AddNote(int id, string value, DateTime date) { using (RacheliandDiniEntities3 db = new RacheliandDiniEntities3()) { db.Lessons.Add(new Lesson() { ScheduleId = id, Date = date, LessonDescribe = value }); db.SaveChanges(); } }
public static bool AddSubjectToTeacher(SubjectToTeacher subjectToTeacher) { using (RacheliandDiniEntities3 db = new RacheliandDiniEntities3()) { int index = db.SubjectToTeachers.ToList().FindIndex(item => item.TeacherId == subjectToTeacher.TeacherId && item.Subject.Contains(subjectToTeacher.Subject) && item.GradesRange.Contains(subjectToTeacher.GradesRange)); if (index >= 0) { return(true); } db.SubjectToTeachers.Add(subjectToTeacher); db.SaveChanges(); return(false); } }
public static void DeleteStudent(int id) { using (RacheliandDiniEntities3 db = new RacheliandDiniEntities3()) { foreach (var item in db.Students) { if (item.StudentId == id) { db.Students.Remove(item); } } foreach (var item in db.Users) { if (item.userId == id) { db.Users.Remove(item); } } } }