本文整理匯總了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;
}
}