public async Task <IActionResult> Edit(int id, [Bind("AnnounceId,Title,Description,AddingDate,ExpiringDate,CategoryId,UserId")] Announce announce) { if (id != announce.AnnounceId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(announce); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AnnounceExists(announce.AnnounceId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CategoryId"] = new SelectList(_context.Category, "CategoryId", "CategoryName", announce.CategoryId); ViewData["UserId"] = new SelectList(_context.User, "UserId", "Email", announce.UserId); return(View(announce)); }
public async Task <IActionResult> Edit(int id, [Bind("UserId,Username,Password,Nume,Prenume,Email,PhoneNumber")] User user) { if (id != user.UserId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(user); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserExists(user.UserId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(user)); }
public async Task <IActionResult> Edit(int id, [Bind("CategoryId,CategoryName")] Category category) { if (id != category.CategoryId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(category); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CategoryExists(category.CategoryId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(category)); }