예제 #1
0
        /// <summary>
        /// Обновляет вариант ответа
        /// </summary>
        /// <param name="lmsTaskAnswer"></param>
        /// <param name="uploadedFile"></param>
        /// <returns></returns>
        public async Task UpdateLmsTaskAnswer(LmsTaskAnswer lmsTaskAnswer, IFormFile uploadedFile)
        {
            if (uploadedFile != null)
            {
                if (lmsTaskAnswer.FileModelId != null)
                {
                    if (lmsTaskAnswer.FileModel == null)
                    {
                        lmsTaskAnswer.FileModel = await _fileModelRepository.GetFileModelAsync(lmsTaskAnswer.FileModelId);
                    }

                    await _fileModelRepository.ReloadFileAsync(lmsTaskAnswer.FileModel, uploadedFile);
                }
                else
                {
                    FileModel newFileModel = await _fileModelRepository.UploadLmsTaskAnswerJpg(uploadedFile);

                    if (newFileModel == null)
                    {
                        return;
                    }
                    lmsTaskAnswer.FileModelId = newFileModel.Id;
                }
            }

            _context.LmsTaskAnswers.Update(lmsTaskAnswer);
            await _context.SaveChangesAsync();
        }
예제 #2
0
        /// <summary>
        /// Добавляет к заданию СДО вариант ответа
        /// </summary>
        /// <param name="lmsTaskAnswer"></param>
        /// <param name="uploadedFile"></param>
        /// <returns></returns>
        public async Task AddLmsTaskAnswer(LmsTaskAnswer lmsTaskAnswer, IFormFile uploadedFile)
        {
            if (uploadedFile != null)
            {
                var newFileModel = await _fileModelRepository.UploadLmsTaskAnswerJpg(uploadedFile);

                if (newFileModel != null)
                {
                    lmsTaskAnswer.FileModel   = newFileModel;
                    lmsTaskAnswer.FileModelId = newFileModel.Id;
                }
            }

            _context.LmsTaskAnswers.Add(lmsTaskAnswer);
            await _context.SaveChangesAsync();
        }