예제 #1
0
        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"));
        }
예제 #2
0
        // 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"));
        }
예제 #3
0
 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);
 }