From cc6636528c781cf99f6c3f0e08ec1febe7e16393 Mon Sep 17 00:00:00 2001 From: Natlinux <97396587+Natlinux81@users.noreply.github.com> Date: Mon, 7 Nov 2022 20:59:15 +0100 Subject: [PATCH] combine competitionlist with combobox --- Apollon.Domain/Apollon.Domain.csproj | 2 +- Apollon.Domain/Models/Competition.cs | 14 ++++ .../20221107194347_competition.Designer.cs | 64 +++++++++++++++++++ .../Migrations/20221107194347_competition.cs | 19 ++++++ Apollon.WPF/MainWindow.xaml | 4 ++ .../ViewModels/AddEditDetailsViewModel.cs | 32 ++++++++-- .../Views/Components/AddEditDetails.xaml | 13 ++-- 7 files changed, 132 insertions(+), 16 deletions(-) create mode 100644 Apollon.Domain/Models/Competition.cs create mode 100644 Apollon.EntityFramework/Migrations/20221107194347_competition.Designer.cs create mode 100644 Apollon.EntityFramework/Migrations/20221107194347_competition.cs diff --git a/Apollon.Domain/Apollon.Domain.csproj b/Apollon.Domain/Apollon.Domain.csproj index 132c02c..141e38f 100644 --- a/Apollon.Domain/Apollon.Domain.csproj +++ b/Apollon.Domain/Apollon.Domain.csproj @@ -3,7 +3,7 @@ net6.0 enable - enable + disable diff --git a/Apollon.Domain/Models/Competition.cs b/Apollon.Domain/Models/Competition.cs new file mode 100644 index 0000000..c126f70 --- /dev/null +++ b/Apollon.Domain/Models/Competition.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Apollon.Domain.Models +{ + public class Competition + { + public string CompetitionName{ get; set; } + public string CompetitionImage{ get; set; } + } +} diff --git a/Apollon.EntityFramework/Migrations/20221107194347_competition.Designer.cs b/Apollon.EntityFramework/Migrations/20221107194347_competition.Designer.cs new file mode 100644 index 0000000..ce630ff --- /dev/null +++ b/Apollon.EntityFramework/Migrations/20221107194347_competition.Designer.cs @@ -0,0 +1,64 @@ +// +using System; +using Apollon.EntityFramework; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Apollon.EntityFramework.Migrations +{ + [DbContext(typeof(TournamentsDbContext))] + [Migration("20221107194347_competition")] + partial class competition + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.8") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("Apollon.EntityFramework.DTOs.TournamentDto", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Competition") + .HasColumnType("nvarchar(max)"); + + b.Property("CompetitionImage") + .HasColumnType("nvarchar(max)"); + + b.Property("EndDate") + .HasColumnType("datetime2"); + + b.Property("Location") + .HasColumnType("nvarchar(max)"); + + b.Property("Organisation") + .HasColumnType("nvarchar(max)"); + + b.Property("Rounds") + .HasColumnType("int"); + + b.Property("StartDate") + .HasColumnType("datetime2"); + + b.Property("TournamentName") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Tournaments"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Apollon.EntityFramework/Migrations/20221107194347_competition.cs b/Apollon.EntityFramework/Migrations/20221107194347_competition.cs new file mode 100644 index 0000000..532f1a4 --- /dev/null +++ b/Apollon.EntityFramework/Migrations/20221107194347_competition.cs @@ -0,0 +1,19 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Apollon.EntityFramework.Migrations +{ + public partial class competition : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} diff --git a/Apollon.WPF/MainWindow.xaml b/Apollon.WPF/MainWindow.xaml index 0a4d585..8e04884 100644 --- a/Apollon.WPF/MainWindow.xaml +++ b/Apollon.WPF/MainWindow.xaml @@ -4,6 +4,7 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:Apollon.WPF" + xmlns:components="clr-namespace:Apollon.WPF.Views.Components" xmlns:views="clr-namespace:Apollon.WPF.Views" xmlns:vms="clr-namespace:Apollon.WPF.ViewModels" xmlns:custom="clr-namespace:ModalControl;assembly=ModalControl" @@ -30,6 +31,9 @@ + + + diff --git a/Apollon.WPF/ViewModels/AddEditDetailsViewModel.cs b/Apollon.WPF/ViewModels/AddEditDetailsViewModel.cs index 47b4c6e..980acf2 100644 --- a/Apollon.WPF/ViewModels/AddEditDetailsViewModel.cs +++ b/Apollon.WPF/ViewModels/AddEditDetailsViewModel.cs @@ -1,4 +1,5 @@ -using Microsoft.EntityFrameworkCore; +using Apollon.Domain.Models; +using Microsoft.EntityFrameworkCore; using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -166,19 +167,38 @@ namespace Apollon.WPF.ViewModels public ICommand SubmitCommand { get; } public ICommand CancelCommand { get; } - public ObservableCollection CompetitionList { get; set; } + public ObservableCollection CompetitionList { get; set; } public AddEditDetailsViewModel(ICommand submitCommand, ICommand cancelCommand) { SubmitCommand = submitCommand; CancelCommand = cancelCommand; - CompetitionList = new ObservableCollection + CompetitionList = new ObservableCollection { - "Halle", "im Freien", "Feld", "3D" - }; + new Competition + { + CompetitionName = "Halle", + CompetitionImage = "targetHall.png" + }, + new Competition + { + CompetitionName = "im Freien", + CompetitionImage ="targetOutdoor.png" + }, + new Competition + { + CompetitionName = "Feld", + CompetitionImage = "targetField.png" + }, - Competition = CompetitionList[1]; + new Competition + { + CompetitionName = "3D", + CompetitionImage = "3d.png" + } + + }; } } diff --git a/Apollon.WPF/Views/Components/AddEditDetails.xaml b/Apollon.WPF/Views/Components/AddEditDetails.xaml index 8fe76fe..e46e496 100644 --- a/Apollon.WPF/Views/Components/AddEditDetails.xaml +++ b/Apollon.WPF/Views/Components/AddEditDetails.xaml @@ -70,8 +70,7 @@ VerticalContentAlignment="Center" Background="LightGray"/> - - + ItemsSource="{Binding CompetitionList}" + DisplayMemberPath="CompetitionName"> - +