/// <summary>
        /// Инициализация таблицы "Регионы"
        /// </summary>
        /// <param name="serviceProvider"></param>
        /// <param name="configuration"></param>
        /// <returns></returns>
        public static async Task CreateRegions(IServiceProvider serviceProvider, IConfiguration configuration)
        {
            using (var serviceScope = serviceProvider.GetRequiredService<Microsoft.Extensions.DependencyInjection.IServiceScopeFactory>().CreateScope())
            {
                AppIdentityDBContext context = serviceScope.ServiceProvider.GetService<AppIdentityDBContext>();

                #region Инициализация таблицы "Регионы"
                if (!await context.Regions.AnyAsync())
                {
                    var row01 = new Region
                    {
                        RegionId = (int)RegionsEnum.RostovskayaOblast,
                        RegionName = "Ростовская область",
                        CountryId = (int)CountriesEnum.Russia
                    };

                    var row02 = new Region
                    {
                        RegionId = (int)RegionsEnum.KrasnodarskiyKray,
                        RegionName = "Краснодарский край",
                        CountryId = (int)CountriesEnum.Russia
                    };

                    var row03 = new Region
                    {
                        RegionId = (int)RegionsEnum.StavropolskiyKray,
                        RegionName = "Ставропольский край",
                        CountryId = (int)CountriesEnum.Russia
                    };


                    await context.Regions.AddRangeAsync(
                        row01,
                        row02,
                        row03
                    );
                    await context.SaveChangesAsync();
                }
                #endregion
            }
        }
        /// <summary>
        /// Создаёт ЭЦП для всех неподписанных документов
        /// </summary>
        /// <returns></returns>
        public async Task <int> CreateSignForUnsignedDocuments()
        {
            //var unsignedDocs = await _context.Files
            //    .Include(f => f.FileToFileTypes)
            //        .ThenInclude(ftft=>ftft.FileDataType)
            //    .Include(f => f.SignList)
            //    .Where(f => f.SignList == null || f.SignList.Count == 0)
            //    .Take(1000)
            //    .ToListAsync();
            var unsignedDocs = await _context.FileToFileTypes
                               .Include(ftft => ftft.FileDataType)
                               .Include(ftft => ftft.FileModel.SignList)
                               .Where(ftft => ftft.FileDataType.FileDataTypeGroupId == 1 ||
                                      ftft.FileDataType.FileDataTypeGroupId == 2 ||
                                      ftft.FileDataType.FileDataTypeGroupId == 3)
                               .Select(ftft => ftft.FileModel)
                               .ToListAsync();

            int counter = 0;

            foreach (var unsignedDoc in unsignedDocs)
            {
                if (unsignedDoc.SignList == null)
                {
                    unsignedDoc.SignList = new List <Sign>();
                }

                if (unsignedDoc.SignList.Count == 0)
                {
                    string newKey  = Guid.NewGuid().ToString().Replace("-", "");
                    Sign   newSign = new Sign {
                        LastName = "Бутенко", FirstName = "Александр", Patronymic = "Фёдорович", Post = "Директор", Key = newKey
                    };
                    unsignedDoc.SignList.Add(newSign);

                    counter++;
                    await _context.SaveChangesAsync();
                }
            }
            return(counter);
        }
        /// <summary>
        /// Загружает на сервер согласие на обработку персональных данных и
        /// создаёт соответствующую запись в таблице UserDocuments
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="uploadedFile"></param>
        /// <returns></returns>
        public async Task <UserDocument> CreateApplicationForProcessingPersonalDataAsync(string userName, IFormFile uploadedFile)
        {
            var userId    = _userProfileRepository.GetAppUserId(userName);
            var fileModel = await _fileModelRepository.UploadApplicationForProcessingPersonalDataAsync(uploadedFile);

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

            var userDocument = new UserDocument
            {
                AppUserId      = userId,
                FileModelId    = fileModel.Id,
                FileDataTypeId = (int)FileDataTypeEnum.SoglasieNaObrabotkuPersonalnihDannih
            };

            await _context.AddAsync(userDocument);

            await _context.SaveChangesAsync();

            return(userDocument);
        }
Exemple #4
0
        /// <summary>
        /// Инициализация таблицы "База данных электронного каталога"
        /// </summary>
        /// <param name="serviceProvider"></param>
        /// <param name="configuration"></param>
        /// <returns></returns>
        public static async Task CreateElectronCatalog(IServiceProvider serviceProvider, IConfiguration configuration)
        {
            using (var serviceScope = serviceProvider.GetRequiredService <IServiceScopeFactory>().CreateScope())
            {
                AppIdentityDBContext context = serviceScope.ServiceProvider.GetService <AppIdentityDBContext>();

                #region Инициализация таблицы "База данных электронного каталога"
                if (!await context.ElectronCatalog.AnyAsync())
                {
                    ElectronCatalog Ec1 = new ElectronCatalog
                    {
                        NameEc        = "Электронный каталог \"MarcSQL\"",
                        DescriptionEc = "Электронный каталог \"MarcSQL\" содержит информацию о учебниках, учебных изданиях и другой литературе, поступившей в библиотеку института, начиная с 1999 года. Электронный каталог удобен для поиска информации."
                    };

                    await context.ElectronCatalog.AddAsync(Ec1);

                    await context.SaveChangesAsync();
                }
                #endregion
            }
        }
        /// <summary>
        /// Инициализация таблицы "Типы образовательных организаций"
        /// </summary>
        /// <param name="serviceProvider"></param>
        /// <param name="configuration"></param>
        /// <returns></returns>
        public static async Task CreateEducationalInstitutionTypes(IServiceProvider serviceProvider, IConfiguration configuration)
        {
            using (var serviceScope = serviceProvider.GetRequiredService <IServiceScopeFactory>().CreateScope())
            {
                AppIdentityDBContext context = serviceScope.ServiceProvider.GetService <AppIdentityDBContext>();

                #region Инициализация таблицы "Типы образовательных организаций"
                if (!await context.EducationalInstitutionTypes.AnyAsync())
                {
                    EducationalInstitutionType EducationalInstitutionType1 = new EducationalInstitutionType
                    {
                        EducationalInstitutionTypeId   = (int)EducationalInstitutionTypeEnum.ObsheobrazovatelnayaOrganizaciya,
                        EducationalInstitutionTypeName = "Общеобразовательная организация"
                    };

                    EducationalInstitutionType EducationalInstitutionType2 = new EducationalInstitutionType
                    {
                        EducationalInstitutionTypeId   = (int)EducationalInstitutionTypeEnum.ProfessionalnayaObrazovatelnayaOrganizaciya,
                        EducationalInstitutionTypeName = "Профессиональная образовательная организация"
                    };

                    EducationalInstitutionType EducationalInstitutionType3 = new EducationalInstitutionType
                    {
                        EducationalInstitutionTypeId   = (int)EducationalInstitutionTypeEnum.ObrazovatelnayaOrganizaciyaVisshegoObrazovaniya,
                        EducationalInstitutionTypeName = "Образовательная организация высшего образования"
                    };

                    await context.EducationalInstitutionTypes.AddRangeAsync(
                        EducationalInstitutionType1,
                        EducationalInstitutionType2,
                        EducationalInstitutionType3
                        );

                    await context.SaveChangesAsync();
                }
                #endregion
            }
        }
