public async Task <IActionResult> Edit(int id, [Bind("TagId,Title")] Tag tag) { if (id != tag.TagId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(tag); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TagExists(tag.TagId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(tag)); }
public async Task <IActionResult> Edit(int id, CategoryVm category, string[] SelectedFolders) { if (id != category.CategoryId) { return(NotFound()); } RemoveFolders(id); if (ModelState.IsValid) { try { Category model = _mapper.Map <Category>(category); AddFolder(model, SelectedFolders); _context.Update(model); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CategoryExists(category.CategoryId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ParentId"] = new SelectList(_context.Category, "CategoryId", "CategoryId", category.ParentId); return(View(category)); }
public async Task <IActionResult> Edit(int id, DocumentVm document, string[] SelectedFolders, IFormFile File) { if (id != document.DocumentId) { return(NotFound()); } RemoveFolders(id); if (ModelState.IsValid) { try { Document model = _mapper.Map <Document>(document); AddFile(model, File); AddFolder(model, SelectedFolders); _context.Update(model); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DocumentExists(document.DocumentId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(document)); }
public async Task <IActionResult> Edit(int id, FolderVm folder, string[] SelectedCategories, string[] SelectedTags, List <IFormFile> Files) { if (id != folder.FolderId) { return(NotFound()); } RemoveCategories(id); RemoveFiles(id); RemoveTags(id); if (ModelState.IsValid) { try { Folder model = _mapper.Map <Folder>(folder); AddCategories(model, SelectedCategories); AddTags(model, SelectedTags); AddFiles(model, Files); _context.Update(model); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FolderExists(folder.FolderId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ParentId"] = new SelectList(_context.Folder, "FolderId", "FolderId", folder.ParentId); return(View(folder)); }