ExtensionMethods and finetuning
This commit is contained in:
@ -16,6 +16,7 @@ using YouTubeViewers.EntityFramework.Commands;
|
|||||||
using YouTubeViewers.EntityFramework.Queries;
|
using YouTubeViewers.EntityFramework.Queries;
|
||||||
using YouTubeViewers.WPF.Stores;
|
using YouTubeViewers.WPF.Stores;
|
||||||
using YouTubeViewers.WPF.ViewModels;
|
using YouTubeViewers.WPF.ViewModels;
|
||||||
|
using YouTubeViewers.WPF.HostBuilders;
|
||||||
|
|
||||||
namespace YouTubeViewers.WPF;
|
namespace YouTubeViewers.WPF;
|
||||||
|
|
||||||
@ -27,15 +28,9 @@ public partial class App : Application
|
|||||||
public App()
|
public App()
|
||||||
{
|
{
|
||||||
_host = Host.CreateDefaultBuilder()
|
_host = Host.CreateDefaultBuilder()
|
||||||
|
.AddDbContext()
|
||||||
.ConfigureServices((context, services) =>
|
.ConfigureServices((context, services) =>
|
||||||
{
|
{
|
||||||
string connectionString = context.Configuration.GetConnectionString("sqlite");
|
|
||||||
services.AddSingleton<DbContextOptions>(
|
|
||||||
new DbContextOptionsBuilder()
|
|
||||||
.UseSqlite(connectionString)
|
|
||||||
.Options);
|
|
||||||
services.AddSingleton<YouTubeViewersDbContextFactory>();
|
|
||||||
|
|
||||||
services.AddSingleton<IGetAllYouTubeViewersQuery,GetAllYouTubeViewersQuery>();
|
services.AddSingleton<IGetAllYouTubeViewersQuery,GetAllYouTubeViewersQuery>();
|
||||||
services.AddSingleton<ICreateYouTubeViewerCommand,CreateYouTubeViewerCommand>();
|
services.AddSingleton<ICreateYouTubeViewerCommand,CreateYouTubeViewerCommand>();
|
||||||
services.AddSingleton<IUpdateYouTubeViewerCommand,UpdateYouTubeViewerCommand>();
|
services.AddSingleton<IUpdateYouTubeViewerCommand,UpdateYouTubeViewerCommand>();
|
||||||
|
|||||||
@ -43,7 +43,8 @@
|
|||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<TextBlock Grid.Row="0"
|
<TextBlock Grid.Row="0"
|
||||||
FontSize="24"
|
FontSize="24"
|
||||||
Text="{Binding UserName}" />
|
Text="{Binding UserName}"
|
||||||
|
TextWrapping="Wrap"/>
|
||||||
|
|
||||||
<Grid Grid.Row="1" Margin="0 20 0 0">
|
<Grid Grid.Row="1" Margin="0 20 0 0">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
|
|||||||
@ -21,7 +21,10 @@
|
|||||||
x:Name="border"
|
x:Name="border"
|
||||||
Background="White"
|
Background="White"
|
||||||
CornerRadius="5"/>
|
CornerRadius="5"/>
|
||||||
<ListView BorderThickness="0"
|
<ListView
|
||||||
|
SelectionMode="Single"
|
||||||
|
BorderThickness="0"
|
||||||
|
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||||
ItemsSource="{Binding YouTubeViewersListingItemViewModels}"
|
ItemsSource="{Binding YouTubeViewersListingItemViewModels}"
|
||||||
SelectedItem="{Binding SelectedYouTubeViewerListingItemViewModel}">
|
SelectedItem="{Binding SelectedYouTubeViewerListingItemViewModel}">
|
||||||
<ListView.ItemContainerStyle>
|
<ListView.ItemContainerStyle>
|
||||||
|
|||||||
@ -18,7 +18,7 @@
|
|||||||
<ColumnDefinition Width="auto"/>
|
<ColumnDefinition Width="auto"/>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<StackPanel Grid.Column="0">
|
<StackPanel Grid.Column="0">
|
||||||
<TextBlock Text="{Binding UserName}"/>
|
<TextBlock Text="{Binding UserName}" />
|
||||||
<TextBlock
|
<TextBlock
|
||||||
FontSize="10"
|
FontSize="10"
|
||||||
Style="{StaticResource ErrorMessage}"
|
Style="{StaticResource ErrorMessage}"
|
||||||
|
|||||||
@ -0,0 +1,27 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using YouTubeViewers.EntityFramework;
|
||||||
|
|
||||||
|
namespace YouTubeViewers.WPF.HostBuilders
|
||||||
|
{
|
||||||
|
public static class AddDbContextHostBuilderExtensions
|
||||||
|
{
|
||||||
|
public static IHostBuilder AddDbContext(this IHostBuilder hostBuilder)
|
||||||
|
{
|
||||||
|
hostBuilder.ConfigureServices((context, services) =>
|
||||||
|
{
|
||||||
|
string connectionString = context.Configuration.GetConnectionString("sqlite");
|
||||||
|
services.AddSingleton<DbContextOptions>(new DbContextOptionsBuilder().UseSqlite(connectionString).Options);
|
||||||
|
services.AddSingleton<YouTubeViewersDbContextFactory>();
|
||||||
|
});
|
||||||
|
return hostBuilder;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -27,8 +27,8 @@
|
|||||||
<custom:Modal Panel.ZIndex="1" IsOpen="{Binding IsModalOpen}">
|
<custom:Modal Panel.ZIndex="1" IsOpen="{Binding IsModalOpen}">
|
||||||
<ContentControl Margin="50 25" Content="{Binding CurrentModalViewModel}"/>
|
<ContentControl Margin="50 25" Content="{Binding CurrentModalViewModel}"/>
|
||||||
</custom:Modal>
|
</custom:Modal>
|
||||||
|
|
||||||
<views:YouTubeViewersView Margin="25" DataContext="{Binding YouTubeViewersViewModel}" />
|
<views:YouTubeViewersView MaxWidth="1000" Margin="25" DataContext="{Binding YouTubeViewersViewModel}" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
</Window>
|
</Window>
|
||||||
|
|||||||
Reference in New Issue
Block a user