Example #1
0
        public async Task <IActionResult> AddLessonFile(int lessonId, DateTime date, [FromBody] LessonFileDto lessonFile)
        {
            var result = await _lessonService.PostLessonFile(lessonId, date, lessonFile);

            if (result)
            {
                return(StatusCode(201));
            }
            return(BadRequest("Fail to create lesson file"));
        }
Example #2
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());
        }