Exemple #6
0
        /// <summary>
        /// Инициализация таблицы "Статусы пользователей"
        /// </summary>
        /// <param name="serviceProvider"></param>
        /// <param name="configuration"></param>
        /// <returns></returns>
        public static async Task CreateAppUserStatuses(IServiceProvider serviceProvider, IConfiguration configuration)
        {
            using (var serviceScope = serviceProvider.GetRequiredService <IServiceScopeFactory>().CreateScope())
            {
                AppIdentityDBContext context = serviceScope.ServiceProvider.GetService <AppIdentityDBContext>();

                #region Инициализация таблицы "Статусы пользователей"
                if (!await context.AppUserStatuses.AnyAsync())
                {
                    var AppUserStatus1 = new AppUserStatus
                    {
                        AppUserStatusId   = (int)AppUserStatusEnum.NewUser,
                        AppUserStatusName = "Новый пользователь"
                    };

                    var AppUserStatus2 = new AppUserStatus
                    {
                        AppUserStatusId   = (int)AppUserStatusEnum.ConfirmedUser,
                        AppUserStatusName = "Подтверждённый пользователь"
                    };

                    var AppUserStatus3 = new AppUserStatus
                    {
                        AppUserStatusId   = (int)AppUserStatusEnum.ToDelete,
                        AppUserStatusName = "Пользователь, помеченный к удалению"
                    };

                    await context.AppUserStatuses.AddRangeAsync(
                        AppUserStatus1,
                        AppUserStatus2,
                        AppUserStatus3
                        );

                    await context.SaveChangesAsync();
                }
                #endregion
            }
        }
        /// <summary>
        /// Инициализация таблицы "Год выпуска"
        /// </summary>
        /// <param name="serviceProvider"></param>
        /// <param name="configuration"></param>
        /// <returns></returns>
        public static async Task CreateGraduateYear(IServiceProvider serviceProvider, IConfiguration configuration)
        {
            using (var serviceScope = serviceProvider.GetRequiredService <Microsoft.Extensions.DependencyInjection.IServiceScopeFactory>().CreateScope())
            {
                AppIdentityDBContext context = serviceScope.ServiceProvider.GetService <AppIdentityDBContext>();

                #region Инициализация таблицы "Срок Обучения"
                if (!await context.GraduateYear.AnyAsync())
                {
                    GraduateYear GraduateYear1 = new GraduateYear
                    {
                        GraduateYearId   = 1,
                        GraduateYearName = "2016 год"
                    };

                    GraduateYear GraduateYear2 = new GraduateYear
                    {
                        GraduateYearId   = 2,
                        GraduateYearName = "2017 год"
                    };

                    GraduateYear GraduateYear3 = new GraduateYear
                    {
                        GraduateYearId   = 3,
                        GraduateYearName = "2018 год"
                    };

                    await context.GraduateYear.AddRangeAsync(
                        GraduateYear1,
                        GraduateYear2,
                        GraduateYear3
                        );

                    await context.SaveChangesAsync();
                }
                #endregion
            }
        }
        /// <summary>
        /// Инициализация таблицы "Авторы"
        /// </summary>
        /// <param name="serviceProvider"></param>
        /// <param name="configuration"></param>
        /// <returns></returns>
        public static async Task CreateAuthor(IServiceProvider serviceProvider, IConfiguration configuration)
        {
            using (var serviceScope = serviceProvider.GetRequiredService <IServiceScopeFactory>().CreateScope())
            {
                AppIdentityDBContext context = serviceScope.ServiceProvider.GetService <AppIdentityDBContext>();

                #region Инициализация таблицы "Авторы"
                if (!await context.Author.AnyAsync())
                {
                    Author AuthorName1 = new Author
                    {
                        AuthorId   = 1,
                        AuthorName = "Литвинов В.Н.",
                    };

                    Author AuthorName2 = new Author
                    {
                        AuthorId   = 2,
                        AuthorName = "Грачева Н.Н.",
                    };

                    Author AuthorName3 = new Author
                    {
                        AuthorId   = 3,
                        AuthorName = "Руденко Н.Б.",
                    };

                    await context.Author.AddRangeAsync(
                        AuthorName1,
                        AuthorName2,
                        AuthorName3
                        );

                    await context.SaveChangesAsync();
                }
                #endregion
            }
        }
Exemple #9
0
        /// <summary>
        /// Инициализация таблицы "Иностранные языки"
        /// </summary>
        /// <param name="serviceProvider"></param>
        /// <param name="configuration"></param>
        /// <returns></returns>
        public static async Task CreateForeignLanguages(IServiceProvider serviceProvider, IConfiguration configuration)
        {
            using (var serviceScope = serviceProvider.GetRequiredService <IServiceScopeFactory>().CreateScope())
            {
                AppIdentityDBContext context = serviceScope.ServiceProvider.GetService <AppIdentityDBContext>();

                #region Инициализация таблицы "Иностранные языки"
                if (!await context.ForeignLanguages.AnyAsync())
                {
                    var Row01 = new ForeignLanguage
                    {
                        ForeignLanguageId   = 1,
                        ForeignLanguageName = "Английский"
                    };

                    var Row02 = new ForeignLanguage
                    {
                        ForeignLanguageId   = 2,
                        ForeignLanguageName = "Немецкий"
                    };

                    var Row03 = new ForeignLanguage
                    {
                        ForeignLanguageId   = 3,
                        ForeignLanguageName = "Французский"
                    };

                    await context.ForeignLanguages.AddRangeAsync(
                        Row01,
                        Row02,
                        Row03
                        );

                    await context.SaveChangesAsync();
                }
                #endregion
            }
        }
        /// <summary>
        /// Инициализация таблицы "Типы пользовательских сообщений"
        /// </summary>
        /// <param name="serviceProvider"></param>
        /// <param name="configuration"></param>
        /// <returns></returns>
        public static async Task CreateUserMessageTypes(IServiceProvider serviceProvider, IConfiguration configuration)
        {
            using (var serviceScope = serviceProvider.GetRequiredService <Microsoft.Extensions.DependencyInjection.IServiceScopeFactory>().CreateScope())
            {
                AppIdentityDBContext context = serviceScope.ServiceProvider.GetService <AppIdentityDBContext>();

                #region Инициализация таблицы "Типы пользовательских сообщений"
                if (!await context.UserMessageTypes.AnyAsync())
                {
                    var mt01 = new UserMessageType
                    {
                        UserMessageTypeId   = 1,
                        UserMessageTypeName = "Простое сообщение"
                    };

                    var mt02 = new UserMessageType
                    {
                        UserMessageTypeId   = 2,
                        UserMessageTypeName = "Информирование"
                    };

                    var mt03 = new UserMessageType
                    {
                        UserMessageTypeId   = 3,
                        UserMessageTypeName = "Задание по дисциплине"
                    };

                    await context.UserMessageTypes.AddRangeAsync(
                        mt01,
                        mt02,
                        mt03
                        );

                    await context.SaveChangesAsync();
                }
                #endregion
            }
        }
