public async Task <IActionResult> Edit(int id, [Bind("Id,FullName,Password,Email,Phone,RoleId")] 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))); } ViewData["RoleId"] = new SelectList(_context.Roles, "Id", "Id", user.RoleId); return(View(user)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Role role) { if (id != role.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(role); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RoleExists(role.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(role)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Price,Status,Image,CategoryId")] Product product) { if (id != product.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(product); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductExists(product.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CategoryId"] = new SelectList(_context.Categories, "Id", "Id", product.CategoryId); return(View(product)); }
public async Task <bool> UpdateAsync(User user) { user.Password = MD5Hash(user.Password); _dbContext.Update(user); await _dbContext.SaveChangesAsync(); return(true); }