public async Task <IActionResult> DeleteConfirmed(int id, int?StructFacultetId)
        {
            var studentGroup = await _context.StudentGroups
                               .Include(sg => sg.Vedomosti)
                               .ThenInclude(v => v.VedomostStudentMarks)
                               .Include(sg => sg.Students)
                               .ThenInclude(sgs => sgs.RezultOsvoenObrazovatProgr)
                               .SingleOrDefaultAsync(sg => sg.StudentGroupId == id);

            foreach (var student in studentGroup.Students)
            {
                await _fileModelRepository.RemoveFileModelAsync(student.RezultOsvoenObrazovatProgr);
            }

            _context.StudentGroups.Remove(studentGroup);
            await _context.SaveChangesAsync();

            if (StructFacultetId != null)
            {
                return(RedirectToAction(nameof(StudentGroupsOfFacultet), new { StructFacultetId }));
            }
            else
            {
                return(RedirectToAction(nameof(Index)));
            }
        }
Exemple #2
0
        /// <summary>
        /// Удаляет заявления о приёме
        /// </summary>
        /// <param name="applicationForAdmissions"></param>
        /// <returns></returns>
        public async Task RemoveApplicationForAdmissionsAsync(List <ApplicationForAdmission> applicationForAdmissions)
        {
            if (applicationForAdmissions != null && applicationForAdmissions.Count() > 0)
            {
                foreach (var applicationForAdmission in applicationForAdmissions)
                {
                    if (applicationForAdmission.FileModelId != null)
                    {
                        await _fileModelRepository.RemoveFileModelAsync(applicationForAdmission.FileModel);
                    }
                }

                _context.ApplicationForAdmissions.RemoveRange(applicationForAdmissions);
                await _context.SaveChangesAsync();
            }
        }
Exemple #3
0
        /// <summary>
        /// Удаляет бланк или пример заполнения документа
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task RemoveDocumentSampleAsync(int id)
        {
            var documentSample = await GetDocumentSampleAsync(id);

            if (documentSample == null)
            {
                return;
            }

            if (documentSample.FileModel != null)
            {
                await _fileModelRepository.RemoveFileModelAsync(documentSample.FileModel);
            }

            _context.DocumentSamples.Remove(documentSample);
            await _context.SaveChangesAsync();
        }
        /// <summary>
        /// Удаляет статью пользователя userName
        /// </summary>
        /// <param name="articleId"></param>
        /// <param name="userName"></param>
        /// <returns></returns>
        public Article RemoveArticle(int articleId, string userName)
        {
            var article = GetArticle(articleId, userName);

            if (article == null)
            {
                return(null);
            }

            _context.Articles.Remove(article);
            if (article.FileModel != null)
            {
                _fileModelRepository.RemoveFileModelAsync(article.FileModel);
            }
            _context.SaveChanges();

            return(article);
        }
        /// <summary>
        /// Удаляет заявление об отзыве документов абитуриента
        /// </summary>
        /// <param name="revocationStatement"></param>
        /// <returns></returns>
        public async Task RemoveRevocationStatementAsync(RevocationStatement revocationStatement)
        {
            _context.RevocationStatements.Remove(revocationStatement);

            if (revocationStatement.FileModel != null)
            {
                await _fileModelRepository.RemoveFileModelAsync(revocationStatement.FileModel);
            }

            await _context.SaveChangesAsync();
        }
        /// <summary>
        /// Удаляет научную статью по её УИД
        /// </summary>
        /// <param name="articleId">УИД статьи</param>
        public async Task RemoveArticleAsync(int articleId)
        {
            var article = GetArticle(articleId);

            _context.Articles.Remove(article);
            if (article.FileModel != null)
            {
                await _fileModelRepository.RemoveFileModelAsync(article.FileModel);
            }
            _context.SaveChanges();
        }
Exemple #7
0
        /// <summary>
        /// Удаляет индивидуальное достижение абитуриента
        /// </summary>
        /// <param name="abiturientIndividualAchievmentId"></param>
        /// <returns></returns>
        public async Task Remove(int abiturientIndividualAchievmentId)
        {
            var entry = await GetAbiturientIndividualAchievmentAsync(abiturientIndividualAchievmentId);

            if (entry.FileModel != null)
            {
                await _fileModelRepository.RemoveFileModelAsync(entry.FileModel);
            }

            _context.AbiturientIndividualAchievments.Remove(entry);
            await _context.SaveChangesAsync();
        }
Exemple #8
0
        //[ValidateAntiForgeryToken]
        public async Task <IActionResult> Delete(int?id, FileDataTypeEnum?doctype)
        {
            if (id != null)
            {
                var fileModel = await _fileModelRepository.GetFileModelAsync(id);

                await _fileModelRepository.RemoveFileModelAsync(fileModel);

                //KisVuzDotNetCore2.Models.Files.Files.RemoveFile(_context, _appEnvironment, id);
                await _context.SaveChangesAsync();
            }

            return(RedirectToAction(nameof(Index), new { doctype }));
        }
