Esempio n. 1
0
        /// <summary>
        /// Обновляет заявление о согласии на зачисление
        /// </summary>
        /// <param name="consentToEnrollment"></param>
        /// <param name="uploadedFile"></param>
        /// <returns></returns>
        public async Task UpdateConsentToEnrollmentAsync(ConsentToEnrollment consentToEnrollment, IFormFile uploadedFile)
        {
            if (consentToEnrollment == null)
            {
                return;
            }

            if (uploadedFile != null)                        //Если пользователь загрузил новый файл
            {
                if (consentToEnrollment.FileModelId == null) //Если ранее загруженный файл отсутствует, создаём новую файловую модель
                {
                    var newFileModel = await _fileModelRepository.UploadConsentToEnrollmentFileAsync(uploadedFile);

                    consentToEnrollment.FileModelId = newFileModel.Id;
                }
                else//Иначе заменяем имеющуюся модель на новую
                {
                    if (consentToEnrollment.FileModel == null)
                    {
                        await _fileModelRepository.ReloadFileAsync(consentToEnrollment.FileModelId, uploadedFile);
                    }
                    else
                    {
                        await _fileModelRepository.ReloadFileAsync(consentToEnrollment.FileModel, uploadedFile);
                    }
                }
            }

            _context.ConsentToEnrollments.Update(consentToEnrollment);
            await _context.SaveChangesAsync();
        }
Esempio n. 2
0
        /// <summary>
        /// Создание заявления о согласии на зачисление
        /// </summary>
        /// <param name="admissionPrivilege"></param>
        /// <param name="uploadedFile"></param>
        /// <returns></returns>
        public async Task CreateConsentToEnrollmentAsync(ConsentToEnrollment consentToEnrollment,
                                                         IFormFile uploadedFile)
        {
            if (consentToEnrollment == null)
            {
                return;
            }
            if (uploadedFile == null)
            {
                return;
            }

            var fileModel = await _fileModelRepository.UploadConsentToEnrollmentFileAsync(uploadedFile);

            if (fileModel == null)
            {
                return;
            }

            consentToEnrollment.FileModelId = fileModel.Id;

            if (consentToEnrollment.RowStatusId == 0)
            {
                consentToEnrollment.RowStatusId = (int)RowStatusEnum.NotConfirmed;
            }



            _context.ConsentToEnrollments.Add(consentToEnrollment);
            await _context.SaveChangesAsync();
        }
Esempio n. 3
0
        /// <summary>
        /// Удаляет заявление о согласии на зачисление
        /// </summary>
        public async Task RemoveConsentToEnrollmentAsync(ConsentToEnrollment consentToEnrollment)
        {
            if (consentToEnrollment == null)
            {
                return;
            }

            if (consentToEnrollment.FileModelId != null)
            {
                if (consentToEnrollment.FileModel != null)
                {
                    await _fileModelRepository.RemoveFileModelAsync(consentToEnrollment.FileModel);
                }
                else
                {
                    await _fileModelRepository.RemoveFileAsync(consentToEnrollment.FileModelId);
                }
            }

            _context.ConsentToEnrollments.Remove(consentToEnrollment);
            await _context.SaveChangesAsync();
        }