public async Task <IActionResult> AddApiProperties(CreateApiPropertiesDto apiProperties) { if (!ModelState.IsValid) { return(BadRequest(ModelStateErrors)); } var result = await _apiresourceService.AddProperties(apiProperties); return(ResultResponse(result, "添加ApiProperties成功")); }
public async Task <bool> AddProperties(CreateApiPropertiesDto apiProperties) { var apiresource = await _apiresourceRepository.GetByIdAsync(apiProperties.ApiResourceId); var entity = _mapper.Map <ApiResourceProperty>(apiProperties); entity.ApiResource = apiresource ?? throw new Exception("apiResource不存在"); await _apipropertyRepository.AddAsync(entity); return(await _apipropertyRepository.SaveChangesAsync() > 0); }