/// <inheritdoc /> public IDictionary <string, object> ExecuteNoParameters(string connectorName, string procedureName, ILoggingService loggingService = null) { loggingService?.AddSprocToLogger(connectorName, procedureName, HttpMethodType.GET); IOperationResource resource = ResourceFactory.GetResource(connectorName, OperationType.read, procedureName); return(resource.ExecuteProc(new Dictionary <string, object>())); }
/// <inheritdoc /> public StoredProcedureParameterDefinition Definition(string connectorName, string procedureName, string parameterName, ILoggingService loggingService = null) { loggingService?.AddSprocToLogger(connectorName, procedureName, HttpMethodType.GET); IOperationResource resource = ResourceFactory.GetResource(connectorName, OperationType.Any, procedureName); return(resource.GetStoredProcedureDefinition(parameterName)); }
/// <inheritdoc /> public virtual ColumnDefinition Definition(string connectorName, string tableName, string columnName, ILoggingService loggingService = null) { loggingService?.AddTableToLogger(connectorName, tableName, HttpMethodType.GET); IOperationResource resource = ResourceFactory.GetResource(connectorName, OperationType.Any, tableName); return(resource.GetColumnDefinition(columnName)); }
/// <inheritdoc /> public virtual IQueryable <TViewModel> GetAll <TViewModel>(string connectorName, string tableName, ILoggingService loggingService = null) { loggingService?.AddTableToLogger(connectorName, tableName, HttpMethodType.GET); IOperationResource resource = ResourceFactory.GetResource(connectorName, OperationType.read, tableName); //Manually $expand to prevent nulls on non pk joins var joinProperties = typeof(TViewModel).GetProperties() .Where(c => (c.PropertyType.IsClass && c.PropertyType != typeof(string)) || (c.PropertyType.IsGenericType && c.PropertyType.GetGenericTypeDefinition() == typeof(IEnumerable <>))) .Select(c => c.Name); IQueryable <dynamic> list; if (joinProperties.Any()) { list = resource.GetResourceRecords(new Dictionary <string, string>() { { "$expand", string.Join(",", joinProperties) } }); } else { list = resource.GetResourceRecords(new Dictionary <string, string>()); } return(list.ProjectTo <TViewModel>()); }
/// <inheritdoc /> public IQueryable <object> GetAll(string connectorName, string viewName, ILoggingService loggingService = null) { loggingService?.AddViewToLogger(connectorName, viewName); IOperationResource resource = ResourceFactory.GetResource(connectorName, OperationType.read, viewName); return(resource.GetViewRecords()); }
/// <inheritdoc /> public (IQueryable <object> list, int recordLimit) GetAllAndRecordLimit(string connectorName, string viewName, ILoggingService loggingService = null) { loggingService?.AddViewToLogger(connectorName, viewName); IOperationResource resource = ResourceFactory.GetResource(connectorName, OperationType.read, viewName); return(resource.GetViewRecords(), resource.Connector.RecordLimit); }
public IEnumerable <string> ListSchemas(string connectorName, ILoggingService loggingService = null) { loggingService?.AddSchemaToLogger(connectorName); IOperationResource resource = ResourceFactory.GetResource(connectorName, OperationType.Any, string.Empty); return(resource.ListSchemas()); }
/// <inheritdoc /> public SchemaDefinition Definition(string connectorName, ILoggingService loggingService = null) { loggingService?.AddSchemaToLogger(connectorName); IOperationResource resource = ResourceFactory.GetResource(connectorName, OperationType.Any, string.Empty); return(resource.GetSchemaDefinition()); }
/// <inheritdoc /> public virtual object DeleteRow(string connectorName, string tableName, ILoggingService loggingService, params object[] id) { loggingService?.AddTableToLogger(connectorName, tableName, HttpMethodType.DELETE, id); IOperationResource resource = ResourceFactory.GetResource(connectorName, OperationType.delete, tableName); return(resource.DeleteResourceRecordById(id)); }
/// <inheritdoc /> public virtual object GetById(string connectorName, string tableName, ILoggingService loggingService, params object[] id) { loggingService?.AddTableToLogger(connectorName, tableName, HttpMethodType.GET, id); IOperationResource resource = ResourceFactory.GetResource(connectorName, OperationType.read, tableName); var data = resource.GetResourceRecordById(id); return(data); }
/// <inheritdoc /> public virtual TViewModel CreateNewRow <TViewModel>(string connectorName, string tableName, TViewModel value, ILoggingService loggingService = null) where TViewModel : class { loggingService?.AddTableToLogger(connectorName, tableName, HttpMethodType.POST); IOperationResource resource = ResourceFactory.GetResource(connectorName, OperationType.write, tableName); var data = resource.CreateNewResourceRecord(value); return(DynamicObjectExtensions.PopulateModel <TViewModel>(data)); }
/// <inheritdoc /> public IDictionary <string, object> Execute(string connectorName, string procedureName, JToken parameters, ILoggingService loggingService = null) { loggingService?.AddSprocToLogger(connectorName, procedureName, HttpMethodType.POST); Check.NotNull(parameters, nameof(parameters)); IOperationResource resource = ResourceFactory.GetResource(connectorName, OperationType.read, procedureName); IDictionary <string, object> parameterDictionary = (IDictionary <string, object>)parameters.JTokenToConventionalDotNetObject(); return(resource.ExecuteProc(parameterDictionary)); }
/// <inheritdoc /> public IDictionary <string, object> Execute <TViewModel>(string connectorName, string procedureName, TViewModel parameters, ILoggingService loggingService = null) { loggingService?.AddSprocToLogger(connectorName, procedureName, HttpMethodType.POST); IOperationResource resource = ResourceFactory.GetResource(connectorName, OperationType.read, procedureName); IDictionary <string, object> parameterDictionary = typeof(TViewModel) .GetProperties(BindingFlags.Instance | BindingFlags.Public) .ToDictionary(prop => prop.Name, prop => prop.GetValue(parameters, null)); return(resource.ExecuteProc(parameterDictionary)); }
/// <inheritdoc /> public virtual object CreateNewRow(string connectorName, string tableName, JToken value, ILoggingService loggingService = null) { loggingService?.AddTableToLogger(connectorName, tableName, HttpMethodType.POST); Check.NotNull(value, nameof(value)); IOperationResource resource = ResourceFactory.GetResource(connectorName, OperationType.write, tableName); var data = resource.CreateNewResourceRecord(value); return(data); }
/// <inheritdoc /> public virtual (IQueryable <object> list, int connectorMax) GetAll(string connectorName, string tableName, ILoggingService loggingService = null) { Check.NotEmpty(connectorName, nameof(connectorName)); Check.NotEmpty(tableName, nameof(tableName)); loggingService?.AddTableToLogger(connectorName, tableName, HttpMethodType.GET); IOperationResource resource = ResourceFactory.GetResource(connectorName, OperationType.read, tableName); var queryString = _requestQuery.GetQueryStrings(); return(resource.GetResourceRecords(queryString), resource.Connector.RecordLimit); }
public virtual IServiceProvider GetOrAdd(IOperationResource resource, IServiceProvider rootProvider) { Check.NotNull(resource, nameof(resource)); return(_configurations.GetOrAdd( resource.ResourceType, k => { var service = new ServiceCollection(); resource.ApplyServices(service, rootProvider); return service.BuildServiceProvider(); })); }
/// <inheritdoc /> public virtual TViewModel UpdateRow <TViewModel>(string connectorName, string tableName, TViewModel value, ILoggingService loggingService = null) where TViewModel : class { IOperationResource resource = ResourceFactory.GetResource(connectorName, OperationType.write, tableName); object[] id = null; try { id = resource.GetPrimaryKeys(value); } catch (Exception) { throw; } finally { //Log even if values for PK not found loggingService?.AddTableToLogger(connectorName, tableName, HttpMethodType.PUT, id); } return(resource.UpdateResourceRecordById(value, id)); }
/// <inheritdoc /> public virtual object UpdateRow(string connectorName, string tableName, JToken value, ILoggingService loggingService = null) { Check.NotNull(value, nameof(value)); IOperationResource resource = ResourceFactory.GetResource(connectorName, OperationType.write, tableName); object[] id = null; try { id = resource.GetPrimaryKeys(value); } catch (Exception) { throw; } finally { //Log even if values for PK not found loggingService?.AddTableToLogger(connectorName, tableName, HttpMethodType.PUT, id); } return(resource.UpdateResourceRecordById(value, id)); }
/// <inheritdoc /> public virtual TViewModel GetById <TViewModel>(string connectorName, string tableName, ILoggingService loggingService, params object[] id) where TViewModel : class { loggingService?.AddTableToLogger(connectorName, tableName, HttpMethodType.GET, id); //Manually $expand to prevent nulls on non pk joins var joinProperties = typeof(TViewModel).GetProperties() .Where(c => (c.PropertyType.IsClass && c.PropertyType != typeof(string)) || (c.PropertyType.IsGenericType && c.PropertyType.GetGenericTypeDefinition() == typeof(IEnumerable <>))) .Select(c => c.Name); IOperationResource resource = ResourceFactory.GetResource(connectorName, OperationType.read, tableName); if (joinProperties.Any()) { return(resource.GetResourceRecordById <TViewModel>(id, new Dictionary <string, string>() { { "$expand", string.Join(",", joinProperties) } })); } else { return(resource.GetResourceRecordById <TViewModel>(id, new Dictionary <string, string>())); } }