Referenzen entfernt

This commit is contained in:
2023-04-11 19:56:36 +02:00
parent c4fd240f59
commit 1c3e3c876b
13 changed files with 31 additions and 103 deletions

View File

@@ -1,7 +1,5 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using SewerStammGen.EntityFramework;
using SewerStammGen.HostBuilders;
using SewerStammGen.WPF.ViewModel;
using System;
@@ -31,8 +29,8 @@ namespace SewerStammGen.WPF
.AddConfiguration()
.AddServices()
.AddViewModels()
.AddStores()
.AddDBContext();
.AddStores();
}
protected override void OnStartup(StartupEventArgs e)
@@ -42,11 +40,7 @@ namespace SewerStammGen.WPF
_host.Start();
SewerStammGenDbContextFactory contextFactory = _host.Services.GetRequiredService<SewerStammGenDbContextFactory>();
using(SewerStammGenDbContext context = contextFactory.CreateDbContext())
{
context.Database.Migrate();
}
MainWindow? window = new MainWindow() { DataContext = _host.Services.GetRequiredService<MainWindowViewModel>() };
window.Show();

View File

@@ -12,15 +12,15 @@ namespace SewerStammGen.WPF.Commands
{
internal class HaltungEditCommand : AsyncCommandBase
{
private IHaltungDataService haltungDataService;
private IActualState actualState;
private IRenavigator renavigator;
private HaltungListViewModel haltungListViewModel;
public HaltungEditCommand(IHaltungDataService haltungDataService, IActualState actualState, IRenavigator renavigator, HaltungListViewModel haltungListViewModel)
public HaltungEditCommand(IActualState actualState, IRenavigator renavigator, HaltungListViewModel haltungListViewModel)
{
this.haltungDataService = haltungDataService;
this.actualState = actualState;
this.renavigator = renavigator;
this.haltungListViewModel = haltungListViewModel;
@@ -28,7 +28,7 @@ namespace SewerStammGen.WPF.Commands
public override async Task ExecuteAsync(object? parameter)
{
actualState.SetHaltung(haltungListViewModel.SelectedHaltung);
//actualState.SetHaltung(haltungListViewModel.SelectedHaltung);
renavigator.Renavigate();
}
}

View File

@@ -17,10 +17,10 @@ namespace SewerStammGen.WPF.Commands
private IDataService<Kanal> kanalDataService;
private ISchachtService schachtService;
public HaltungEditSaveCommand(HaltungEditViewModel haltungEditViewModel, IDataService<Kanal> kanalDataService, ISchachtService schachtService)
public HaltungEditSaveCommand(HaltungEditViewModel haltungEditViewModel, ISchachtService schachtService)
{
this.haltungEditViewModel = haltungEditViewModel;
this.kanalDataService = kanalDataService;
//this.kanalDataService = kanalDataService;
this.schachtService = schachtService;
}

View File

@@ -1,8 +1,7 @@
using Microsoft.EntityFrameworkCore;

using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using SewerStammGen.EntityFramework;
using System;
using System.Collections.Generic;
using System.Diagnostics;
@@ -14,38 +13,6 @@ namespace SewerStammGen.HostBuilders
{
static class AddDBContextHostBuilderExtensions
{
public static IHostBuilder AddDBContext(this IHostBuilder hostBuilder)
{
hostBuilder.ConfigureServices((context, services) =>
{
string? connectionString = "";
Action<DbContextOptionsBuilder>? configureDbContext = null;
string? databaseToUse = context.Configuration.GetConnectionString("databaseToUse");
if (databaseToUse != null)
{
if (databaseToUse.Equals("default"))
{
connectionString = context.Configuration.GetConnectionString("default");
configureDbContext = o =>
{
o.EnableSensitiveDataLogging();
o.UseNpgsql(connectionString);
};
}
else if (databaseToUse.Equals("sqlite"))
{
connectionString = context.Configuration.GetConnectionString("sqlite");
configureDbContext = o => o.UseSqlite(connectionString);
}
services.AddDbContext<SewerStammGenDbContext>(configureDbContext);
services.AddSingleton<SewerStammGenDbContextFactory>(new SewerStammGenDbContextFactory(configureDbContext));
}
});
return hostBuilder;
}
}
}

View File

@@ -1,6 +1,6 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using SewerStammGen.EntityFramework.Services;
using SewerStammGen.Shared.Contracts;
using SewerStammGen.Shared.Services;
using SewerStammGen.WPF.Interface.Navigator;
@@ -25,11 +25,12 @@ namespace SewerStammGen.HostBuilders
{
services.AddSingleton<IMainWindowNavigator, MainWindowNavigator>();
services.AddSingleton<ViewModelDelegateRenavigator<ProjektEditViewModel>>();
services.AddSingleton<IDataService<Projekt>, GenericDataService<Projekt>>();
/* services.AddSingleton<IDataService<Projekt>, GenericDataService<Projekt>>();
services.AddSingleton<IDataService<Schacht>, GenericDataService<Schacht>>();
services.AddSingleton<IDataService<Kanal>, GenericDataService<Kanal>>();
services.AddSingleton<ISchachtDataService, SchachtDataService>();
services.AddSingleton<IHaltungDataService, HaltungDataService>();
*/
services.AddSingleton<ISchachtService, SchachtService>();
});
return host;

View File

@@ -66,7 +66,7 @@ namespace SewerStammGen.HostBuilders
services.AddSingleton<CreateViewModel<HaltungListViewModel>>(services =>
{
return () => new HaltungListViewModel(
services.GetRequiredService<IHaltungDataService>(),
services.GetRequiredService<IActualState>(),
services.GetRequiredService<ViewModelDelegateRenavigator<HaltungEditViewModel>>()
);
@@ -75,7 +75,7 @@ namespace SewerStammGen.HostBuilders
services.AddTransient<CreateViewModel<HaltungEditViewModel>>(services =>
{
return () => new HaltungEditViewModel(
services.GetRequiredService<IHaltungDataService>(),
services.GetRequiredService<ISchachtService>(),
services.GetRequiredService<IActualState>()
);

View File

@@ -19,7 +19,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SewerStammGen.EntityFramework\SewerStammGen.EntityFramework.csproj" />
<ProjectReference Include="..\Shared\SewerStammGen.Shared.csproj" />
</ItemGroup>
<ItemGroup>

View File

@@ -17,7 +17,7 @@ namespace SewerStammGen.WPF.ViewModel
internal class HaltungEditViewModel : BaseViewModel
{
private readonly IActualState _actualState;
private readonly IHaltungDataService _kanalDataService;
//private readonly IHaltungDataService _kanalDataService;
private readonly ISchachtService _schachtService;
private Kanal _model;
@@ -112,15 +112,15 @@ namespace SewerStammGen.WPF.ViewModel
public ICommand Speichern { get; set; }
public HaltungEditViewModel(IHaltungDataService kanalDataService,
public HaltungEditViewModel(
ISchachtService schachtService,
IActualState actualState)
{
_actualState = actualState;
_kanalDataService = kanalDataService;
//_kanalDataService = kanalDataService;
_schachtService = schachtService;
_model = new Kanal();
Speichern = new HaltungEditSaveCommand(this, kanalDataService, schachtService);
Speichern = new HaltungEditSaveCommand(this, schachtService);
LoadModel();
@@ -129,7 +129,7 @@ namespace SewerStammGen.WPF.ViewModel
private async void LoadModel()
{
_model = await _kanalDataService.Get(_actualState.HaltungID);
/*_model = await _kanalDataService.Get(_actualState.HaltungID);
UntereSchacht = _model.EndSchacht.Objektbezeichnung;
ObereSchacht = _model.StartSchacht.Objektbezeichnung;
OnPropertyChanged(nameof(ObereSchacht));
@@ -138,6 +138,7 @@ namespace SewerStammGen.WPF.ViewModel
OnPropertyChanged(nameof(Haltungsbezeichnung));
OnPropertyChanged(nameof(Material));
OnPropertyChanged(nameof(Durchmesser));
*/
}
}
}

View File

@@ -17,7 +17,7 @@ namespace SewerStammGen.WPF.ViewModel
{
private readonly ObservableCollection<Kanal> _haltungen;
private readonly IActualState _actualState;
private readonly IHaltungDataService _haltungDataService;
//private readonly IHaltungDataService _haltungDataService;
public Kanal? SelectedHaltung { get; set; }
public ObservableCollection<Kanal> Haltungen { get => _haltungen; }
@@ -25,14 +25,14 @@ namespace SewerStammGen.WPF.ViewModel
public ICommand EditCommand { get; set; }
public ICommand AddCommand { get; set; }
public HaltungListViewModel(IHaltungDataService haltungDataService, IActualState actualState, IRenavigator renavigator )
public HaltungListViewModel( IActualState actualState, IRenavigator renavigator )
{
_haltungen = new ObservableCollection<Kanal>();
_actualState = actualState;
_haltungDataService = haltungDataService;
EditCommand = new HaltungEditCommand(haltungDataService, actualState, renavigator, this);
EditCommand = new HaltungEditCommand(actualState, renavigator, this);
AddCommand = new HaltungAddCommand();
LoadHaltungen();
@@ -40,8 +40,9 @@ namespace SewerStammGen.WPF.ViewModel
private async void LoadHaltungen()
{
var haltungen = await _haltungDataService.GetAll(_actualState.ProjektID);
/* var haltungen = await _haltungDataService.GetAll(_actualState.ProjektID);
InitCollection(_haltungen, haltungen);
*/
}
private void InitCollection(ObservableCollection<Kanal> dest, IEnumerable<Kanal> source)

View File

@@ -1,5 +1,4 @@
using SewerStammGen.EntityFramework.Services;
using SewerStammGen.WPF.Commands;
using SewerStammGen.WPF.Commands;
using SewerStammGen.WPF.Interface.Navigator;
using SewerStammGen.WPF.ViewModel;
using SewerStammGen.WPF.ViewModel.State;

View File

@@ -1,15 +0,0 @@
using Shared.Contracts;
using Shared.Domain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SewerStammGen.Shared.Contracts
{
public interface IHaltungDataService : IDataService<Kanal>
{
Task<IEnumerable<Kanal>> GetAll(int projektID);
}
}

View File

@@ -1,14 +0,0 @@
using Shared.Contracts;
using Shared.Domain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SewerStammGen.Shared.Contracts
{
public interface IProjektDataService : IDataService<Projekt>
{
}
}

View File

@@ -7,8 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SewerStammGen.WPF", "SewerS
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SewerStammGen.Shared", "Shared\SewerStammGen.Shared.csproj", "{3A47BD31-36C2-45C4-9609-D0D9D92A993B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SewerStammGen.EntityFramework", "SewerStammGen.EntityFramework\SewerStammGen.EntityFramework.csproj", "{803CB44F-F68C-4872-8408-047D02BBF201}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -23,10 +21,6 @@ Global
{3A47BD31-36C2-45C4-9609-D0D9D92A993B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3A47BD31-36C2-45C4-9609-D0D9D92A993B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3A47BD31-36C2-45C4-9609-D0D9D92A993B}.Release|Any CPU.Build.0 = Release|Any CPU
{803CB44F-F68C-4872-8408-047D02BBF201}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{803CB44F-F68C-4872-8408-047D02BBF201}.Debug|Any CPU.Build.0 = Debug|Any CPU
{803CB44F-F68C-4872-8408-047D02BBF201}.Release|Any CPU.ActiveCfg = Release|Any CPU
{803CB44F-F68C-4872-8408-047D02BBF201}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE