Example #1
0
        public async Task <bool> PostLessonFile(int lessonId, DateTime date, LessonFileDto lessonFile)
        {
            LessonInHistory lessonInHistory = await GetOrCreateLessonInHistory(lessonId, date);

            var fileToCreate = _mapper.Map <LessonFile>(lessonFile);

            fileToCreate.LessonInHistoryId = lessonInHistory.LessonInHistoryId;

            _uow.LessonFileRepository.Add(fileToCreate);
            return(await _uow.SaveChanges());
        }
Example #2
0
        public async Task <bool> PostLessonInformation(int lessonId, DateTime date, LessonInforamtionDto informationDto)
        {
            LessonInHistory lessonInHistory = await GetOrCreateLessonInHistory(lessonId, date);

            var inforamtionToCreate = _mapper.Map <LessonInformation>(informationDto);

            inforamtionToCreate.LessonInHistoryId = lessonInHistory.LessonInHistoryId;

            _uow.LessonInformationRepository.Add(inforamtionToCreate);
            return(await _uow.SaveChanges());
        }
Example #3
0
        private async Task <LessonInHistory> GetOrCreateLessonInHistory(int lessonId, DateTime date)
        {
            LessonInHistory lessonInHistory = await _uow.lessonInHistoryRepository.GetByLessonIdAndDate(lessonId, date);

            if (lessonInHistory == null)
            {
                lessonInHistory = new LessonInHistory()
                {
                    lesson_date = date,
                    lesson_id   = lessonId
                };
                _uow.lessonInHistoryRepository.Add(lessonInHistory);
                await _uow.SaveChanges();
            }
            return(lessonInHistory);
        }