ExtensionMethods and finetuning
This commit is contained in:
@ -16,6 +16,7 @@ using YouTubeViewers.EntityFramework.Commands;
|
||||
using YouTubeViewers.EntityFramework.Queries;
|
||||
using YouTubeViewers.WPF.Stores;
|
||||
using YouTubeViewers.WPF.ViewModels;
|
||||
using YouTubeViewers.WPF.HostBuilders;
|
||||
|
||||
namespace YouTubeViewers.WPF;
|
||||
|
||||
@ -27,15 +28,9 @@ public partial class App : Application
|
||||
public App()
|
||||
{
|
||||
_host = Host.CreateDefaultBuilder()
|
||||
.AddDbContext()
|
||||
.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<ICreateYouTubeViewerCommand,CreateYouTubeViewerCommand>();
|
||||
services.AddSingleton<IUpdateYouTubeViewerCommand,UpdateYouTubeViewerCommand>();
|
||||
|
||||
@ -43,7 +43,8 @@
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Row="0"
|
||||
FontSize="24"
|
||||
Text="{Binding UserName}" />
|
||||
Text="{Binding UserName}"
|
||||
TextWrapping="Wrap"/>
|
||||
|
||||
<Grid Grid.Row="1" Margin="0 20 0 0">
|
||||
<Grid.ColumnDefinitions>
|
||||
|
||||
@ -21,7 +21,10 @@
|
||||
x:Name="border"
|
||||
Background="White"
|
||||
CornerRadius="5"/>
|
||||
<ListView BorderThickness="0"
|
||||
<ListView
|
||||
SelectionMode="Single"
|
||||
BorderThickness="0"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||
ItemsSource="{Binding YouTubeViewersListingItemViewModels}"
|
||||
SelectedItem="{Binding SelectedYouTubeViewerListingItemViewModel}">
|
||||
<ListView.ItemContainerStyle>
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
<ColumnDefinition Width="auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel Grid.Column="0">
|
||||
<TextBlock Text="{Binding UserName}"/>
|
||||
<TextBlock Text="{Binding UserName}" />
|
||||
<TextBlock
|
||||
FontSize="10"
|
||||
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}">
|
||||
<ContentControl Margin="50 25" Content="{Binding CurrentModalViewModel}"/>
|
||||
</custom:Modal>
|
||||
|
||||
<views:YouTubeViewersView Margin="25" DataContext="{Binding YouTubeViewersViewModel}" />
|
||||
|
||||
<views:YouTubeViewersView MaxWidth="1000" Margin="25" DataContext="{Binding YouTubeViewersViewModel}" />
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
</Window>
|
||||
|
||||
Reference in New Issue
Block a user