Пример #1
0
        private List <Section> ConvertSections(List <SectionBO> sectionsToConvert)
        {
            var sectionsConverted = new List <Section>();

            foreach (var section in sectionsToConvert)
            {
                var lessonsConverted = new List <Lesson>();
                foreach (var lesson in section.Lessons)
                {
                    var lessonConverted = _lesConv.Convert(lesson);
                    lessonsConverted.Add(lessonConverted);
                }
                var sectionConverted = _secConverter.Convert(section);
                sectionConverted.Lessons = lessonsConverted;
                sectionsConverted.Add(sectionConverted);
            }
            return(sectionsConverted);
        }
Пример #2
0
        public LessonBO Get(int id)
        {
            using (var uow = _facade.UnitOfWork)
            {
                var lesFromDb   = uow.LessonRepo.Get(id);
                var convSection = _secConv.Convert(lesFromDb.Section);

                var lesson = _lessonConv.Convert(lesFromDb);
                lesson.Section = convSection;

                return(lesson);
            }
        }
Пример #3
0
 public SectionBO Create(SectionBO section)
 {
     using (var uow = _facade.UnitOfWork)
     {
         // TODO check if entity is valid, and throw errors if not
         var sectionCreated = uow.SectionRepo.Create(_sectionConv.Convert(section));
         uow.Complete();
         return(_sectionConv.Convert(sectionCreated));
     }
 }