Example #1
0
        /// <summary>
        /// Обновляет индивидуальное достижение абитуриента
        /// </summary>
        /// <param name="abiturientIndividualAchievment"></param>
        /// <returns></returns>
        public async Task Update(AbiturientIndividualAchievment abiturientIndividualAchievment,
                                 IFormFile uploadedFile)
        {
            if (uploadedFile != null)
            {
                if (abiturientIndividualAchievment.FileModelId != null)
                {
                    if (abiturientIndividualAchievment.FileModel == null)
                    {
                        var entryFileModel = await _fileModelRepository.GetFileModelAsync(abiturientIndividualAchievment.FileModelId);

                        abiturientIndividualAchievment.FileModel = entryFileModel;
                    }

                    await _fileModelRepository.ReloadFileAsync(abiturientIndividualAchievment.FileModel, uploadedFile);
                }
                else
                {
                    var loadedFileModel = await _fileModelRepository.UploadIndividualAchievmentFile(uploadedFile);

                    abiturientIndividualAchievment.FileModel   = loadedFileModel;
                    abiturientIndividualAchievment.FileModelId = loadedFileModel.Id;
                }
            }

            _context.AbiturientIndividualAchievments.Update(abiturientIndividualAchievment);
            await _context.SaveChangesAsync();
        }
Example #2
0
        /// <summary>
        /// Создаёт индивидуальное достижение абитуриента
        /// </summary>
        /// <param name="abiturientIndividualAchievment"></param>
        /// <param name="uploadedFile"></param>
        /// <returns></returns>
        public async Task Create(AbiturientIndividualAchievment abiturientIndividualAchievment, IFormFile uploadedFile)
        {
            if (uploadedFile != null)
            {
                var loadedFileModel = await _fileModelRepository.UploadIndividualAchievmentFile(uploadedFile);

                abiturientIndividualAchievment.FileModel   = loadedFileModel;
                abiturientIndividualAchievment.FileModelId = loadedFileModel.Id;
            }

            _context.AbiturientIndividualAchievments.Add(abiturientIndividualAchievment);
            await _context.SaveChangesAsync();
        }