コード例 #1
0
 public void Delete(UserDto entity)
 {
     try
     {
         var user = _userDal.Get(x => x.Id == entity.Id);
         if (user != null)
         {
             var userRoles = _userRolesService.GetList(x => x.UserId == user.Id);
             if (userRoles != null)
             {
                 foreach (var userRole in userRoles)
                 {
                     _userRolesService.Delete(userRole.Id);
                 }
                 _userDal.Delete(user);
                 return;
             }
             _userDal.Delete(user);
         }
     }
     catch (Exception exception)
     {
         throw new Exception(exception.Message);
     }
 }
コード例 #2
0
 public ActionResult Delete(UserRole userRole)
 {
     try
     {
         userRolesService.Delete(userRole.UserId, userRole.RoleId);
         return(RedirectToAction(nameof(Index)));
     }
     catch (ValidationException ex)
     {
         ModelState.AddModelError("", ex.Message);
         return(View(userRole));
     }
 }
コード例 #3
0
        public void Delete(int id)
        {
            var userRoles = _userRolesService.GetRole(id);

            _userRolesService.Delete(userRoles);
        }