Exemple #11
0
        /// <summary>
        /// Добавляет новое задание в базу заданий СДО
        /// </summary>
        /// <param name="lmsTask"></param>
        /// <param name="uploadedFile"></param>
        /// <returns></returns>
        public async Task AddLmsTask(LmsTask lmsTask, IFormFile uploadedFile)
        {
            if (lmsTask == null)
            {
                return;
            }

            if (uploadedFile != null)
            {
                FileModel newFileModel = await _fileModelRepository.UploadLmsTaskJpg(uploadedFile);

                if (newFileModel == null)
                {
                    return;
                }
                lmsTask.LmsTaskJpgId = newFileModel.Id;
            }

            _context.LmsTasks.Add(lmsTask);
            await _context.SaveChangesAsync();
        }
        /// <summary>
        /// Инициализация таблицы "Корпус"
        /// </summary>
        /// <param name="serviceProvider"></param>
        /// <param name="configuration"></param>
        /// <returns></returns>
        public static async Task CreatePomeshenieType(IServiceProvider serviceProvider, IConfiguration configuration)
        {
            using (var serviceScope = serviceProvider.GetRequiredService <Microsoft.Extensions.DependencyInjection.IServiceScopeFactory>().CreateScope())
            {
                AppIdentityDBContext context = serviceScope.ServiceProvider.GetService <AppIdentityDBContext>();

                #region Инициализация таблицы "Тип помещения (справочник)"
                if (!await context.PomeshenieType.AnyAsync())
                {
                    PomeshenieType PomeshenieTypeName1 = new PomeshenieType
                    {
                        PomeshenieTypeId   = 1,
                        PomeshenieTypeName = "Учебная аудитория",
                    };

                    PomeshenieType PomeshenieTypeName2 = new PomeshenieType
                    {
                        PomeshenieTypeId   = 2,
                        PomeshenieTypeName = "Лекционная аудитория",
                    };

                    PomeshenieType PomeshenieTypeName3 = new PomeshenieType
                    {
                        PomeshenieTypeId   = 3,
                        PomeshenieTypeName = "Аудитория для самостоятельной работы студентов",
                    };

                    await context.PomeshenieType.AddRangeAsync(
                        PomeshenieTypeName1,
                        PomeshenieTypeName2,
                        PomeshenieTypeName3
                        );

                    await context.SaveChangesAsync();
                }
                #endregion
            }
        }
        internal static async Task CreateInstituteLinks(IServiceProvider serviceProvider, IConfiguration configuration)
        {
            using (var serviceScope = serviceProvider.GetRequiredService <IServiceScopeFactory>().CreateScope())
            {
                AppIdentityDBContext context = serviceScope.ServiceProvider.GetService <AppIdentityDBContext>();

                #region Инициализация таблицы "Дисциплины"
                if (!await context.InstituteLinks.AnyAsync())
                {
                    InstituteLink InstituteLink1 = new InstituteLink
                    {
                        InstituteLinkId          = 1,
                        InstituteLinkDescription = "Официальный веб-сайт",
                        LinkTypeId        = (int)LinkTypesEnum.OfficialWebSite,
                        InstituteLinkLink = "ачгаа.рф",
                        StructInstituteId = 1
                    };

                    InstituteLink InstituteLink2 = new InstituteLink
                    {
                        InstituteLinkId          = 2,
                        InstituteLinkDescription = "Ссылка на информацию, размещаемую на сайте http://bus.gov.ru",
                        LinkTypeId        = (int)LinkTypesEnum.BusGovRu,
                        InstituteLinkLink = "http://bus.gov.ru/pub/agency/485942/register-info",
                        StructInstituteId = 1
                    };

                    await context.InstituteLinks.AddRangeAsync(
                        InstituteLink1,
                        InstituteLink2
                        );

                    await context.SaveChangesAsync();
                }
                #endregion
            }
        }
        public async Task <IActionResult> Create([Bind("ProfessionalRetrainingId,ProfessionalRetrainingDiplomRegNumber,ProfessionalRetrainingDiplomNumber,ProfessionalRetrainingProgramName,ProfessionalRetrainingHours,ProfessionalRetrainingCity,ProfessionalRetrainingInstitition,ProfessionalRetrainingDateStart,ProfessionalRetrainingDateFinish,ProfessionalRetrainingDateIssue,AppUserId")] ProfessionalRetraining professionalRetraining,
                                                 IFormFile uploadedFile)
        {
            if (ModelState.IsValid && uploadedFile != null)
            {
                FileModel fileModel = await KisVuzDotNetCore2.Models.Files.Files.LoadFile(_context, _appEnvironment, uploadedFile, "Диплом о профессиональной переподготовке", FileDataTypeEnum.DiplomOProfessionalnoyPerepodgotovke);

                professionalRetraining.ProfessionalRetrainingFileId = fileModel.Id;
                professionalRetraining.RowStatusId = (int)RowStatusEnum.NotConfirmed;
                _context.Add(professionalRetraining);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index), new { id = professionalRetraining.AppUserId }));
            }

            ViewBag.AppUserId = professionalRetraining.AppUserId;
            return(View(professionalRetraining));
        }
        public async Task <IActionResult> Create([Bind("RefresherCourseId,RefresherCourseRegNumber,RefresherCourseName,RefresherCourseHours,RefresherCourseCity,RefresherCourseInstitition,RefresherCourseDateStart,RefresherCourseDateFinish,RefresherCourseDateIssue,AppUserId")] RefresherCourse refresherCourse,
                                                 IFormFile uploadedFile)
        {
            if (ModelState.IsValid && uploadedFile != null)
            {
                FileModel fileModel = await KisVuzDotNetCore2.Models.Files.Files.LoadFile(_context, _appEnvironment, uploadedFile, "Удостоверение о повышении квалификации", FileDataTypeEnum.UdostoverenieOPovisheniiKvalifikacii);

                refresherCourse.RefresherCourseFileId = fileModel.Id;
                refresherCourse.RowStatusId           = (int)RowStatusEnum.NotConfirmed;
                _context.Add(refresherCourse);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index), new { id = refresherCourse.AppUserId }));
            }

            ViewBag.AppUserId = refresherCourse.AppUserId;
            return(View(refresherCourse));
        }
        /// <summary>
        /// Инициализация таблицы "Страны"
        /// </summary>
        /// <param name="serviceProvider"></param>
        /// <param name="configuration"></param>
        /// <returns></returns>
        public static async Task CreateCountries(IServiceProvider serviceProvider, IConfiguration configuration)
        {
            using (var serviceScope = serviceProvider.GetRequiredService<Microsoft.Extensions.DependencyInjection.IServiceScopeFactory>().CreateScope())
            {
                AppIdentityDBContext context = serviceScope.ServiceProvider.GetService<AppIdentityDBContext>();

                #region Инициализация таблицы "Страны"
                if (!await context.Countries.AnyAsync())
                {
                    var country01 = new Country
                    {
                        CountryId = (int)CountriesEnum.Russia,
                        CountryName = "Россия"
                    };
                    

                    await context.Countries.AddRangeAsync(
                        country01
                    );
                    await context.SaveChangesAsync();
                }
                #endregion
            }
        }
