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"/> + + +