public async Task <IActionResult> Edit(long id, [Bind("ID,Name")] Node node) { if (id != node.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(node); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!NodeExists(node.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } return(View(node)); }
public async Task <IActionResult> Edit(long id, [Bind("AuthorID,Firstname,Lastname")] Author author) { if (id != author.AuthorID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(author); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AuthorExists(author.AuthorID)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } return(View(author)); }
public async Task <IActionResult> Edit(long id, [Bind("ID,Title,Type,Year,Abstract,PeerReviewed")] Journal journal, IFormFile file1, IFormFile file2, Journal listBox) { if (id != journal.ID) { return(NotFound()); } var user = await _userManager.GetUserAsync(User); var author = _context.Author.Find(user.AuthorID); var currentJournal = _context.Journal.Find(id); _context.Entry(currentJournal).State = EntityState.Detached; if (ModelState.IsValid) { try { if (!listBox.CoAuthor1.Equals("0")) { journal.CoAuthor1 = await FindAuthorName(listBox.CoAuthor1); } else { journal.CoAuthor1 = currentJournal.CoAuthor1; } if (!listBox.CoAuthor2.Equals("0")) { journal.CoAuthor2 = await FindAuthorName(listBox.CoAuthor2); } else { journal.CoAuthor2 = currentJournal.CoAuthor2; } journal.AuthorID = user.AuthorID; if (file1 != null) { journal.url = await Upload(file1); } if (file2 != null) { journal.PeerUrl = await Upload(file2); } if (journal.PeerReviewed) { journal.ProofOfpeerReview = "This journal has been peer reviewed"; } else { journal.ProofOfpeerReview = currentJournal.ProofOfpeerReview; } _context.Update(journal); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!JournalExists(journal.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } return(View(journal)); }