Exemple #17
0
        /// <summary>
        /// Инициализация таблицы "Типы работ пользователя (курсовые, ВКР, эссе и пр.)"
        /// </summary>
        /// <param name="serviceProvider"></param>
        /// <param name="configuration"></param>
        /// <returns></returns>
        internal static async Task CreateUserWorkType(IServiceProvider serviceProvider, IConfiguration configuration)
        {
            using (var serviceScope = serviceProvider.GetRequiredService <IServiceScopeFactory>().CreateScope())
            {
                AppIdentityDBContext context = serviceScope.ServiceProvider.GetService <AppIdentityDBContext>();

                #region Инициализация таблицы "Типы работ пользователя (курсовые, ВКР, эссе и пр.)"
                if (!await context.UserWorkTypes.AnyAsync())
                {
                    var items = new List <UserWorkType>();
                    items.Add(new UserWorkType
                    {
                        UserWorkTypeId   = (int)UserWorkTypeEnum.Esse,
                        UserWorkTypeName = "Эссе"
                    });

                    items.Add(new UserWorkType
                    {
                        UserWorkTypeId   = (int)UserWorkTypeEnum.Referat,
                        UserWorkTypeName = "Реферат"
                    });

                    items.Add(new UserWorkType
                    {
                        UserWorkTypeId   = (int)UserWorkTypeEnum.Sochinenie,
                        UserWorkTypeName = "Сочинение"
                    });

                    items.Add(new UserWorkType
                    {
                        UserWorkTypeId   = (int)UserWorkTypeEnum.Perevod,
                        UserWorkTypeName = "Перевод текста с иностранного языка / на иностранный язык"
                    });

                    items.Add(new UserWorkType
                    {
                        UserWorkTypeId   = (int)UserWorkTypeEnum.OtchetLabRabota,
                        UserWorkTypeName = "Отчет по лабораторной работе"
                    });

                    items.Add(new UserWorkType
                    {
                        UserWorkTypeId   = (int)UserWorkTypeEnum.OtchetPractica,
                        UserWorkTypeName = "Отчет по практике"
                    });

                    items.Add(new UserWorkType
                    {
                        UserWorkTypeId   = (int)UserWorkTypeEnum.OtchetSamostRabota,
                        UserWorkTypeName = "Отчет по самостоятельной работе"
                    });

                    items.Add(new UserWorkType
                    {
                        UserWorkTypeId   = (int)UserWorkTypeEnum.KursRabota,
                        UserWorkTypeName = "Курсовая работа"
                    });

                    items.Add(new UserWorkType
                    {
                        UserWorkTypeId   = (int)UserWorkTypeEnum.KursProekt,
                        UserWorkTypeName = "Курсовой проект"
                    });

                    items.Add(new UserWorkType
                    {
                        UserWorkTypeId   = (int)UserWorkTypeEnum.VKR,
                        UserWorkTypeName = "Выпускная квалификационная работа"
                    });

                    items.Add(new UserWorkType
                    {
                        UserWorkTypeId   = (int)UserWorkTypeEnum.Other,
                        UserWorkTypeName = "Другое"
                    });

                    await context.UserWorkTypes.AddRangeAsync(items);

                    await context.SaveChangesAsync();
                }
                #endregion
            }
        }
 /// <summary>
 /// Удаляет запись, связывающую направление подготовки, форму обучения и нормативный срок обучения
 /// </summary>
 /// <param name="eduNapravlEduFormEduSrok"></param>
 /// <returns></returns>
 public async Task RemoveEduNapravlEduFormEduSrokAsync(EduNapravlEduFormEduSrok eduNapravlEduFormEduSrok)
 {
     _context.EduNapravlEduFormEduSroks.Remove(eduNapravlEduFormEduSrok);
     await _context.SaveChangesAsync();
 }
        /// <summary>
        /// Обновляет учебное пособие
        /// </summary>
        /// <param name="uchPosobieEditViewModel"></param>
        /// <returns></returns>
        public async Task UpdateUchPosobie(UchPosobieEditViewModel uchPosobieEditViewModel)
        {
            if (uchPosobieEditViewModel == null)
            {
                return;
            }

            if (uchPosobieEditViewModel.FormFile != null)
            {
                FileDataTypeEnum fileDataTypeEnum = await GetFileDataTypeEnumByUchPosobieVidId(uchPosobieEditViewModel.UchPosobie.UchPosobieVidId);

                var fileModel = await _fileModelRepository.UploadUchPosobieAsync(uchPosobieEditViewModel.FormFile, fileDataTypeEnum);

                if (fileModel != null)                                                                              //Если новый файл успешно загружен
                {
                    if (uchPosobieEditViewModel.UchPosobie.FileModelId != 0)                                        // и при этом ранее уже был загружен другой файл
                    {
                        await _fileModelRepository.RemoveFileAsync(uchPosobieEditViewModel.UchPosobie.FileModelId); // Удаляем старый файл
                    }
                }

                uchPosobieEditViewModel.UchPosobie.FileModelId = fileModel.Id;
            }

            _context.UchPosobie.Update(uchPosobieEditViewModel.UchPosobie);
            try
            {
                // Attempt to save changes to the database
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException ex)
            {
                foreach (var entry in ex.Entries)
                {
                    if (entry.Entity is UchPosobie)
                    {
                        var proposedValues = entry.CurrentValues;
                        var databaseValues = entry.GetDatabaseValues();

                        foreach (var property in proposedValues.Properties)
                        {
                            var proposedValue = proposedValues[property];
                            var databaseValue = databaseValues[property];

                            // TODO: decide which value should be written to database
                            proposedValues[property] = proposedValue;
                        }

                        // Refresh original values to bypass next concurrency check
                        entry.OriginalValues.SetValues(databaseValues);
                        await _context.SaveChangesAsync();
                    }
                    else
                    {
                        throw new NotSupportedException(
                                  "Don't know how to handle concurrency conflicts for "
                                  + entry.Metadata.Name);
                    }
                }
            }
        }
