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); } }
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)); } }
public void Delete(int id) { var userRoles = _userRolesService.GetRole(id); _userRolesService.Delete(userRoles); }