public async Task <IActionResult> Delete(string id) { if (id == null) { return(NotFound()); } var account = await _context.Accounts.FirstOrDefaultAsync(m => m.UserName == id); if (account == null) { return(NotFound()); } _context.Accounts.Remove(account); await _context.SaveChangesAsync(); return(RedirectToAction("listuser")); }
// GET: Admin/Role/Delete/5 public async Task <IActionResult> Delete(string id) { if (id == null) { return(NotFound()); } var role = await _context.Roles .FirstOrDefaultAsync(m => m.RoleName == id); if (role == null) { return(NotFound()); } _context.Roles.Remove(role); await _context.SaveChangesAsync(); return(RedirectToAction("ListRole")); }
public bool CreateDevices(string name, string nameShow, string branchOrProtocol) { try { Device device = new Device() { Name = name, NameShow = nameShow, BranchOrProtocol = branchOrProtocol }; _context.Add(device); _context.SaveChangesAsync(); } catch { return(false); } return(true); }