diff --git a/BusinessLogic/LookupLogic/FwLookupLogic.cs b/BusinessLogic/LookupLogic/FwLookupLogic.cs index 61486a7..fc583d9 100644 --- a/BusinessLogic/LookupLogic/FwLookupLogic.cs +++ b/BusinessLogic/LookupLogic/FwLookupLogic.cs @@ -27,7 +27,7 @@ namespace BusinessLogic.LookupLogic public async Task>> GetAllLookups() { var result = await _lookupRepo.GetAllLookups(); - _logger.LogInformation($"Call to GetAllLookups ended with {nameof(result.GeneralResult)}"); + _logger.LogInformation($"Call to GetAllLookups ended with {result.GeneralResult.ToString()}"); return result; } diff --git a/BusinessLogic/LookupLogic/LookupLogic.csproj b/BusinessLogic/LookupLogic/LookupLogic.csproj index 77196f7..843e53b 100644 --- a/BusinessLogic/LookupLogic/LookupLogic.csproj +++ b/BusinessLogic/LookupLogic/LookupLogic.csproj @@ -1,17 +1,13 @@ - - - - - - - - - - - - - netstandard2.1 - - - + + + + + + + + + + net6.0 + + \ No newline at end of file diff --git a/BusinessLogic/SearchLogic/Exceptions/FieldAliasMissingException.cs b/BusinessLogic/SearchLogic/Exceptions/FieldAliasMissingException.cs new file mode 100644 index 0000000..16461c1 --- /dev/null +++ b/BusinessLogic/SearchLogic/Exceptions/FieldAliasMissingException.cs @@ -0,0 +1,9 @@ +using System; + +namespace SearchApi.Exceptions +{ + public class FieldAliasMissingException : Exception + { + public FieldAliasMissingException(string message) : base(message: message) {} + } +} \ No newline at end of file diff --git a/BusinessLogic/SearchLogic/Exceptions/TableAliasMissingException.cs b/BusinessLogic/SearchLogic/Exceptions/TableAliasMissingException.cs new file mode 100644 index 0000000..8648c46 --- /dev/null +++ b/BusinessLogic/SearchLogic/Exceptions/TableAliasMissingException.cs @@ -0,0 +1,9 @@ +using System; + +namespace SearchApi.Exceptions +{ + public class TableAliasMissingException : Exception + { + public TableAliasMissingException(string message) : base(message: message) {} + } +} \ No newline at end of file diff --git a/BusinessLogic/SearchLogic/ISearchLogic.cs b/BusinessLogic/SearchLogic/ISearchLogic.cs index ae14b15..905699e 100644 --- a/BusinessLogic/SearchLogic/ISearchLogic.cs +++ b/BusinessLogic/SearchLogic/ISearchLogic.cs @@ -6,7 +6,7 @@ using Datamodels.BusinessModels; using Datamodels.DatabaseModels; using Datamodels.SearchModels; -namespace SearchLogic +namespace SearchApi.SearchLogic { public interface ISearchLogic { diff --git a/BusinessLogic/SearchLogic/SearchLogic.cs b/BusinessLogic/SearchLogic/SearchLogic.cs index 942d922..204afca 100644 --- a/BusinessLogic/SearchLogic/SearchLogic.cs +++ b/BusinessLogic/SearchLogic/SearchLogic.cs @@ -9,14 +9,21 @@ using Datamodels.SearchModels; using Newtonsoft.Json; using System.Linq; using System.Linq.Expressions; +using SearchApi.Exceptions; -namespace SearchLogic +namespace SearchApi.SearchLogic { public class SearchLogic : ISearchLogic { private readonly ILogger _logger; private readonly IFwMariaSearchRepo _searchRepo; + private List _tableNames; + private List _joinConditions; + private List _fieldNames; + private List _whereConditions; + private List _sortFields; + public SearchLogic(ILogger logger, IFwMariaSearchRepo searchRepo) { _logger = logger; @@ -37,5 +44,61 @@ namespace SearchLogic return result; } + + // Extract Table + private void GetTables(FilterModel filter) + { + bool hasTableList = filter.TableDescriptions.Count > 0; + _tableNames = new List(); + foreach(var table in filter.TableDescriptions) + { + if (hasTableList && string.IsNullOrEmpty(table.TableAlias)) + { + throw new TableAliasMissingException($"No Alias defined for Table {table.TableName}"); + } + _tableNames.Add($"{table.TableName} {(string.IsNullOrEmpty(table.TableAlias) ? string.Empty : table.TableAlias)}"); + } + } + + // Extract Fieldlist + private void GetFields(FilterModel filter) + { + var tables = filter.TableDescriptions; + foreach (var table in tables) + { + bool hasMultipleFields = table.Fields.Count > 0; + foreach (var field in table.Fields) { + if (hasMultipleFields && string.IsNullOrEmpty(field.FieldAlias)) + { + throw new FieldAliasMissingException($"No Alias defined for Field {field.FieldName} in Table {table.TableName}"); + } + _fieldNames.Add($"{table.TableAlias}.{field.FieldName} {field.FieldAlias}"); + } + } + } + + // Extract Join Path if more than one table + private void GetTableJoinConditions(FilterModel filter) + { + + } + + // Extract Where Conditions + private void GetWhereConditions(FilterModel filter) + { + + } + + // Extract Sort Items + private void GetSortFields(FilterModel filter) + { + + } + + // Assemble SQL Query + private string AssembleSqlQuery() + { + return null; + } } } diff --git a/BusinessLogic/SearchLogic/SearchLogic.csproj b/BusinessLogic/SearchLogic/SearchLogic.csproj index a27aa5e..2e26a0e 100644 --- a/BusinessLogic/SearchLogic/SearchLogic.csproj +++ b/BusinessLogic/SearchLogic/SearchLogic.csproj @@ -1,7 +1,7 @@ - netstandard2.1 + net6.0 diff --git a/Repositories/Repositories.csproj b/Repositories/Repositories.csproj index 1a08ffa..7f103af 100644 --- a/Repositories/Repositories.csproj +++ b/Repositories/Repositories.csproj @@ -1,22 +1,18 @@ - - - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - - - - - netstandard2.1 - - - + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + net6.0 + + \ No newline at end of file diff --git a/SearchWebApi/Controllers/SearchController.cs b/SearchWebApi/Controllers/SearchController.cs index cf441b5..242cb18 100644 --- a/SearchWebApi/Controllers/SearchController.cs +++ b/SearchWebApi/Controllers/SearchController.cs @@ -2,7 +2,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; using System.Threading.Tasks; -using SearchLogic; +using SearchApi.SearchLogic; using Datamodels.SearchModels; using System.Collections.Generic; using Datamodels.DatabaseModels; diff --git a/SearchWebApi/SearchWebApi.csproj b/SearchWebApi/SearchWebApi.csproj index f528809..3bfe3bb 100644 --- a/SearchWebApi/SearchWebApi.csproj +++ b/SearchWebApi/SearchWebApi.csproj @@ -1,41 +1,36 @@ - - - net6.0 - 10 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + net6.0 + 10 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/SearchWebApi/Startup.cs b/SearchWebApi/Startup.cs index 6b5b176..371ea44 100644 --- a/SearchWebApi/Startup.cs +++ b/SearchWebApi/Startup.cs @@ -16,7 +16,7 @@ using OpenTelemetry.Trace; using Repositories; using Repositories.Interfaces; -using SearchLogic; +using SearchApi.SearchLogic; namespace FwSearchApi { @@ -43,7 +43,7 @@ namespace FwSearchApi services.AddTransient(); services.AddTransient(); services.AddTransient(); - services.AddTransient(); + services.AddTransient(); services.AddSwaggerGen(); AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true); //needed if no Security is used when calling APM Server services.AddOpenTelemetryTracing((builder) => builder diff --git a/Tests/Repo/fwrepo/fwrepo.csproj b/Tests/Repo/fwrepo/fwrepo.csproj index 99a8759..95ac2c4 100644 --- a/Tests/Repo/fwrepo/fwrepo.csproj +++ b/Tests/Repo/fwrepo/fwrepo.csproj @@ -1,7 +1,7 @@ - netcoreapp3.1 + net6.0 false diff --git a/Tools/EF/Migration/Migration.csproj b/Tools/EF/Migration/Migration.csproj index a65e492..bac2f08 100644 --- a/Tools/EF/Migration/Migration.csproj +++ b/Tools/EF/Migration/Migration.csproj @@ -1,19 +1,15 @@ - - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - - Exe - netcoreapp3.1 - - - + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + Exe + net6.0 + + \ No newline at end of file