From d4dd7a545a4244e52d058b9f130ac33e474b9810 Mon Sep 17 00:00:00 2001 From: Natlinux <97396587+Natlinux81@users.noreply.github.com> Date: Thu, 10 Nov 2022 22:48:47 +0100 Subject: [PATCH] select logo --- Apollon.Domain/Models/Tournament.cs | 4 +- .../Commands/CreateTournamentCommand.cs | 1 + .../Commands/UpdateTournamentCommand.cs | 1 + Apollon.EntityFramework/DTOs/TournamentDto.cs | 1 + .../20221110003817_logo.Designer.cs | 67 +++++++++++++++ .../Migrations/20221110003817_logo.cs | 25 ++++++ .../TournamentsDbContextModelSnapshot.cs | 3 + .../Queries/GetAllTournamentsQuery.cs | 1 + Apollon.WPF/Commands/AddTournamentCommand.cs | 1 + Apollon.WPF/Commands/ChooseLogoCommand.cs | 40 +++++++++ Apollon.WPF/Commands/EditTournamentCommand.cs | 1 + .../ViewModels/AddEditDetailsViewModel.cs | 27 ++++-- .../ViewModels/OverviewDetailsViewModel.cs | 2 + .../ViewModels/TournamentDetailsViewModel.cs | 1 + .../Views/Components/AddEditDetails.xaml | 29 ++++++- .../Views/Components/OverviewDetails.xaml | 78 ++++++++++++------ .../Views/Components/TournamentDetails.xaml | 2 +- Apollon.WPF/images/Logos/logo_gross_BD.jpg | Bin 0 -> 108231 bytes Apollon.WPF/images/Logos/logo_gross_BL.jpg | Bin 0 -> 161234 bytes Apollon.WPF/images/Logos/logo_gross_BR.jpg | Bin 0 -> 153295 bytes Apollon.WPF/images/Logos/logo_gross_BY.jpg | Bin 0 -> 701396 bytes .../images/Logos/logo_gross_Beispiel.jpg | Bin 0 -> 19104 bytes Apollon.WPF/images/Logos/logo_gross_HH.jpg | Bin 0 -> 161151 bytes Apollon.WPF/images/Logos/logo_gross_HS.jpg | Bin 0 -> 381250 bytes Apollon.WPF/images/Logos/logo_gross_MV.jpg | Bin 0 -> 143915 bytes Apollon.WPF/images/Logos/logo_gross_ND.jpg | Bin 0 -> 95643 bytes Apollon.WPF/images/Logos/logo_gross_NS.jpg | Bin 0 -> 150663 bytes Apollon.WPF/images/Logos/logo_gross_NW.jpg | Bin 0 -> 189425 bytes Apollon.WPF/images/Logos/logo_gross_OP.jpg | Bin 0 -> 165630 bytes Apollon.WPF/images/Logos/logo_gross_PF.jpg | Bin 0 -> 238715 bytes Apollon.WPF/images/Logos/logo_gross_RH.jpg | Bin 0 -> 144963 bytes Apollon.WPF/images/Logos/logo_gross_RP.jpg | Bin 0 -> 1292 bytes Apollon.WPF/images/Logos/logo_gross_SA.jpg | Bin 0 -> 204242 bytes Apollon.WPF/images/Logos/logo_gross_SB.jpg | Bin 0 -> 213883 bytes Apollon.WPF/images/Logos/logo_gross_SC.jpg | Bin 0 -> 142369 bytes Apollon.WPF/images/Logos/logo_gross_ST.jpg | Bin 0 -> 170321 bytes Apollon.WPF/images/Logos/logo_gross_TH.jpg | Bin 0 -> 171849 bytes Apollon.WPF/images/Logos/logo_gross_WF.jpg | Bin 0 -> 179614 bytes Apollon.WPF/images/Logos/logo_gross_WT.jpg | Bin 0 -> 44751 bytes Apollon.WPF/images/Logos/logo_gross_WTMS.jpg | Bin 0 -> 1275170 bytes Apollon.WPF/images/Logos/logo_klein_BD.jpg | Bin 0 -> 54865 bytes Apollon.WPF/images/Logos/logo_klein_BL.jpg | Bin 0 -> 51257 bytes Apollon.WPF/images/Logos/logo_klein_BR.jpg | Bin 0 -> 66986 bytes Apollon.WPF/images/Logos/logo_klein_BY.jpg | Bin 0 -> 193528 bytes .../images/Logos/logo_klein_Beispiel.jpg | Bin 0 -> 11464 bytes Apollon.WPF/images/Logos/logo_klein_HH.jpg | Bin 0 -> 62765 bytes Apollon.WPF/images/Logos/logo_klein_HS.jpg | Bin 0 -> 73934 bytes Apollon.WPF/images/Logos/logo_klein_MV.jpg | Bin 0 -> 55758 bytes Apollon.WPF/images/Logos/logo_klein_ND.jpg | Bin 0 -> 37952 bytes Apollon.WPF/images/Logos/logo_klein_NS.jpg | Bin 0 -> 59031 bytes Apollon.WPF/images/Logos/logo_klein_NW.jpg | Bin 0 -> 63952 bytes Apollon.WPF/images/Logos/logo_klein_OP.jpg | Bin 0 -> 65132 bytes Apollon.WPF/images/Logos/logo_klein_PF.jpg | Bin 0 -> 86464 bytes Apollon.WPF/images/Logos/logo_klein_RH.jpg | Bin 0 -> 60726 bytes Apollon.WPF/images/Logos/logo_klein_RP.jpg | Bin 0 -> 4872 bytes Apollon.WPF/images/Logos/logo_klein_SA.jpg | Bin 0 -> 76962 bytes Apollon.WPF/images/Logos/logo_klein_SB.jpg | Bin 0 -> 80255 bytes Apollon.WPF/images/Logos/logo_klein_SC.jpg | Bin 0 -> 58310 bytes Apollon.WPF/images/Logos/logo_klein_ST.jpg | Bin 0 -> 66074 bytes Apollon.WPF/images/Logos/logo_klein_TH.jpg | Bin 0 -> 63349 bytes Apollon.WPF/images/Logos/logo_klein_WF.jpg | Bin 0 -> 68697 bytes Apollon.WPF/images/Logos/logo_klein_WT.jpg | Bin 0 -> 24660 bytes Apollon.WPF/images/Logos/logo_klein_WTMS.jpg | Bin 0 -> 462831 bytes 63 files changed, 247 insertions(+), 37 deletions(-) create mode 100644 Apollon.EntityFramework/Migrations/20221110003817_logo.Designer.cs create mode 100644 Apollon.EntityFramework/Migrations/20221110003817_logo.cs create mode 100644 Apollon.WPF/Commands/ChooseLogoCommand.cs create mode 100644 Apollon.WPF/images/Logos/logo_gross_BD.jpg create mode 100644 Apollon.WPF/images/Logos/logo_gross_BL.jpg create mode 100644 Apollon.WPF/images/Logos/logo_gross_BR.jpg create mode 100644 Apollon.WPF/images/Logos/logo_gross_BY.jpg create mode 100644 Apollon.WPF/images/Logos/logo_gross_Beispiel.jpg create mode 100644 Apollon.WPF/images/Logos/logo_gross_HH.jpg create mode 100644 Apollon.WPF/images/Logos/logo_gross_HS.jpg create mode 100644 Apollon.WPF/images/Logos/logo_gross_MV.jpg create mode 100644 Apollon.WPF/images/Logos/logo_gross_ND.jpg create mode 100644 Apollon.WPF/images/Logos/logo_gross_NS.jpg create mode 100644 Apollon.WPF/images/Logos/logo_gross_NW.jpg create mode 100644 Apollon.WPF/images/Logos/logo_gross_OP.jpg create mode 100644 Apollon.WPF/images/Logos/logo_gross_PF.jpg create mode 100644 Apollon.WPF/images/Logos/logo_gross_RH.jpg create mode 100644 Apollon.WPF/images/Logos/logo_gross_RP.jpg create mode 100644 Apollon.WPF/images/Logos/logo_gross_SA.jpg create mode 100644 Apollon.WPF/images/Logos/logo_gross_SB.jpg create mode 100644 Apollon.WPF/images/Logos/logo_gross_SC.jpg create mode 100644 Apollon.WPF/images/Logos/logo_gross_ST.jpg create mode 100644 Apollon.WPF/images/Logos/logo_gross_TH.jpg create mode 100644 Apollon.WPF/images/Logos/logo_gross_WF.jpg create mode 100644 Apollon.WPF/images/Logos/logo_gross_WT.jpg create mode 100644 Apollon.WPF/images/Logos/logo_gross_WTMS.jpg create mode 100644 Apollon.WPF/images/Logos/logo_klein_BD.jpg create mode 100644 Apollon.WPF/images/Logos/logo_klein_BL.jpg create mode 100644 Apollon.WPF/images/Logos/logo_klein_BR.jpg create mode 100644 Apollon.WPF/images/Logos/logo_klein_BY.jpg create mode 100644 Apollon.WPF/images/Logos/logo_klein_Beispiel.jpg create mode 100644 Apollon.WPF/images/Logos/logo_klein_HH.jpg create mode 100644 Apollon.WPF/images/Logos/logo_klein_HS.jpg create mode 100644 Apollon.WPF/images/Logos/logo_klein_MV.jpg create mode 100644 Apollon.WPF/images/Logos/logo_klein_ND.jpg create mode 100644 Apollon.WPF/images/Logos/logo_klein_NS.jpg create mode 100644 Apollon.WPF/images/Logos/logo_klein_NW.jpg create mode 100644 Apollon.WPF/images/Logos/logo_klein_OP.jpg create mode 100644 Apollon.WPF/images/Logos/logo_klein_PF.jpg create mode 100644 Apollon.WPF/images/Logos/logo_klein_RH.jpg create mode 100644 Apollon.WPF/images/Logos/logo_klein_RP.jpg create mode 100644 Apollon.WPF/images/Logos/logo_klein_SA.jpg create mode 100644 Apollon.WPF/images/Logos/logo_klein_SB.jpg create mode 100644 Apollon.WPF/images/Logos/logo_klein_SC.jpg create mode 100644 Apollon.WPF/images/Logos/logo_klein_ST.jpg create mode 100644 Apollon.WPF/images/Logos/logo_klein_TH.jpg create mode 100644 Apollon.WPF/images/Logos/logo_klein_WF.jpg create mode 100644 Apollon.WPF/images/Logos/logo_klein_WT.jpg create mode 100644 Apollon.WPF/images/Logos/logo_klein_WTMS.jpg diff --git a/Apollon.Domain/Models/Tournament.cs b/Apollon.Domain/Models/Tournament.cs index b380897..b78c5f1 100644 --- a/Apollon.Domain/Models/Tournament.cs +++ b/Apollon.Domain/Models/Tournament.cs @@ -8,9 +8,10 @@ namespace Apollon.Domain.Models { public class Tournament { - public Tournament(Guid id, string organisation, string tournamentName, string competition, string competitionImage, DateTime startDate, DateTime endDate, string location, int rounds) + public Tournament(Guid id, string logo, string organisation, string tournamentName, string competition, string competitionImage, DateTime startDate, DateTime endDate, string location, int rounds) { Id = id; + Logo = logo; Organisation = organisation; TournamentName = tournamentName; Competition = competition; @@ -22,6 +23,7 @@ namespace Apollon.Domain.Models } public Guid Id { get; } + public string Logo { get; } public string Organisation { get; } public string TournamentName { get; } public string Competition { get; } diff --git a/Apollon.EntityFramework/Commands/CreateTournamentCommand.cs b/Apollon.EntityFramework/Commands/CreateTournamentCommand.cs index d139171..c4aad26 100644 --- a/Apollon.EntityFramework/Commands/CreateTournamentCommand.cs +++ b/Apollon.EntityFramework/Commands/CreateTournamentCommand.cs @@ -26,6 +26,7 @@ namespace Apollon.EntityFramework.Commands TournamentDto tournamentDto = new TournamentDto() { Id = tournament.Id, + Logo = tournament.Logo, Organisation = tournament.Organisation, TournamentName = tournament.TournamentName, Competition = tournament.Competition, diff --git a/Apollon.EntityFramework/Commands/UpdateTournamentCommand.cs b/Apollon.EntityFramework/Commands/UpdateTournamentCommand.cs index f06cd65..1f77d45 100644 --- a/Apollon.EntityFramework/Commands/UpdateTournamentCommand.cs +++ b/Apollon.EntityFramework/Commands/UpdateTournamentCommand.cs @@ -25,6 +25,7 @@ namespace Apollon.EntityFramework.Commands TournamentDto tournamentDto = new TournamentDto() { Id = tournament.Id, + Logo = tournament.Logo, Organisation = tournament.Organisation, TournamentName = tournament.TournamentName, Competition = tournament.Competition, diff --git a/Apollon.EntityFramework/DTOs/TournamentDto.cs b/Apollon.EntityFramework/DTOs/TournamentDto.cs index d51cd03..fd4d40a 100644 --- a/Apollon.EntityFramework/DTOs/TournamentDto.cs +++ b/Apollon.EntityFramework/DTOs/TournamentDto.cs @@ -9,6 +9,7 @@ namespace Apollon.EntityFramework.DTOs public class TournamentDto { public Guid Id { get; set; } + public string Logo { get; set; } public string Organisation { get; set; } public string TournamentName { get; set; } public string Competition { get; set; } diff --git a/Apollon.EntityFramework/Migrations/20221110003817_logo.Designer.cs b/Apollon.EntityFramework/Migrations/20221110003817_logo.Designer.cs new file mode 100644 index 0000000..ebf683b --- /dev/null +++ b/Apollon.EntityFramework/Migrations/20221110003817_logo.Designer.cs @@ -0,0 +1,67 @@ +// +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("20221110003817_logo")] + partial class logo + { + 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("Logo") + .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/20221110003817_logo.cs b/Apollon.EntityFramework/Migrations/20221110003817_logo.cs new file mode 100644 index 0000000..47ff0df --- /dev/null +++ b/Apollon.EntityFramework/Migrations/20221110003817_logo.cs @@ -0,0 +1,25 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Apollon.EntityFramework.Migrations +{ + public partial class logo : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "Logo", + table: "Tournaments", + type: "nvarchar(max)", + nullable: true); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Logo", + table: "Tournaments"); + } + } +} diff --git a/Apollon.EntityFramework/Migrations/TournamentsDbContextModelSnapshot.cs b/Apollon.EntityFramework/Migrations/TournamentsDbContextModelSnapshot.cs index 022de9b..30548d1 100644 --- a/Apollon.EntityFramework/Migrations/TournamentsDbContextModelSnapshot.cs +++ b/Apollon.EntityFramework/Migrations/TournamentsDbContextModelSnapshot.cs @@ -40,6 +40,9 @@ namespace Apollon.EntityFramework.Migrations b.Property("Location") .HasColumnType("nvarchar(max)"); + b.Property("Logo") + .HasColumnType("nvarchar(max)"); + b.Property("Organisation") .HasColumnType("nvarchar(max)"); diff --git a/Apollon.EntityFramework/Queries/GetAllTournamentsQuery.cs b/Apollon.EntityFramework/Queries/GetAllTournamentsQuery.cs index 5ec300c..e890537 100644 --- a/Apollon.EntityFramework/Queries/GetAllTournamentsQuery.cs +++ b/Apollon.EntityFramework/Queries/GetAllTournamentsQuery.cs @@ -27,6 +27,7 @@ namespace Apollon.EntityFramework.Queries return tournamentsDtos.Select(y => new Tournament( y.Id, + y.Logo, y.Organisation, y.TournamentName, y.Competition, diff --git a/Apollon.WPF/Commands/AddTournamentCommand.cs b/Apollon.WPF/Commands/AddTournamentCommand.cs index 1beb7cf..9feb836 100644 --- a/Apollon.WPF/Commands/AddTournamentCommand.cs +++ b/Apollon.WPF/Commands/AddTournamentCommand.cs @@ -36,6 +36,7 @@ namespace Apollon.WPF.Commands Tournament tournament = new Tournament( Guid.NewGuid(), + detailsViewModel.Logo, detailsViewModel.Organisation, detailsViewModel.TournamentName, detailsViewModel.Competition, diff --git a/Apollon.WPF/Commands/ChooseLogoCommand.cs b/Apollon.WPF/Commands/ChooseLogoCommand.cs new file mode 100644 index 0000000..0ccc45c --- /dev/null +++ b/Apollon.WPF/Commands/ChooseLogoCommand.cs @@ -0,0 +1,40 @@ +using Apollon.WPF.ViewModels; +using Microsoft.Win32; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Web; +using System.Windows; + +namespace Apollon.WPF.Commands +{ + public class ChooseLogoCommand : CommandBase + { + + private readonly AddEditDetailsViewModel _addEditDetailsViewModel; + + public ChooseLogoCommand(AddEditDetailsViewModel addEditDetailsViewModel) + { + _addEditDetailsViewModel = addEditDetailsViewModel; + } + + public override void Execute(object parameter) + { + OpenFileDialog openFileDialog = new OpenFileDialog() + { + Title = "Logo wählen", + Filter = "Picture (.jpg) | *.jpg", + + }; + + bool? result = openFileDialog.ShowDialog(); + + if (result == true) + { + _addEditDetailsViewModel.Logo = openFileDialog.FileName; + } + } + } +} diff --git a/Apollon.WPF/Commands/EditTournamentCommand.cs b/Apollon.WPF/Commands/EditTournamentCommand.cs index 7abd6ce..11849e3 100644 --- a/Apollon.WPF/Commands/EditTournamentCommand.cs +++ b/Apollon.WPF/Commands/EditTournamentCommand.cs @@ -31,6 +31,7 @@ namespace Apollon.WPF.Commands Tournament tournament = new Tournament( _editTournamentViewModel.TournamentId, + detailsViewModel.Logo, detailsViewModel.Organisation, detailsViewModel.TournamentName, detailsViewModel.Competition, diff --git a/Apollon.WPF/ViewModels/AddEditDetailsViewModel.cs b/Apollon.WPF/ViewModels/AddEditDetailsViewModel.cs index 8b52b10..a982f18 100644 --- a/Apollon.WPF/ViewModels/AddEditDetailsViewModel.cs +++ b/Apollon.WPF/ViewModels/AddEditDetailsViewModel.cs @@ -1,4 +1,5 @@ using Apollon.Domain.Models; +using Apollon.WPF.Commands; using Microsoft.EntityFrameworkCore; using System; using System.Collections.Generic; @@ -15,7 +16,20 @@ namespace Apollon.WPF.ViewModels { public class AddEditDetailsViewModel : ViewModelBase { - + private string logo; + public string Logo + { + get + { + return logo; + } + set + { + logo = value; + OnPropertyChanged(nameof(Logo)); + } + } + private string _organisation; public string Organisation { @@ -183,13 +197,16 @@ namespace Apollon.WPF.ViewModels public ICommand SubmitCommand { get; } public ICommand CancelCommand { get; } + public ICommand ChooseLogoCommand { get; } - public ObservableCollection CompetitionList { get; set; } - - public AddEditDetailsViewModel(ICommand submitCommand, ICommand cancelCommand) + public ObservableCollection CompetitionList { get; } + + + public AddEditDetailsViewModel(ICommand submitCommand, ICommand cancelCommand) { SubmitCommand = submitCommand; CancelCommand = cancelCommand; + ChooseLogoCommand = new ChooseLogoCommand(this); CompetitionList = new ObservableCollection { @@ -214,9 +231,7 @@ namespace Apollon.WPF.ViewModels CompetitionName = "3D", CompetitionImage = @"\Images\3d.png" } - }; } } - } diff --git a/Apollon.WPF/ViewModels/OverviewDetailsViewModel.cs b/Apollon.WPF/ViewModels/OverviewDetailsViewModel.cs index 6f44d70..964f8ec 100644 --- a/Apollon.WPF/ViewModels/OverviewDetailsViewModel.cs +++ b/Apollon.WPF/ViewModels/OverviewDetailsViewModel.cs @@ -16,6 +16,7 @@ namespace Apollon.WPF.ViewModels private Tournament SelectedTournament => _selectedTournamentStore.SelectedTournament; public bool HasSelectedTournament => SelectedTournament != null; + public string Logo => SelectedTournament?.Logo ?? "D:\\Projekte\\Apollon\\Apollon\\Apollon.WPF\\Images\\Archery.png"; public string Organisation => SelectedTournament?.Organisation ?? "keine Organisation"; public string TournamentName => SelectedTournament?.TournamentName ?? "kein Name"; public string Competition => SelectedTournament?.Competition ?? "keine Kategorie"; @@ -47,6 +48,7 @@ namespace Apollon.WPF.ViewModels private void SelectedTournamentStore_SelectedTournamentChanged() { OnPropertyChanged(nameof(HasSelectedTournament)); + OnPropertyChanged(nameof(Logo)); OnPropertyChanged(nameof(Organisation)); OnPropertyChanged(nameof(TournamentName)); OnPropertyChanged(nameof(Competition)); diff --git a/Apollon.WPF/ViewModels/TournamentDetailsViewModel.cs b/Apollon.WPF/ViewModels/TournamentDetailsViewModel.cs index 511faf9..82da260 100644 --- a/Apollon.WPF/ViewModels/TournamentDetailsViewModel.cs +++ b/Apollon.WPF/ViewModels/TournamentDetailsViewModel.cs @@ -18,6 +18,7 @@ namespace Apollon.WPF.ViewModels private Tournament SelectedTournament => _selectedTournamentsStore.SelectedTournament; public bool HasSelectedTournament => SelectedTournament != null; + public string Logo => SelectedTournament?.Logo ?? "D:\\Projekte\\Apollon\\Apollon\\Apollon.WPF\\Images\\Archery.png"; public string Organisation => SelectedTournament?.Organisation ?? "keine Organisation"; public string TournamentName => SelectedTournament?.TournamentName ?? "kein Name"; public string Competition => SelectedTournament?.Competition ?? "keine Kategorie"; diff --git a/Apollon.WPF/Views/Components/AddEditDetails.xaml b/Apollon.WPF/Views/Components/AddEditDetails.xaml index 0fa0b96..ce890e7 100644 --- a/Apollon.WPF/Views/Components/AddEditDetails.xaml +++ b/Apollon.WPF/Views/Components/AddEditDetails.xaml @@ -58,8 +58,10 @@ FontFamily="Arial" FontSize="16" Height="30" + Width="300" Background="LightGray" - VerticalContentAlignment="Center"/> + VerticalContentAlignment="Center" + HorizontalAlignment="Left"/> + + +