public async Task <IActionResult> Edit(int id, [Bind("ResearchId,ArticleId")] ResearchArticle researchArticle) { if (id != researchArticle.ResearchId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(researchArticle); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ResearchArticleExists(researchArticle.ResearchId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ArticleId"] = new SelectList(_context.Article, "Id", "Name", researchArticle.ArticleId); ViewData["ResearchId"] = new SelectList(_context.Research, "Id", "Name", researchArticle.ResearchId); return(View(researchArticle)); }
public async Task <IActionResult> Create([Bind("ResearchId,ArticleId")] ResearchArticle researchArticle) { if (ModelState.IsValid) { _context.Add(researchArticle); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ArticleId"] = new SelectList(_context.Article, "Id", "Name", researchArticle.ArticleId); ViewData["ResearchId"] = new SelectList(_context.Research, "Id", "Name", researchArticle.ResearchId); return(View(researchArticle)); }