Namelist
This commit is contained in:
14
Apollon.Domain/Commands/ICreateNameListCommand.cs
Normal file
14
Apollon.Domain/Commands/ICreateNameListCommand.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
using Apollon.Domain.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Apollon.Domain.Commands
|
||||||
|
{
|
||||||
|
public interface ICreateNameListCommand
|
||||||
|
{
|
||||||
|
Task Execute(NameList nameList);
|
||||||
|
}
|
||||||
|
}
|
||||||
13
Apollon.Domain/Commands/IDeleteNameListCommand.cs
Normal file
13
Apollon.Domain/Commands/IDeleteNameListCommand.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Apollon.Domain.Commands
|
||||||
|
{
|
||||||
|
public interface IDeleteNameListCommand
|
||||||
|
{
|
||||||
|
Task Execute(Guid id);
|
||||||
|
}
|
||||||
|
}
|
||||||
14
Apollon.Domain/Commands/IUpdateNameListCommand.cs
Normal file
14
Apollon.Domain/Commands/IUpdateNameListCommand.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
using Apollon.Domain.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Apollon.Domain.Commands
|
||||||
|
{
|
||||||
|
public interface IUpdateNameListCommand
|
||||||
|
{
|
||||||
|
Task Exexute(NameList nameList);
|
||||||
|
}
|
||||||
|
}
|
||||||
32
Apollon.Domain/Models/NameList.cs
Normal file
32
Apollon.Domain/Models/NameList.cs
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Apollon.Domain.Models
|
||||||
|
{
|
||||||
|
public class NameList
|
||||||
|
{
|
||||||
|
public NameList(Guid id,string firstName, string lastName, int passNumber, string society, int societyNumber, string birthday, string country)
|
||||||
|
{
|
||||||
|
Id = id;
|
||||||
|
FirstName = firstName;
|
||||||
|
LastName = lastName;
|
||||||
|
PassNumber = passNumber;
|
||||||
|
Society = society;
|
||||||
|
SocietyNumber = societyNumber;
|
||||||
|
Birthday = birthday;
|
||||||
|
Country = country;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Guid Id { get; }
|
||||||
|
public string FirstName { get; }
|
||||||
|
public string LastName { get; }
|
||||||
|
public int PassNumber { get; }
|
||||||
|
public string Society { get; }
|
||||||
|
public int SocietyNumber { get; }
|
||||||
|
public string Birthday { get; }
|
||||||
|
public string Country { get; }
|
||||||
|
}
|
||||||
|
}
|
||||||
14
Apollon.Domain/Queries/IGetAllNamesQuery.cs
Normal file
14
Apollon.Domain/Queries/IGetAllNamesQuery.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
using Apollon.Domain.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Apollon.Domain.Queries
|
||||||
|
{
|
||||||
|
public interface IGetAllNamesQuery
|
||||||
|
{
|
||||||
|
Task<IEnumerable<NameList>> Execute();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,6 +14,7 @@ namespace Apollon.EntityFramework
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
public DbSet<TournamentDto> Tournaments { get; set; }
|
public DbSet<TournamentDto> Tournaments { get; set; }
|
||||||
|
public DbSet<NameListDto> NameList { get; set; }
|
||||||
public DbSet<CompetitionDto> Competition { get; set; }
|
public DbSet<CompetitionDto> Competition { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
42
Apollon.EntityFramework/Commands/CreateNameListCommand.cs
Normal file
42
Apollon.EntityFramework/Commands/CreateNameListCommand.cs
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
using Apollon.Domain.Commands;
|
||||||
|
using Apollon.Domain.Models;
|
||||||
|
using Apollon.EntityFramework.DTOs;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Apollon.EntityFramework.Commands
|
||||||
|
{
|
||||||
|
public class CreateNameListCommand : ICreateNameListCommand
|
||||||
|
{
|
||||||
|
private readonly ApplicationDBContextFactory _contextFactory;
|
||||||
|
|
||||||
|
public CreateNameListCommand(ApplicationDBContextFactory dbContextFactory)
|
||||||
|
{
|
||||||
|
_contextFactory = dbContextFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task Execute(NameList nameList)
|
||||||
|
{
|
||||||
|
using (ApplicationDbContext context = _contextFactory.Create())
|
||||||
|
{
|
||||||
|
NameListDto nameListDto = new NameListDto()
|
||||||
|
{
|
||||||
|
Id = nameList.Id,
|
||||||
|
FirstName = nameList.FirstName,
|
||||||
|
LastName = nameList.Country,
|
||||||
|
PassNumber = nameList.PassNumber,
|
||||||
|
Society = nameList.Society,
|
||||||
|
SocietyNumber = nameList.SocietyNumber,
|
||||||
|
Birthday = nameList.Birthday,
|
||||||
|
Country = nameList.Country,
|
||||||
|
};
|
||||||
|
|
||||||
|
context.NameList.Add(nameListDto);
|
||||||
|
await context.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
34
Apollon.EntityFramework/Commands/DeleteNameListCommand.cs
Normal file
34
Apollon.EntityFramework/Commands/DeleteNameListCommand.cs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
using Apollon.Domain.Commands;
|
||||||
|
using Apollon.EntityFramework.DTOs;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Apollon.EntityFramework.Commands
|
||||||
|
{
|
||||||
|
public class DeleteNameListCommand : IDeleteNameListCommand
|
||||||
|
{
|
||||||
|
private readonly ApplicationDBContextFactory _contextFactory;
|
||||||
|
|
||||||
|
public DeleteNameListCommand(ApplicationDBContextFactory contextFactory)
|
||||||
|
{
|
||||||
|
_contextFactory = contextFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task Execute(Guid id)
|
||||||
|
{
|
||||||
|
using (ApplicationDbContext context = _contextFactory.Create())
|
||||||
|
{
|
||||||
|
NameListDto nameListDto = new NameListDto()
|
||||||
|
{
|
||||||
|
Id = id,
|
||||||
|
};
|
||||||
|
|
||||||
|
context.NameList.Remove(nameListDto);
|
||||||
|
await context.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
41
Apollon.EntityFramework/Commands/UpdateNameListCommand.cs
Normal file
41
Apollon.EntityFramework/Commands/UpdateNameListCommand.cs
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
using Apollon.Domain.Commands;
|
||||||
|
using Apollon.Domain.Models;
|
||||||
|
using Apollon.EntityFramework.DTOs;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Apollon.EntityFramework.Commands
|
||||||
|
{
|
||||||
|
public class UpdateNameListCommand : IUpdateNameListCommand
|
||||||
|
{
|
||||||
|
private readonly ApplicationDBContextFactory _ContextFactory;
|
||||||
|
|
||||||
|
public UpdateNameListCommand(ApplicationDBContextFactory contextFactory)
|
||||||
|
{
|
||||||
|
_ContextFactory = contextFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task Exexute(NameList nameList)
|
||||||
|
{
|
||||||
|
using (ApplicationDbContext context = _ContextFactory.Create())
|
||||||
|
{
|
||||||
|
NameListDto nameListDto = new NameListDto()
|
||||||
|
{
|
||||||
|
Id = nameList.Id,
|
||||||
|
FirstName = nameList.FirstName,
|
||||||
|
LastName = nameList.LastName,
|
||||||
|
PassNumber = nameList.PassNumber,
|
||||||
|
Society = nameList.Society,
|
||||||
|
SocietyNumber = nameList.SocietyNumber,
|
||||||
|
Birthday = nameList.Birthday,
|
||||||
|
Country = nameList.Country,
|
||||||
|
};
|
||||||
|
context.NameList.Update(nameListDto);
|
||||||
|
await context.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
20
Apollon.EntityFramework/DTOs/NameListDto.cs
Normal file
20
Apollon.EntityFramework/DTOs/NameListDto.cs
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Apollon.EntityFramework.DTOs
|
||||||
|
{
|
||||||
|
public class NameListDto
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
public string FirstName { get; set; }
|
||||||
|
public string LastName { get; set; }
|
||||||
|
public int PassNumber { get; set; }
|
||||||
|
public string Society { get; set; }
|
||||||
|
public int SocietyNumber { get; set; }
|
||||||
|
public string Birthday { get; set; }
|
||||||
|
public string Country { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
40
Apollon.EntityFramework/Queries/GetAllNamesQuery.cs
Normal file
40
Apollon.EntityFramework/Queries/GetAllNamesQuery.cs
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
using Apollon.Domain.Models;
|
||||||
|
using Apollon.Domain.Queries;
|
||||||
|
using Apollon.EntityFramework.DTOs;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Apollon.EntityFramework.Queries
|
||||||
|
{
|
||||||
|
public class GetAllNamesQuery : IGetAllNamesQuery
|
||||||
|
{
|
||||||
|
private readonly ApplicationDBContextFactory _contextFactory;
|
||||||
|
|
||||||
|
public GetAllNamesQuery(ApplicationDBContextFactory contextFactory)
|
||||||
|
{
|
||||||
|
_contextFactory = contextFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<NameList>> Execute()
|
||||||
|
{
|
||||||
|
using (ApplicationDbContext context = _contextFactory.Create())
|
||||||
|
{
|
||||||
|
IEnumerable<NameListDto> nameListDtos = await context.NameList.ToListAsync();
|
||||||
|
|
||||||
|
return nameListDtos.Select(y => new NameList(
|
||||||
|
y.Id,
|
||||||
|
y.FirstName,
|
||||||
|
y.LastName,
|
||||||
|
y.PassNumber,
|
||||||
|
y.Society,
|
||||||
|
y.SocietyNumber,
|
||||||
|
y.Birthday,
|
||||||
|
y.Country));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,5 +8,102 @@ namespace Apollon.WPF.ViewModels
|
|||||||
{
|
{
|
||||||
public class NameListViewModel : ViewModelBase
|
public class NameListViewModel : ViewModelBase
|
||||||
{
|
{
|
||||||
|
private string _firstName;
|
||||||
|
public string FirstName
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _firstName;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_firstName = value;
|
||||||
|
OnPropertyChanged(nameof(FirstName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string _lastName;
|
||||||
|
public string LastName
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _lastName;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_lastName = value;
|
||||||
|
OnPropertyChanged(nameof(LastName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int _passNumber;
|
||||||
|
public int PassNumber
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _passNumber;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_passNumber = value;
|
||||||
|
OnPropertyChanged(nameof(PassNumber));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string _society;
|
||||||
|
public string Society
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _society;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_society = value;
|
||||||
|
OnPropertyChanged(nameof(Society));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int _societyNumber;
|
||||||
|
public int SocietyNumber
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _societyNumber;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_societyNumber = value;
|
||||||
|
OnPropertyChanged(nameof(SocietyNumber));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string _birthday;
|
||||||
|
public string Birthday
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _birthday;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_birthday = value;
|
||||||
|
OnPropertyChanged(nameof(Birthday));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string _country;
|
||||||
|
public string Country
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _country;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_country = value;
|
||||||
|
OnPropertyChanged(nameof(Country));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,12 +4,22 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:local="clr-namespace:Apollon.WPF.Views"
|
xmlns:local="clr-namespace:Apollon.WPF.Views"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d">
|
||||||
d:DesignHeight="450" d:DesignWidth="800">
|
<Grid Margin="35">
|
||||||
<Grid>
|
<DataGrid FontSize="14"
|
||||||
<TextBlock Text="Stammdaten"
|
HorizontalAlignment="Center"
|
||||||
FontSize="30"
|
CanUserAddRows="True"
|
||||||
TextAlignment="Center"
|
AutoGenerateColumns="True">
|
||||||
VerticalAlignment="Center"/>
|
<DataGrid.Columns>
|
||||||
|
<DataGridTextColumn Width="120" Header="Vorname" Binding="{Binding FirstName}"/>
|
||||||
|
<DataGridTextColumn Width="120" Header="Nachname" Binding="{Binding LastName}" />
|
||||||
|
<DataGridTextColumn Width="120" Header="Passnummer" Binding="{Binding PassNumber}"/>
|
||||||
|
<DataGridTextColumn Width="150" Header="Verein" Binding="{Binding Society}" />
|
||||||
|
<DataGridTextColumn Width="120" Header="Vereinsnummer" Binding="{Binding SocietyNumber}"/>
|
||||||
|
<DataGridTextColumn Width="100" Header="Geburtsdatum" Binding="{Binding Birthday}" />
|
||||||
|
<DataGridTextColumn Header="Bundesland" Binding="{Binding Country}"/>
|
||||||
|
</DataGrid.Columns>
|
||||||
|
|
||||||
|
</DataGrid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|||||||
Reference in New Issue
Block a user