public async Task <IActionResult> Create([Bind("Id,Name")] Countries countries) { if (ModelState.IsValid) { _context.Add(countries); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(countries)); }
public async Task <IActionResult> Create(int universityId, [Bind("Id,Name,Info,UniversityId")] Faculties faculties) { faculties.UniversityId = universityId; if (ModelState.IsValid) { _context.Add(faculties); await _context.SaveChangesAsync(); //return RedirectToAction(nameof(Index)); return(RedirectToAction("Index", "Faculties", new { id = universityId, name = _context.Universities.Where(x => x.Id == universityId).FirstOrDefault().Name })); } //ViewData["UniversityId"] = new SelectList(_context.Universities, "Id", "Name", faculties.UniversityId); return(RedirectToAction("Index", "Faculties", new { id = universityId, name = _context.Universities.Where(x => x.Id == universityId).FirstOrDefault().Name })); }
public async Task <IActionResult> Create(int specialtiesId, [Bind("Id,Name,SpecialtiesId,Price")] EducationalProg educationalProg) { educationalProg.SpecialtiesId = specialtiesId; if (ModelState.IsValid) { _context.Add(educationalProg); await _context.SaveChangesAsync(); //return RedirectToAction(nameof(Index)); return(RedirectToAction("Index", "EducationalProgs", new { id = specialtiesId, name = _context.Specialties.Where(c => c.Id == specialtiesId).FirstOrDefault().Name })); } //ViewData["SpecialtiesId"] = new SelectList(_context.Specialties, "Id", "Name", educationalProg.SpecialtiesId); //return View(educationalProg); return(RedirectToAction("Index", "EducationalProgs", new { id = specialtiesId, name = _context.Specialties.Where(c => c.Id == specialtiesId).FirstOrDefault().Name })); }
public async Task <IActionResult> Create(int countryId, [Bind("Id,Name")] Universities universities) { universities.CountryId = countryId; if (ModelState.IsValid) { _context.Add(universities); await _context.SaveChangesAsync(); //return RedirectToAction(nameof(Index)); return(RedirectToAction("Index", "Universities", new { id = countryId, name = _context.Countries.Where(v => v.Id == countryId).FirstOrDefault().Name })); } //ViewData["CountryId"] = new SelectList(_context.Countries, "Id", "Name", universities.CountryId); // return View(universities); return(RedirectToAction("Index", "Universities", new { id = countryId, name = _context.Countries.Where(v => v.Id == countryId).FirstOrDefault().Name })); }
public async Task <IActionResult> Create(int educationalProgId, int facultyId, [Bind("Id,EducationalProgId,FacultyId")] FacultyEducationalProg facultyEducationalProg) { // facultyEducationalProg.EducationalProgId = educationalProgId; // facultyEducationalProg.FacultyId = facultyId; // if (ModelState.IsValid) // { _context.Add(facultyEducationalProg); await _context.SaveChangesAsync(); //return RedirectToAction(nameof(Index)); // return RedirectToAction("Index", "FacultyEducationalProgs", new { id = educationalProgId, name = _context.EducationalProg.Where(h => h.Id == educationalProgId).FirstOrDefault().Name }); // } //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 = educationalProgId, name = _context.EducationalProg.Where(h => h.Id == educationalProgId).FirstOrDefault().Name }); return(RedirectToAction("Index", "FacultyEducationalProgs", new { id = facultyId })); }