public async Task <IActionResult> Edit(int id, [Bind("Name,UpperId,Id,State")] Category category) { if (id != category.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(category); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CategoryExists(category.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction("List", "Admin")); } return(View(category)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,Email,Name,CreatedOn")] User user) { if (id != user.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(user); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserExists(user.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(user)); }
public async Task <IActionResult> Edit(int id, [Bind("CourseName,Title,Description,FilePath,UploadDate,Id,State")] File file) { if (id != file.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(file); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FileExists(file.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(file)); }
public async Task <IActionResult> Change(int id, Note Note) { if (ModelState.IsValid) { try { Note.LastChange = DateTime.Now.ToString("dd.MM.yyyy HH:mm"); db.Update(Note); await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!NoteInfoExists(Note.Id)) { return(NotFound()); } else { throw; } } return(Redirect("~/Notes/View/" + id)); } return(Redirect("/")); }
public async Task <IActionResult> Edit(int id, [Bind("ID,Title,Notes,CreatedOn,CategoryId,UserId,IsDeleted")] Note note) { if (id != note.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(note); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!NoteExists(note.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CategoryId"] = new SelectList(_context.Categories, "ID", "ID", note.CategoryId); ViewData["UserId"] = new SelectList(_context.Users, "ID", "ID", note.UserId); return(View(note)); }