Exemple #20
0
        /// <summary>
        /// Инициализация таблицы "Дисциплины"
        /// </summary>
        /// <param name="serviceProvider"></param>
        /// <param name="configuration"></param>
        /// <returns></returns>
        public static async Task CreateDisciplineName(IServiceProvider serviceProvider, IConfiguration configuration)
        {
            using (var serviceScope = serviceProvider.GetRequiredService <IServiceScopeFactory>().CreateScope())
            {
                AppIdentityDBContext context = serviceScope.ServiceProvider.GetService <AppIdentityDBContext>();

                #region Инициализация таблицы "Дисциплины"
                if (!await context.DisciplineNames.AnyAsync())
                {
                    DisciplineName DisciplineName1 = new DisciplineName
                    {
                        DisciplineNameId   = 1,
                        DisciplineNameName = "Иностранный язык"
                    };

                    DisciplineName DisciplineName2 = new DisciplineName
                    {
                        DisciplineNameId   = 2,
                        DisciplineNameName = "Философия"
                    };

                    DisciplineName DisciplineName3 = new DisciplineName
                    {
                        DisciplineNameId   = 3,
                        DisciplineNameName = "История"
                    };

                    DisciplineName DisciplineName4 = new DisciplineName
                    {
                        DisciplineNameId   = 4,
                        DisciplineNameName = "Математика"
                    };

                    DisciplineName DisciplineName5 = new DisciplineName
                    {
                        DisciplineNameId   = 5,
                        DisciplineNameName = "Информатика"
                    };

                    DisciplineName DisciplineName6 = new DisciplineName
                    {
                        DisciplineNameId   = 6,
                        DisciplineNameName = "Физика"
                    };

                    DisciplineName DisciplineName7 = new DisciplineName
                    {
                        DisciplineNameId   = 7,
                        DisciplineNameName = "Химия"
                    };

                    DisciplineName DisciplineName8 = new DisciplineName
                    {
                        DisciplineNameId   = 8,
                        DisciplineNameName = "Начертательная геометрия. Инженерная графика"
                    };

                    DisciplineName DisciplineName9 = new DisciplineName
                    {
                        DisciplineNameId   = 9,
                        DisciplineNameName = "Физическая культура"
                    };

                    await context.DisciplineNames.AddRangeAsync(
                        DisciplineName1,
                        DisciplineName2,
                        DisciplineName3,
                        DisciplineName4,
                        DisciplineName5,
                        DisciplineName6,
                        DisciplineName7,
                        DisciplineName8,
                        DisciplineName9
                        );

                    await context.SaveChangesAsync();
                }
                #endregion
            }
        }
        /// <summary>
        /// Инициализация таблицы "Статусы абитуриентов"
        /// </summary>
        /// <param name="serviceProvider"></param>
        /// <param name="configuration"></param>
        /// <returns></returns>
        public static async Task CreateAbiturientStatuses(IServiceProvider serviceProvider, IConfiguration configuration)
        {
            using (var serviceScope = serviceProvider.GetRequiredService <IServiceScopeFactory>().CreateScope())
            {
                AppIdentityDBContext context = serviceScope.ServiceProvider.GetService <AppIdentityDBContext>();

                #region Инициализация таблицы "Статусы абитуриентов"
                if (!await context.AbiturientStatuses.AnyAsync())
                {
                    var row01 = new AbiturientStatus
                    {
                        AbiturientStatusId   = (int)AbiturientStatusEnum.NewAbiturient,
                        AbiturientStatusName = "Новый абитуриент"
                    };

                    var row02 = new AbiturientStatus
                    {
                        AbiturientStatusId   = (int)AbiturientStatusEnum.ConfirmedAbiturient,
                        AbiturientStatusName = "Подтверждённый абитуриент"
                    };

                    var row03 = new AbiturientStatus
                    {
                        AbiturientStatusId   = (int)AbiturientStatusEnum.Zachislenie,
                        AbiturientStatusName = "К зачислению"
                    };

                    var row04 = new AbiturientStatus
                    {
                        AbiturientStatusId   = (int)AbiturientStatusEnum.VObrabotke,
                        AbiturientStatusName = "В обработке"
                    };

                    var row05 = new AbiturientStatus
                    {
                        AbiturientStatusId   = (int)AbiturientStatusEnum.KEkzamenam,
                        AbiturientStatusName = "Экзамен"
                    };

                    var row06 = new AbiturientStatus
                    {
                        AbiturientStatusId   = (int)AbiturientStatusEnum.AddedToStudGroup,
                        AbiturientStatusName = "Экзамен дистанционно"
                    };

                    var row07 = new AbiturientStatus
                    {
                        AbiturientStatusId   = (int)AbiturientStatusEnum.AddedToStudGroup,
                        AbiturientStatusName = "Зачислен и добавлен в студенческую группу"
                    };

                    await context.AbiturientStatuses.AddRangeAsync(
                        row01,
                        row02,
                        row03,
                        row04,
                        row05,
                        row06,
                        row07
                        );

                    await context.SaveChangesAsync();
                }
                #endregion
            }
        }
        /// <summary>
        /// Инициализация таблицы "Виды деятельности по учебному плану"
        /// </summary>
        /// <param name="serviceProvider"></param>
        /// <param name="configuration"></param>
        /// <returns></returns>
        public static async Task CreateEduVidDeyats(IServiceProvider serviceProvider, IConfiguration configuration)
        {
            using (var serviceScope = serviceProvider.GetRequiredService <IServiceScopeFactory>().CreateScope())
            {
                AppIdentityDBContext context = serviceScope.ServiceProvider.GetService <AppIdentityDBContext>();

                #region Инициализация таблицы "Виды деятельности по учебному плану"
                if (!await context.EduVidDeyat.AnyAsync())
                {
                    EduVidDeyat EduVidDeyat1 = new EduVidDeyat
                    {
                        EduVidDeyatId   = 1,
                        EduVidDeyatName = "Монтажно-наладочная"
                    };

                    EduVidDeyat EduVidDeyat2 = new EduVidDeyat
                    {
                        EduVidDeyatId   = 2,
                        EduVidDeyatName = "Научно-исследовательская"
                    };

                    EduVidDeyat EduVidDeyat3 = new EduVidDeyat
                    {
                        EduVidDeyatId   = 3,
                        EduVidDeyatName = "Организационно-управленческая"
                    };

                    EduVidDeyat EduVidDeyat4 = new EduVidDeyat
                    {
                        EduVidDeyatId   = 4,
                        EduVidDeyatName = "Проектно-конструкторская"
                    };

                    EduVidDeyat EduVidDeyat5 = new EduVidDeyat
                    {
                        EduVidDeyatId   = 5,
                        EduVidDeyatName = "Производственно-технологическая"
                    };

                    EduVidDeyat EduVidDeyat6 = new EduVidDeyat
                    {
                        EduVidDeyatId   = 6,
                        EduVidDeyatName = "Расчетно-проектная и проектно-конструкторская"
                    };

                    EduVidDeyat EduVidDeyat7 = new EduVidDeyat
                    {
                        EduVidDeyatId   = 7,
                        EduVidDeyatName = "Сервисно-эксплуатационная"
                    };

                    EduVidDeyat EduVidDeyat8 = new EduVidDeyat
                    {
                        EduVidDeyatId   = 8,
                        EduVidDeyatName = "Экспертная, надзорная и инспекционно-аудиторская"
                    };

                    await context.EduVidDeyat.AddRangeAsync(
                        EduVidDeyat1,
                        EduVidDeyat2,
                        EduVidDeyat3,
                        EduVidDeyat4,
                        EduVidDeyat5,
                        EduVidDeyat6,
                        EduVidDeyat7,
                        EduVidDeyat8
                        );

                    await context.SaveChangesAsync();
                }
                #endregion
            }
        }
