コード例 #1
0
        public async Task <IActionResult> Edit(int id, int universityId, [Bind("Id,Name,Info,UniversityId")] Faculties faculties)
        {
            if (id != faculties.Id)
            {
                return(NotFound());
            }
            ViewBag.UniversityId = universityId;

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(faculties);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FacultiesExists(faculties.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index", "Faculties", new { id = universityId }));
            }
            ViewData["UniversityId"] = new SelectList(_context.Universities, "Id", "Name", faculties.UniversityId);
            //return View(faculties);
            return(RedirectToAction("Index", "Faculties", new { id = universityId }));
        }
コード例 #2
0
        public async Task <IActionResult> Edit(int id, int countryId, [Bind("Id,Name,CountryId")] Universities universities)
        {
            if (id != universities.Id)
            {
                return(NotFound());
            }
            ViewBag.CountryId = countryId;

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(universities);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UniversitiesExists(universities.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                //return RedirectToAction(nameof(Index));
                return(RedirectToAction("Index", "Universities", new { id = countryId }));
            }
            ViewData["CountryId"] = new SelectList(_context.Countries, "Id", "Name", universities.CountryId);
            //return View(universities);
            return(RedirectToAction("Index", "Universities", new { id = countryId }));
        }
コード例 #3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Countries countries)
        {
            if (id != countries.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(countries);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CountriesExists(countries.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(countries));
        }
コード例 #4
0
        public async Task <IActionResult> Edit(int id, int facultyId, [Bind("Id,EducationalProgId,FacultyId")] FacultyEducationalProg facultyEducationalProg)
        {
            if (id != facultyEducationalProg.Id)
            {
                return(NotFound());
            }
            ViewBag.FacultyId         = facultyId;
            ViewBag.EducationalProgId = facultyEducationalProg.EducationalProgId;

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(facultyEducationalProg);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FacultyEducationalProgExists(facultyEducationalProg.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                //return RedirectToAction(nameof(Index));
                return(RedirectToAction("Index", "FacultyEducationalProgs", new { id = facultyId }));
            }
            ViewData["EducationalProgId"] = new SelectList(_context.EducationalProg, "Id", "Name", facultyEducationalProg.EducationalProgId);
            ViewData["FacultyId"]         = new SelectList(_context.Faculties, "Id", "Name", facultyEducationalProg.FacultyId);
            //return View(facultyEducationalProg);
            return(RedirectToAction("Index", "FacultyEducationalProgs", new { id = facultyId }));
        }
コード例 #5
0
        public async Task <IActionResult> Edit(int id, int?specialtiesId, [Bind("Id,Name,SpecialtiesId,Price")] EducationalProg educationalProg)
        {
            if (id != educationalProg.Id)
            {
                return(NotFound());
            }

            ViewBag.SpecialtiesId = specialtiesId;
            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(educationalProg);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EducationalProgExists(educationalProg.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index", "EducationalProgs", new { id = specialtiesId }));
            }
            ViewData["SpecialtiesId"] = new SelectList(_context.Specialties, "Id", "Name", educationalProg.SpecialtiesId);
            //return View(educationalProg);
            return(RedirectToAction("Index", "EducationalProgs", new { id = specialtiesId }));
        }