public async Task <IActionResult> Edit(int jid, int id, [Bind("Id,JournalId,ArticleTypeId,IsDeleted")] JournalArticleType journalArticleType) { if (id != journalArticleType.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(journalArticleType); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!JournalArticleTypeExists(journalArticleType.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index", new { id = jid })); } ViewData["ArticleTypeId"] = new SelectList(_context.ArticleTypes, "Id", "Type", journalArticleType.ArticleTypeId); ViewData["JournalId"] = new SelectList(_context.Journals, "Id", "ArName", journalArticleType.JournalId); return(View(journalArticleType)); }
public async Task <IActionResult> Create(int jid, [Bind("JournalId,ArticleTypeId,IsDeleted")] JournalArticleType journalArticleType) { if (journalArticleType.ArticleTypeId == 0) { return(RedirectToAction("Create", new { id = jid })); } if (ModelState.IsValid) { _context.Add(journalArticleType); await _context.SaveChangesAsync(); return(RedirectToAction("Index", new { id = jid })); } ViewData["ArticleTypeId"] = new SelectList(_context.ArticleTypes.Where(a => a.Type != null && _context.JournalArticleTypes.Where(j => j.ArticleType.Type == a.Type).Count() == 0), "Id", "Type", journalArticleType.ArticleTypeId); ViewData["JournalId"] = new SelectList(_context.Journals, "Id", "ArName", journalArticleType.JournalId); return(View(journalArticleType)); }