本文整理汇总了C#中Schedule.DataLayer.ScheduleContext类的典型用法代码示例。如果您正苦于以下问题:C# ScheduleContext类的具体用法?C# ScheduleContext怎么用?C# ScheduleContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ScheduleContext类属于Schedule.DataLayer命名空间,在下文中一共展示了ScheduleContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddGroupsInFaculty
public GroupsInFaculty AddGroupsInFaculty(GroupsInFaculty groupsInFaculty)
{
using (var context = new ScheduleContext(ConnectionString))
{
groupsInFaculty.GroupsInFacultyId = 0;
groupsInFaculty.StudentGroup = context.StudentGroups.FirstOrDefault(gif => gif.StudentGroupId == groupsInFaculty.StudentGroup.StudentGroupId);
groupsInFaculty.Faculty = context.Faculties.FirstOrDefault(gif => gif.FacultyId == groupsInFaculty.Faculty.FacultyId);
context.GroupsInFaculties.Add(groupsInFaculty);
context.SaveChanges();
return groupsInFaculty;
}
}
示例2: FindConfigOption
public ConfigOption FindConfigOption(string key)
{
using (var context = new ScheduleContext(ConnectionString))
{
return context.Config.FirstOrDefault(op => op.Key == key);
}
}
示例3: FindFaculty
public Faculty FindFaculty(string name)
{
using (var context = new ScheduleContext(ConnectionString))
{
return context.Faculties.FirstOrDefault(f => f.Name == name);
}
}
示例4: ClearAllExams
public void ClearAllExams()
{
using (var context = new ScheduleContext(ConnectionString))
{
var examIds = context.Exams.Select(e => e.ExamId).ToList();
foreach (var examId in examIds)
{
RemoveExam(examId);
}
}
}
示例5: FindAuditorium
public Auditorium FindAuditorium(string name)
{
using (var context = new ScheduleContext(ConnectionString))
{
return context.Auditoriums.FirstOrDefault(a => a.Name == name);
}
}
示例6: AddTeacher
public Teacher AddTeacher(Teacher teacher)
{
using (var context = new ScheduleContext(ConnectionString))
{
teacher.TeacherId = 0;
context.Teachers.Add(teacher);
context.SaveChanges();
return teacher;
}
}
示例7: AddTeacherForDisciplineRange
public void AddTeacherForDisciplineRange(IEnumerable<TeacherForDiscipline> teacherForDisciplineList)
{
using (var context = new ScheduleContext(ConnectionString))
{
foreach (var teacherForDiscipline in teacherForDisciplineList)
{
teacherForDiscipline.TeacherForDisciplineId = 0;
context.TeacherForDiscipline.Add(teacherForDiscipline);
}
context.SaveChanges();
}
}
示例8: AddLessonWOLog
public Lesson AddLessonWOLog(Lesson lesson)
{
using (var context = new ScheduleContext(ConnectionString))
{
lesson.LessonId = 0;
lesson.TeacherForDiscipline = context.TeacherForDiscipline.FirstOrDefault(tfd => tfd.TeacherForDisciplineId == lesson.TeacherForDiscipline.TeacherForDisciplineId);
lesson.Calendar = context.Calendars.FirstOrDefault(c => c.CalendarId == lesson.Calendar.CalendarId);
lesson.Ring = context.Rings.FirstOrDefault(r => r.RingId == lesson.Ring.RingId);
lesson.Auditorium = context.Auditoriums.FirstOrDefault(a => a.AuditoriumId == lesson.Auditorium.AuditoriumId);
context.Lessons.Add(lesson);
context.SaveChanges();
return lesson;
}
}
示例9: AddLogEvent
public LogEvent AddLogEvent(LogEvent logEvent)
{
using (var context = new ScheduleContext(ConnectionString))
{
logEvent.OldExam = context.Exams.FirstOrDefault(e => e.ExamId == logEvent.OldExam.ExamId);
logEvent.NewExam = context.Exams.FirstOrDefault(e => e.ExamId == logEvent.NewExam.ExamId);
context.EventLog.Add(logEvent);
context.SaveChanges();
return logEvent;
}
}
示例10: AddLessonLogEventRange
public void AddLessonLogEventRange(IEnumerable<LessonLogEvent> lessonLogEventList)
{
using (var context = new ScheduleContext(ConnectionString))
{
foreach (var lessonLogEvent in lessonLogEventList)
{
lessonLogEvent.LessonLogEventId = 0;
lessonLogEvent.OldLesson = context.Lessons.FirstOrDefault(l => l.LessonId == lessonLogEvent.OldLesson.LessonId);
lessonLogEvent.NewLesson = context.Lessons.FirstOrDefault(l => l.LessonId == lessonLogEvent.NewLesson.LessonId);
context.LessonLog.Add(lessonLogEvent);
}
context.SaveChanges();
}
}
示例11: AddLessonRange
public void AddLessonRange(IEnumerable<Lesson> lessonList)
{
using (var context = new ScheduleContext(ConnectionString))
{
foreach (var lesson in lessonList)
{
lesson.LessonId = 0;
lesson.TeacherForDiscipline = context.TeacherForDiscipline.FirstOrDefault(tfd => tfd.TeacherForDisciplineId == lesson.TeacherForDiscipline.TeacherForDisciplineId);
lesson.Calendar = context.Calendars.FirstOrDefault(c => c.CalendarId == lesson.Calendar.CalendarId);
lesson.Ring = context.Rings.FirstOrDefault(r => r.RingId == lesson.Ring.RingId);
lesson.Auditorium = context.Auditoriums.FirstOrDefault(a => a.AuditoriumId == lesson.Auditorium.AuditoriumId);
context.Lessons.Add(lesson);
}
context.SaveChanges();
}
}
示例12: AddLessonLogEvent
public LessonLogEvent AddLessonLogEvent(LessonLogEvent lessonLogEvent)
{
using (var context = new ScheduleContext(ConnectionString))
{
lessonLogEvent.LessonLogEventId = 0;
lessonLogEvent.OldLesson = (lessonLogEvent.OldLesson == null) ? null : context.Lessons.FirstOrDefault(l => l.LessonId == lessonLogEvent.OldLesson.LessonId);
lessonLogEvent.NewLesson = (lessonLogEvent.NewLesson == null) ? null : context.Lessons.FirstOrDefault(l => l.LessonId == lessonLogEvent.NewLesson.LessonId);
context.LessonLog.Add(lessonLogEvent);
context.SaveChanges();
return lessonLogEvent;
}
}
示例13: AddLesson
public Lesson AddLesson(Lesson lesson, string publicComment = "", string hiddenComment = "")
{
using (var context = new ScheduleContext(ConnectionString))
{
lesson.LessonId = 0;
lesson.TeacherForDiscipline = context.TeacherForDiscipline.FirstOrDefault(tfd => tfd.TeacherForDisciplineId == lesson.TeacherForDiscipline.TeacherForDisciplineId);
lesson.Calendar = context.Calendars.FirstOrDefault(c => c.CalendarId == lesson.Calendar.CalendarId);
lesson.Ring = context.Rings.FirstOrDefault(r => r.RingId == lesson.Ring.RingId);
lesson.Auditorium = context.Auditoriums.FirstOrDefault(a => a.AuditoriumId == lesson.Auditorium.AuditoriumId);
context.Lessons.Add(lesson);
context.LessonLog.Add(
new LessonLogEvent
{
OldLesson = null,
NewLesson = lesson,
DateTime = DateTime.Now,
PublicComment = publicComment,
HiddenComment = hiddenComment
}
);
context.SaveChanges();
return lesson;
}
}
示例14: AddGroupsInFacultyRange
public void AddGroupsInFacultyRange(IEnumerable<GroupsInFaculty> groupsInFacultiesList)
{
using (var context = new ScheduleContext(ConnectionString))
{
foreach (var groupsInFaculty in groupsInFacultiesList)
{
groupsInFaculty.GroupsInFacultyId = 0;
groupsInFaculty.StudentGroup = context.StudentGroups.FirstOrDefault(gif => gif.StudentGroupId == groupsInFaculty.StudentGroup.StudentGroupId);
groupsInFaculty.Faculty = context.Faculties.FirstOrDefault(gif => gif.FacultyId == groupsInFaculty.Faculty.FacultyId);
context.GroupsInFaculties.Remove(groupsInFaculty);
}
context.SaveChanges();
}
}
示例15: AddStudentsInGroups
public StudentsInGroups AddStudentsInGroups(StudentsInGroups studentsInGroups)
{
using (var context = new ScheduleContext(ConnectionString))
{
studentsInGroups.StudentsInGroupsId = 0;
studentsInGroups.Student = context.Students.FirstOrDefault(s => s.StudentId == studentsInGroups.Student.StudentId);
studentsInGroups.StudentGroup = context.StudentGroups.FirstOrDefault(sg => sg.StudentGroupId == studentsInGroups.StudentGroup.StudentGroupId);
context.StudentsInGroups.Add(studentsInGroups);
context.SaveChanges();
return studentsInGroups;
}
}