public async Task <IActionResult> Edit(Guid id, [Bind("Id,UserEmail,Message,PhotoUrl,PublishDateTime")] Post post) { if (id != post.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(post); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PostExists(post.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(post)); }
public async Task <IActionResult> Edit(Guid id, [Bind("UserIdA,UserIdB")] Friendship friendship) { if (id != friendship.UserIdA) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(friendship); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FriendshipExists(friendship.UserIdA)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["UserIdA"] = new SelectList(_context.Users, "Id", "Id", friendship.UserIdA); ViewData["UserIdB"] = new SelectList(_context.Users, "Id", "Id", friendship.UserIdB); return(View(friendship)); }