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); } }