コード例 #1
0
        private async Task HandleUploadedFileAndItemFilePath(UpdateCourseItemByTeacherCommand request, CourseItem item)
        {
            if (request.File != null)
            {
                _coursesFileManager.DeleteFile(item.FilePath);
                var course = _courseRepository.GetQueryable().Include(x => x.Teacher).First(x => x.Id == request.Id);
                await _coursesFileManager.SaveFile(request.File, course.Teacher.UserName, item.CourseId);

                item.FilePath =
                    _coursesFileManager.GetFilePathForDownload(request.File, course.Teacher.UserName, item.CourseId);
                item.ContentType = GetContentType(request.File.ContentType);
            }
        }
コード例 #2
0
        private async Task HandleUploadedFileAndItemFilePath(EditCourseItemCommand request, CourseItem item)
        {
            if (request.File != null)
            {
                if (File.Exists(item.FilePath))
                {
                    _coursesFileManager.DeleteFile(item.FilePath);
                }
                var course = _courseRepo.GetQueryable().Include(x => x.Teacher)
                             .First(x => x.Contents.Any(c => c.Id == request.Id));
                await _coursesFileManager.SaveFile(request.File, course.Teacher.UserName, item.CourseId);

                item.FilePath = _coursesFileManager.GetFilePathForDownload(request.File, course.Teacher.UserName, item.CourseId);
            }
        }