Exemple #9
0
        /// <summary>
        /// Удаляет файлы работ пользователей, загруженные до указанной даты
        /// </summary>
        /// <param name="date"></param>
        /// <returns></returns>
        public async Task RemoveUserWorksToDateAsync(DateTime date)
        {
            var userWorksToDelete = await _context.UserWorks
                                    .Include(uw => uw.FileModel)
                                    .Where(uw => uw.FileModelId != null)
                                    .Where(uw => uw.FileModel.UploadDate <= date)
                                    .Take(1000)
                                    .ToListAsync();

            foreach (var userWork in userWorksToDelete)
            {
                await _fileModelRepository.RemoveFileModelAsync(userWork.FileModel);
            }
        }
Exemple #10
0
        /// <summary>
        /// Удаляет задание СДО
        /// </summary>
        /// <param name="lmsTask"></param>
        /// <returns></returns>
        public async Task RemoveLmsTaskAsync(LmsTask lmsTask)
        {
            if (lmsTask.LmsTaskAnswers != null)
            {
                foreach (var lmsTaskAnswer in lmsTask.LmsTaskAnswers)
                {
                    if (lmsTaskAnswer.FileModelId != null)
                    {
                        if (lmsTaskAnswer.FileModel != null)
                        {
                            await _fileModelRepository.RemoveFileModelAsync(lmsTaskAnswer.FileModel);
                        }
                        else
                        {
                            await _fileModelRepository.RemoveFileAsync(lmsTaskAnswer.FileModelId);
                        }
                    }
                }
            }


            if (lmsTask.LmsTaskJpgId != null)
            {
                if (lmsTask.LmsTaskJpg != null)
                {
                    await _fileModelRepository.RemoveFileModelAsync(lmsTask.LmsTaskJpg);
                }
                else
                {
                    await _fileModelRepository.RemoveFileAsync(lmsTask.LmsTaskJpgId);
                }
            }

            _context.LmsTasks.Remove(lmsTask);
            await _context.SaveChangesAsync();
        }
        /// <summary>
        /// Удаляет монографию
        /// </summary>
        /// <param name="monografId"></param>
        public void RemoveMonografAsync(int monografId)
        {
            var monograf = GetMonograf(monografId);

            if (monograf == null)
            {
                return;
            }
            _context.Monografs.Remove(monograf);
            if (monograf.FileModel != null)
            {
                _fileModelRepository.RemoveFileModelAsync(monograf.FileModel);
            }
            _context.SaveChanges();
        }
        /// <summary>
        /// Удаляет патент (свидетельство) по УИД
        /// </summary>
        /// <param name="patentId"></param>
        /// <returns></returns>
        public async Task <Patent> RemovePatentAsync(int patentId)
        {
            var patent = GetPatent(patentId);

            if (patent == null)
            {
                return(null);
            }

            _context.Patents.Remove(patent);
            if (patent.FileModelId != null)
            {
                await _fileModelRepository.RemoveFileModelAsync(patent.FileModel);
            }
            _context.SaveChanges();

            return(patent);
        }
        /// <summary>
        /// Удаляет договор
        /// </summary>
        /// <param name="contract"></param>
        /// <returns></returns>
        public async Task RemoveContractAsync(Contract contract)
        {
            if (contract == null)
            {
                return;
            }

            if (contract.FileModelId != null)
            {
                if (contract.FileModel == null)
                {
                    var entryFileModel = await _fileModelRepository.GetFileModelAsync(contract.FileModelId);

                    contract.FileModel = entryFileModel;
                }
                await _fileModelRepository.RemoveFileModelAsync(contract.FileModel);
            }

            _context.Contracts.Remove(contract);
            await _context.SaveChangesAsync();
        }
        /// <summary>
        /// Удаляет учебное пособие
        /// </summary>
        /// <param name="uchPosobie"></param>
        /// <returns></returns>
        public async Task RemoveUchPosobieAsync(UchPosobie uchPosobie)
        {
            if (uchPosobie == null)
            {
                return;
            }

            //if(uchPosobie.EduForms!=null)
            //{
            //    _context.RemoveRange(uchPosobie.EduForms);
            //}
            _context.Remove(uchPosobie);
            await _context.SaveChangesAsync();

            if (uchPosobie.FileModel != null)
            {
                await _fileModelRepository.RemoveFileModelAsync(uchPosobie.FileModel);

                await _context.SaveChangesAsync();
            }
        }
Exemple #15
0
        /// <summary>
        /// Удаляет льготу абитуриента при поступлении
        /// </summary>
        /// <param name="admissionPrivilegeId"></param>
        /// <returns></returns>
        public async Task RemoveAdmissionPrivilegeAsync(AdmissionPrivilege admissionPrivilege)
        {
            if (admissionPrivilege == null)
            {
                return;
            }

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

            _context.AdmissionPrivileges.Remove(admissionPrivilege);
            await _context.SaveChangesAsync();
        }
Exemple #16
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();
        }