Exemple #23
0
 /// <summary>
 /// Добавляет сведения об образовании пользователя
 /// </summary>
 /// <param name="userEducation"></param>
 /// <returns></returns>
 public async Task AddUserEducationAsync(UserEducation userEducation)
 {
     _context.UserEducations.Add(userEducation);
     await _context.SaveChangesAsync();
 }
        /// <summary>
        /// Инициализация таблицы "Руководство"
        /// </summary>
        /// <param name="serviceProvider"></param>
        /// <param name="configuration"></param>
        /// <returns></returns>
        public static async Task CreateRucovodstvo(IServiceProvider serviceProvider, IConfiguration configuration)
        {
            using (var serviceScope = serviceProvider.GetRequiredService <IServiceScopeFactory>().CreateScope())
            {
                AppIdentityDBContext context = serviceScope.ServiceProvider.GetService <AppIdentityDBContext>();

                #region Инициализация таблицы "Руководство"
                if (!await context.SvedenRucovodstvo.AnyAsync())
                {
                    Rucovodstvo SvedenRucovodstvo1 = new Rucovodstvo
                    {
                        Fio       = "Серегин Александр Анатольевич",
                        Post      = "Директор",
                        Telephone = "8(86359) 41-7-43",
                        Email     = "*****@*****.**"
                    };

                    Rucovodstvo SvedenRucovodstvo2 = new Rucovodstvo
                    {
                        Fio       = "Глечикова Наталья Александровна",
                        Post      = "И.о. зам. директора по учебной работе",
                        Telephone = "8(86359) 42-1-76",
                        Email     = "*****@*****.**"
                    };

                    Rucovodstvo SvedenRucovodstvo3 = new Rucovodstvo
                    {
                        Fio       = "Юдаев Игорь Викторович",
                        Post      = "Зам. директора по научной работе",
                        Telephone = "8(86359) 41-1-61",
                        Email     = "*****@*****.**"
                    };

                    Rucovodstvo SvedenRucovodstvo4 = new Rucovodstvo
                    {
                        Fio       = "Джанибеков Казбек Алиевич",
                        Post      = "Зам. директора по административно-хозяйственной работе",
                        Telephone = "8(86359) 42-7-81",
                        Email     = "*****@*****.**"
                    };

                    Rucovodstvo SvedenRucovodstvo5 = new Rucovodstvo
                    {
                        Fio       = "Асатурян Сергей Вартанович",
                        Post      = "И.о. зам. директора по воспитательной работе",
                        Telephone = "8(86359) 43-3-49",
                        Email     = "*****@*****.**"
                    };

                    Rucovodstvo SvedenRucovodstvo6 = new Rucovodstvo
                    {
                        Fio       = "Кабанов Александр Николаевич",
                        Post      = "И.о. зам. директора по социальной работе",
                        Telephone = "8(86359) 34-6-12",
                        Email     = "*****@*****.**"
                    };

                    Rucovodstvo SvedenRucovodstvo7 = new Rucovodstvo
                    {
                        Fio       = "Бондаренко Анатолий Михайлович",
                        Post      = "И.о. зам. директора по связям с общественностью",
                        Telephone = "8(86359) 41-3-65",
                        Email     = "*****@*****.**"
                    };

                    Rucovodstvo SvedenRucovodstvo8 = new Rucovodstvo
                    {
                        Fio       = "Меркулов Александр Филиппович",
                        Post      = "Директор агротехнологического центра",
                        Telephone = "8(86359) 34-7-32",
                        Email     = "*****@*****.**"
                    };
                    await context.SvedenRucovodstvo.AddRangeAsync(
                        SvedenRucovodstvo1,
                        SvedenRucovodstvo2,
                        SvedenRucovodstvo3,
                        SvedenRucovodstvo4,
                        SvedenRucovodstvo5,
                        SvedenRucovodstvo6,
                        SvedenRucovodstvo7,
                        SvedenRucovodstvo8
                        );

                    await context.SaveChangesAsync();
                }
                #endregion
            }
        }
Exemple #25
0
        /// <summary>
        /// Инициализация таблицы "Срок Обучения"
        /// </summary>
        /// <param name="serviceProvider"></param>
        /// <param name="configuration"></param>
        /// <returns></returns>
        public static async Task CreateEduSrok(IServiceProvider serviceProvider, IConfiguration configuration)
        {
            using (var serviceScope = serviceProvider.GetRequiredService <Microsoft.Extensions.DependencyInjection.IServiceScopeFactory>().CreateScope())
            {
                AppIdentityDBContext context = serviceScope.ServiceProvider.GetService <AppIdentityDBContext>();

                #region Инициализация таблицы "Срок Обучения"
                if (!await context.EduSrok.AnyAsync())
                {
                    EduSrok EduSrok1 = new EduSrok
                    {
                        EduSrokId   = 1,
                        EduSrokName = "1 год 10 месяцев"
                    };

                    EduSrok EduSrok2 = new EduSrok
                    {
                        EduSrokId   = 2,
                        EduSrokName = "2 года"
                    };

                    EduSrok EduSrok3 = new EduSrok
                    {
                        EduSrokId   = 3,
                        EduSrokName = "2 года 6 месяцев"
                    };

                    EduSrok EduSrok4 = new EduSrok
                    {
                        EduSrokId   = 4,
                        EduSrokName = "2 года 10 месяцев"
                    };

                    EduSrok EduSrok5 = new EduSrok
                    {
                        EduSrokId   = 5,
                        EduSrokName = "3 года"
                    };

                    EduSrok EduSrok6 = new EduSrok
                    {
                        EduSrokId   = 6,
                        EduSrokName = "3 года 10 месяцев"
                    };

                    EduSrok EduSrok7 = new EduSrok
                    {
                        EduSrokId   = 7,
                        EduSrokName = "4 года"
                    };

                    EduSrok EduSrok8 = new EduSrok
                    {
                        EduSrokId   = 8,
                        EduSrokName = "5 лет"
                    };

                    await context.EduSrok.AddRangeAsync(
                        EduSrok1,
                        EduSrok2,
                        EduSrok3,
                        EduSrok4,
                        EduSrok5,
                        EduSrok6,
                        EduSrok7,
                        EduSrok8
                        );

                    await context.SaveChangesAsync();
                }
                #endregion
            }
        }
 /// <summary>
 /// Устанавливает статус пользователя
 /// </summary>
 /// <param name="appUser"></param>
 /// <param name="appUserStatusEnum"></param>
 /// <returns></returns>
 public async Task SetAppUserStatusAsync(AppUser appUser, AppUserStatusEnum appUserStatusEnum)
 {
     appUser.AppUserStatusId = (int)appUserStatusEnum;
     await _context.SaveChangesAsync();
 }
