using Datamodels.BusinessModels; using Datamodels.DatabaseModels; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; using Repositories.Interfaces; using System; using System.Collections.Generic; using System.Text; using System.Threading.Tasks; using System.Linq; using Microsoft.EntityFrameworkCore; using Datamodels.SearchModels; using System.Linq.Expressions; using System.Diagnostics; namespace Repositories { public class FwMariaSearchRepo : IFwMariaSearchRepo { private readonly FwDbContext _dbContext = new FwDbContext(); private readonly ILogger _logger; private readonly IConfiguration _configuration; public FwMariaSearchRepo(ILogger logger, IConfiguration configuration) { _logger = logger; _configuration = configuration; try { if (Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == "Development") { _dbContext._connectionString = "SERVER=127.0.0.1;DATABASE=testdb;PORT=3306;USER=root;PASSWORD=example"; } else { string usedDb = configuration.GetSection("GeneralSettings").GetSection("DbToUse").Value; string connectionString = configuration.GetConnectionString(usedDb); _dbContext._connectionString = connectionString; } } catch (Exception ex) { _logger.LogError(ex, "Database Connection Configuration not valid"); } } public async Task>> GetAllAddresses() { try { var result = await _dbContext.Address.Where(x => x.City == "Augsburg" || x.City == "München").Where(y => y.StreetName.Contains("bruck")).ToListAsync().ConfigureAwait(false); return new DataResult> { Data = result }; } catch (Exception ex) { return new DataResult> { GeneralResult = GeneralResults.DatabaseError, UserMessage = "Fehler beim Laden der Adressen", ServerMessage = ex.Message }; } } public Task GetAllSortedData(TableModel queryFieldDef, List sortModel) { throw new NotImplementedException(); } public Task GetBlobData(string tableName, string fieldName, long id) { throw new NotImplementedException(); } public Task GetDataFilteredAndSorted(List filter, List sortModel, long skip = 0, long take = -1) { throw new NotImplementedException(); } public async Task>> GetFilteredData(List expressions, long skip = 0, long take = -1) where T : IEntityClass { throw new NotImplementedException(); } } public class FilterLinq { public static Expression> GetWherePredicate(string whereFieldList, string whereFieldValues) { throw new NotImplementedException(); } } }