public async Task <IActionResult> Edit(int id, [Bind("InstituteLinkId,StructInstituteId,LinkTypeId,InstituteLinkLink,InstituteLinkDescription")] InstituteLink instituteLink)
        {
            if (id != instituteLink.InstituteLinkId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(instituteLink);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!InstituteLinkExists(instituteLink.InstituteLinkId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["LinkTypeId"]        = new SelectList(_context.LinkTypes, "LinkTypeId", "LinkTypeName", instituteLink.LinkTypeId);
            ViewData["StructInstituteId"] = new SelectList(_context.StructInstitutes, "StructInstituteId", "StructInstituteName", instituteLink.StructInstituteId);
            return(View(instituteLink));
        }
        public async Task <IActionResult> Create([Bind("InstituteLinkId,StructInstituteId,LinkTypeId,InstituteLinkLink,InstituteLinkDescription")] InstituteLink instituteLink)
        {
            if (ModelState.IsValid)
            {
                _context.Add(instituteLink);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["LinkTypeId"]        = new SelectList(_context.LinkTypes, "LinkTypeId", "LinkTypeName", instituteLink.LinkTypeId);
            ViewData["StructInstituteId"] = new SelectList(_context.StructInstitutes, "StructInstituteId", "StructInstituteName", instituteLink.StructInstituteId);
            return(View(instituteLink));
        }
        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
            }
        }