public async Task <IActionResult> Edit(Guid id, [Bind("PostID,CategoryID")] PostCategoryEntity postCategoryEntity) { if (id != postCategoryEntity.PostID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(postCategoryEntity); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PostCategoryEntityExists(postCategoryEntity.PostID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CategoryID"] = new SelectList(_context.Categories, "ID", "CategoryName", postCategoryEntity.CategoryID); ViewData["PostID"] = new SelectList(_context.Posts, "ID", "MainContent", postCategoryEntity.PostID); return(View(postCategoryEntity)); }
public async Task <IActionResult> Create([Bind("PostID,CategoryID")] PostCategoryEntity postCategoryEntity) { if (ModelState.IsValid) { postCategoryEntity.PostID = Guid.NewGuid(); _context.Add(postCategoryEntity); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CategoryID"] = new SelectList(_context.Categories, "ID", "CategoryName", postCategoryEntity.CategoryID); ViewData["PostID"] = new SelectList(_context.Posts, "ID", "MainContent", postCategoryEntity.PostID); return(View(postCategoryEntity)); }
private void PrepareUpdate(PostCategoryEntity entity) { }