Exemple #27
0
        /// <summary>
        /// Инициализация таблиц, связанных с пользователем
        /// </summary>
        /// <param name="serviceProvider"></param>
        /// <param name="configuration"></param>
        /// <returns></returns>
        public static async Task CreateUserData(IServiceProvider serviceProvider, IConfiguration configuration)
        {
            using (var serviceScope = serviceProvider.GetRequiredService <IServiceScopeFactory>().CreateScope())
            {
                AppIdentityDBContext context = serviceScope.ServiceProvider.GetService <AppIdentityDBContext>();

                #region Инициализация таблицы "Группы ученых степеней"
                if (!await context.AcademicDegreeGroups.AnyAsync())
                {
                    AcademicDegreeGroup AcademicDegreeGroup1 = new AcademicDegreeGroup
                    {
                        AcademicDegreeGroupId   = 1,
                        AcademicDegreeGroupName = "Кандидаты наук"
                    };

                    AcademicDegreeGroup AcademicDegreeGroup2 = new AcademicDegreeGroup
                    {
                        AcademicDegreeGroupId   = 2,
                        AcademicDegreeGroupName = "Доктора наук"
                    };

                    await context.AcademicDegreeGroups.AddRangeAsync(
                        AcademicDegreeGroup1,
                        AcademicDegreeGroup2
                        );

                    await context.SaveChangesAsync();
                }
                #endregion

                #region Инициализация таблицы "Ученые степени"
                if (!await context.AcademicDegrees.AnyAsync())
                {
                    AcademicDegree AcademicDegree1 = new AcademicDegree
                    {
                        AcademicDegreeId      = 1,
                        AcademicDegreeGroupId = 1,
                        AcademicDegreeName    = "Кандидат технических наук"
                    };

                    AcademicDegree AcademicDegree2 = new AcademicDegree
                    {
                        AcademicDegreeId      = 2,
                        AcademicDegreeGroupId = 1,
                        AcademicDegreeName    = "Кандидат сельскохозяйственных наук"
                    };

                    AcademicDegree AcademicDegree3 = new AcademicDegree
                    {
                        AcademicDegreeId      = 3,
                        AcademicDegreeGroupId = 2,
                        AcademicDegreeName    = "Доктор технических наук"
                    };

                    AcademicDegree AcademicDegree4 = new AcademicDegree
                    {
                        AcademicDegreeId      = 4,
                        AcademicDegreeGroupId = 2,
                        AcademicDegreeName    = "Доктор сельскохозяйственных наук"
                    };

                    await context.AcademicDegrees.AddRangeAsync(
                        AcademicDegree1,
                        AcademicDegree2,
                        AcademicDegree3,
                        AcademicDegree4
                        );

                    await context.SaveChangesAsync();
                }
                #endregion

                #region Инициализация таблицы "Ученые звания"
                if (!await context.AcademicStats.AnyAsync())
                {
                    AcademicStat AcademicStat1 = new AcademicStat
                    {
                        AcademicStatId   = 1,
                        AcademicStatName = "Доцент"
                    };

                    AcademicStat AcademicStat2 = new AcademicStat
                    {
                        AcademicStatId   = 2,
                        AcademicStatName = "Профессор"
                    };

                    await context.AcademicStats.AddRangeAsync(
                        AcademicStat1,
                        AcademicStat2
                        );

                    await context.SaveChangesAsync();
                }
                #endregion
            }
        }
        /// <summary>
        /// Добавление нового или обновление существующего учебного плана
        /// </summary>
        /// <param name="eduPlan"></param>
        /// <param name="uploadedFile"></param>
        /// <param name="eduVidDeyatIds"></param>
        /// <param name="eduYearBeginningTrainingIds"></param>
        /// <param name="eduPlanEduYearIds"></param>
        /// <returns></returns>
        public async Task <EduPlan> CreateEduPlan(EduPlan eduPlan,
                                                  IFormFile uploadedFile,
                                                  int[] eduVidDeyatIds,
                                                  int[] eduYearBeginningTrainingIds,
                                                  int[] eduPlanEduYearIds)
        {
            if (eduPlan.EduPlanId == 0)
            {
                _context.Add(eduPlan);
            }
            else
            {
                EduPlan eduPlanDbEntry = await GetEduPlanAsync(eduPlan.EduPlanId);

                eduPlanDbEntry.EduFormId      = eduPlan.EduFormId;
                eduPlanDbEntry.EduSrokId      = eduPlan.EduSrokId;
                eduPlanDbEntry.StructKafId    = eduPlan.StructKafId;
                eduPlanDbEntry.ProtokolNumber = eduPlan.ProtokolNumber;
                eduPlanDbEntry.ProtokolDate   = eduPlan.ProtokolDate;
                eduPlanDbEntry.UtverjdDate    = eduPlan.UtverjdDate;
                _context.Update(eduPlanDbEntry);
                eduPlan = eduPlanDbEntry;
            }

            await _context.SaveChangesAsync();

            if (uploadedFile != null)
            {
                FileModel fileModel = await Files.Files.LoadFile(_context, _appEnvironment, uploadedFile, "Учебный план", FileDataTypeEnum.UchebniyPlan);

                await _context.SaveChangesAsync();

                int?fileToRemoveId = eduPlan.EduPlanPdfId;
                eduPlan.EduPlanPdfId = fileModel.Id;
                await _context.SaveChangesAsync();

                Files.Files.RemoveFile(_context, _appEnvironment, fileToRemoveId);
            }

            try
            {
                if (eduVidDeyatIds != null)
                {
                    _context.EduPlanEduVidDeyats.RemoveRange(_context.EduPlanEduVidDeyats.Where(v => v.EduPlanId == eduPlan.EduPlanId));
                    await _context.SaveChangesAsync();

                    var eduPlanEduVidDeyats = new List <EduPlanEduVidDeyat>();
                    foreach (var EduVidDeyatId in eduVidDeyatIds)
                    {
                        EduPlanEduVidDeyat eduPlanEduVidDeyat = new EduPlanEduVidDeyat();
                        eduPlanEduVidDeyat.EduPlanId     = eduPlan.EduPlanId;
                        eduPlanEduVidDeyat.EduVidDeyatId = EduVidDeyatId;
                        eduPlanEduVidDeyats.Add(eduPlanEduVidDeyat);
                    }
                    await _context.EduPlanEduVidDeyats.AddRangeAsync(eduPlanEduVidDeyats);

                    await _context.SaveChangesAsync();
                }

                if (eduYearBeginningTrainingIds != null)
                {
                    _context.EduPlanEduYearBeginningTraining.RemoveRange(_context.EduPlanEduYearBeginningTraining.Where(y => y.EduPlanId == eduPlan.EduPlanId));
                    await _context.SaveChangesAsync();

                    var eduPlanEduYearBeginningTrainings = new List <EduPlanEduYearBeginningTraining>();
                    foreach (var EduYearBeginningTrainingId in eduYearBeginningTrainingIds)
                    {
                        EduPlanEduYearBeginningTraining eduPlanEduYearBeginningTraining = new EduPlanEduYearBeginningTraining();
                        eduPlanEduYearBeginningTraining.EduPlanId = eduPlan.EduPlanId;
                        eduPlanEduYearBeginningTraining.EduYearBeginningTrainingId = EduYearBeginningTrainingId;
                        eduPlanEduYearBeginningTrainings.Add(eduPlanEduYearBeginningTraining);
                    }
                    await _context.EduPlanEduYearBeginningTraining.AddRangeAsync(eduPlanEduYearBeginningTrainings);

                    await _context.SaveChangesAsync();
                }

                if (eduPlanEduYearIds != null)
                {
                    if (eduPlan.EduPlanEduYears == null)
                    {
                        eduPlan.EduPlanEduYears = new List <EduPlanEduYear>();
                    }

                    foreach (var eduYearIdByUser in eduPlanEduYearIds)
                    {
                        bool isNeedAdd = true;
                        foreach (var item in eduPlan.EduPlanEduYears)
                        {
                            if (item.EduYearId == eduYearIdByUser)
                            {
                                isNeedAdd = false;
                            }
                        }

                        if (isNeedAdd)
                        {
                            eduPlan.EduPlanEduYears.Add(new EduPlanEduYear {
                                EduYearId = eduYearIdByUser, EduPlanId = eduPlan.EduPlanId
                            });
                            await _context.SaveChangesAsync();
                        }
                    }

                    var eduPlanEduYearEntriesToRemove = new List <EduPlanEduYear>();
                    foreach (var eduPlanEduYearEntry in eduPlan.EduPlanEduYears)
                    {
                        bool isNeedRemove = true;
                        foreach (var eduYearIdByUser in eduPlanEduYearIds)
                        {
                            if (eduYearIdByUser == eduPlanEduYearEntry.EduYearId)
                            {
                                isNeedRemove = false;
                            }
                        }

                        if (isNeedRemove)
                        {
                            eduPlanEduYearEntriesToRemove.Add(eduPlanEduYearEntry);
                        }
                    }
                    foreach (var removingItem in eduPlanEduYearEntriesToRemove)
                    {
                        eduPlan.EduPlanEduYears.Remove(removingItem);
                    }
                    await _context.SaveChangesAsync();
                }
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
            }

            return(eduPlan);
        }
