/// <summary> /// 获取菜单模块 /// </summary> /// <param name="id"></param> /// <returns></returns> public async Task <SysModule> Get(long id) { var module = await _moduleRep.GetAsync(id); H_AssertEx.That(module == null, "模块或资源不存在"); H_AssertEx.That(module.IsDeleted, "模块或资源已删除"); return(module); }
public async Task <IResultModel> Delete(Guid id) { var entity = await _repository.GetAsync(id); if (entity == null) { return(ResultModel.NotExists); } using (var uow = _dbContext.NewUnitOfWork()) { var result = await _repository.SoftDeleteAsync(id, uow); if (result) { result = await _classRepository.DeleteByModule(id, uow); if (result) { result = await _propertyRepository.DeleteByModule(id, uow); if (result) { result = await _modelPropertyRepository.DeleteByModule(id, uow); if (result) { uow.Commit(); return(ResultModel.Success()); } } } } } return(ResultModel.Failed()); }
public static async Task <Module> GetModuleAsync(this ModulePermission instance, IModuleRepository repository, CancellationToken cancellationToken = default) { if (instance is null) { return(null); } if (repository is null) { throw SystemBaseException.RepositoryIsNull <IModuleRepository>(); } var moduleId = instance.ModuleId; if (moduleId > 0) { var module = await repository.GetAsync(moduleId ?? 0, cancellationToken); instance.Module = module; return(module); } return(null); }