public void CreateLesson(ILessonDto lesson) { if (lesson == null) { throw new ArgumentNullException("lesson"); } _context.Lessons.Add((LessonDto)lesson); _context.SaveChanges(); }
public void UpdateLesson(ILessonDto lesson) { if (lesson == null) { throw new ArgumentNullException("lesson"); } LessonDto oldLesson = _context.Lessons.Single(l => l.LessonId == lesson.LessonId); oldLesson.Date = lesson.Date; oldLesson.GroupId = lesson.GroupId; _context.SaveChanges(); }
private Lesson Map(ILessonDto lesson) { return new Lesson { LessonId = lesson.LessonId, Date = lesson.Date, Group = new Group { GroupId = lesson.GroupId, GroupNumber = lesson.Group.GroupNumber, Year = lesson.Group.Year } }; }