Exemple #29
0
        public async Task <IActionResult> Create(EduPlan eduPlan, IFormFile uploadedFile, int[] EduVidDeyatIds, int[] EduYearBeginningTrainingIds, int[] EduPlanEduYearIds)
        {
            if (ModelState.IsValid && uploadedFile != null)
            {
                FileModel fileModel = await KisVuzDotNetCore2.Models.Files.Files.LoadFile(_context, _appEnvironment, uploadedFile, "Учебный план", FileDataTypeEnum.UchebniyPlan);

                eduPlan.EduPlanPdfId = fileModel.Id;
                _context.EduPlans.Add(eduPlan);
                await _context.SaveChangesAsync();

                if (EduVidDeyatIds != null)
                {
                    var eduPlanEduVidDeyats = new List <EduPlanEduVidDeyat>();
                    foreach (var EduVidDeyatId in EduVidDeyatIds)
                    {
                        EduPlanEduVidDeyat eduPlanEduVidDeyat = new EduPlanEduVidDeyat();
                        eduPlanEduVidDeyat.EduPlanId     = eduPlan.EduPlanId;
                        eduPlanEduVidDeyat.EduVidDeyatId = EduVidDeyatId;
                        eduPlanEduVidDeyats.Add(eduPlanEduVidDeyat);
                    }
                    await _context.EduPlanEduVidDeyats.AddRangeAsync(eduPlanEduVidDeyats);

                    await _context.SaveChangesAsync();
                }

                if (EduYearBeginningTrainingIds != null)
                {
                    var eduPlanEduYearBeginningTrainings = new List <EduPlanEduYearBeginningTraining>();
                    foreach (var EduYearBeginningTrainingId in EduYearBeginningTrainingIds)
                    {
                        EduPlanEduYearBeginningTraining eduPlanEduYearBeginningTraining = new EduPlanEduYearBeginningTraining();
                        eduPlanEduYearBeginningTraining.EduPlanId = eduPlan.EduPlanId;
                        eduPlanEduYearBeginningTraining.EduYearBeginningTrainingId = EduYearBeginningTrainingId;
                        eduPlanEduYearBeginningTrainings.Add(eduPlanEduYearBeginningTraining);
                    }
                    await _context.EduPlanEduYearBeginningTraining.AddRangeAsync(eduPlanEduYearBeginningTrainings);

                    await _context.SaveChangesAsync();
                }

                if (EduPlanEduYearIds != null)
                {
                    var eduPlanEduYears = new List <EduPlanEduYear>();
                    foreach (var EduPlanEduYearId in EduPlanEduYearIds)
                    {
                        EduPlanEduYear eduPlanEduYear = new EduPlanEduYear();
                        eduPlanEduYear.EduPlanId = eduPlan.EduPlanId;
                        eduPlanEduYear.EduYearId = EduPlanEduYearId;
                        eduPlanEduYears.Add(eduPlanEduYear);
                    }
                    await _context.EduPlanEduYears.AddRangeAsync(eduPlanEduYears);

                    await _context.SaveChangesAsync();
                }


                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EduFormId"]        = new SelectList(_context.EduForms, "EduFormId", "EduFormName", eduPlan.EduFormId);
            ViewData["EduProfileId"]     = new SelectList(_context.EduProfiles.Include(p => p.EduNapravl.EduUgs.EduLevel), "EduProfileId", "GetEduProfileFullName", eduPlan.EduProfileId);
            ViewData["EduProgramPodgId"] = new SelectList(_context.EduProgramPodg, "EduProgramPodgId", "EduProgramPodgName", eduPlan.EduProgramPodgId);
            ViewData["EduSrokId"]        = new SelectList(_context.EduSrok, "EduSrokId", "EduSrokName", eduPlan.EduSrokId);
            ViewData["StructKafId"]      = new SelectList(_context.StructKafs.Include(k => k.StructSubvision), "StructKafId", "StructSubvision.StructSubvisionName", eduPlan.StructKafId);

            List <EduVidDeyat> eduVidDeyats = _context.EduVidDeyat.ToList();

            ViewData["EduVidDeyats"] = eduVidDeyats;

            List <EduYearBeginningTraining> eduYearBeginningTrainings = _context.EduYearBeginningTrainings.ToList();

            ViewData["EduYearBeginningTrainings"] = eduYearBeginningTrainings;

            List <EduYear> eduYears = _context.EduYears.ToList();

            ViewData["EduYears"] = eduYears;

            return(View(eduPlan));
        }
Exemple #30
0
 /// <summary>
 /// Обновляет заявление о зачислении
 /// </summary>
 /// <param name="applicationForAdmission"></param>
 /// <returns></returns>
 public async Task UpdateApplicationForAdmissionAsync(ApplicationForAdmission applicationForAdmission)
 {
     _context.ApplicationForAdmissions.Update(applicationForAdmission);
     await _context.SaveChangesAsync();
 }