public DataResult <int> AddSecretToApiResource(int apiResourceId, SecretModel secret) { var newSecret = new ApiSecretEntity { Value = secret.Value, Description = secret.Description, Expiration = secret.Expiration }; try { var result = m_secretUoW.AddSecretToApiResource(apiResourceId, newSecret); return(Success(result)); } catch (NoResultException <ApiResourceEntity> e) { m_logger.LogWarning(e); return(Error <int>(m_translator.Translate("invalid-api-resource-id"), DataResultErrorCode.ApiResourceNotExistId)); } catch (DatabaseException e) { m_logger.LogWarning(e); return(Error <int>(e.Message)); } }
public virtual int AddSecretToApiResource(int apiResourceId, ApiSecretEntity newSecret) { var apiResource = m_apiResourceRepository.FindById <ApiResourceEntity>(apiResourceId); newSecret.ApiResource = apiResource ?? throw new NoResultException <ApiResourceEntity>(); var result = (int)m_secretRepository.Create(newSecret); return(result); }