diff --git a/GreadyPoang.EntityLayer/EntityClasses/GamePoint.cs b/GreadyPoang.EntityLayer/EntityClasses/GamePoint.cs index 76baa0b..1bd6b85 100644 --- a/GreadyPoang.EntityLayer/EntityClasses/GamePoint.cs +++ b/GreadyPoang.EntityLayer/EntityClasses/GamePoint.cs @@ -67,6 +67,9 @@ public class GamePoint : EntityBase } } + // GameRoundRegNr räknas upp när en spelare får en ny gamepoint inlagd + // Alltså hans/hennes senaste i samma runda uppräknad med 1 + [Column("GameRoundRegNr")] public int GameRoundRegNr { diff --git a/GreadyPoang.EntityLayer/HelperEntities/RoundBuilderGroup.cs b/GreadyPoang.EntityLayer/HelperEntities/RoundBuilderGroup.cs new file mode 100644 index 0000000..e2e4a52 --- /dev/null +++ b/GreadyPoang.EntityLayer/HelperEntities/RoundBuilderGroup.cs @@ -0,0 +1,53 @@ +namespace GreadyPoang.EntityLayer; + +public class RoundBuilderGroup +{ + public RoundBuilderGroup() + { + _gameRoundId = 0; + _gameRoundStartDate = DateTime.MinValue; + _status = GamePointStatus.New; + _elements = new List(); + } + private int _gameRoundId; + private DateTime _gameRoundStartDate; + private GamePointStatus _status; + private List _elements; + public int GameRoundId + { + get { return _gameRoundId; } + set + { + _gameRoundId = value; + // No need to raise property changed for this example + } + } + public DateTime GameRoundStartDate + { + get { return _gameRoundStartDate; } + set + { + _gameRoundStartDate = value; + // No need to raise property changed for this example + } + } + public GamePointStatus Status + { + get { return _status; } + set + { + _status = value; + // No need to raise property changed for this example + } + } + + public List Elements + { + get { return _elements; } + set + { + _elements = value; + // No need to raise property changed for this example + } + } +} diff --git a/GreadyPoang.ViewModelLayer/ViewModelClasses/RoundRunningViewModel.cs b/GreadyPoang.ViewModelLayer/ViewModelClasses/RoundRunningViewModel.cs new file mode 100644 index 0000000..c3a781c --- /dev/null +++ b/GreadyPoang.ViewModelLayer/ViewModelClasses/RoundRunningViewModel.cs @@ -0,0 +1,39 @@ +using Common.Library; +using GreadyPoang.DataLayer; +using GreadyPoang.EntityLayer; +using System.Collections.ObjectModel; + +namespace GreadyPoang.ViewModelLayer; + +public class RoundRunningViewModel : ViewModelBase +{ + + public RoundRunningViewModel() : base() + { + } + + public RoundRunningViewModel( + + IRepository roundsRepo, + IRepository pointsRepo, + IMethodSharingService sharingService, + ICombinedRepository combined + ) : base() + { + _roundsRepo = roundsRepo; + _pointsRepo = pointsRepo; + _sharingService = sharingService; + _combined = combined; + } + + private readonly IRepository? _roundsRepo; + private readonly IRepository _pointsRepo; + private readonly IMethodSharingService _sharingService; + private readonly ICombinedRepository _combined; + + private ObservableCollection _GameRoundList = new(); + private ObservableCollection _ParticipantList = new(); + private ObservableCollection _roundElements; + + +} diff --git a/GreadyPoang.ViewModelLayer/ViewModelClasses/RoundStartingViewModel.cs b/GreadyPoang.ViewModelLayer/ViewModelClasses/RoundStartingViewModel.cs index 28f5b60..e81e49a 100644 --- a/GreadyPoang.ViewModelLayer/ViewModelClasses/RoundStartingViewModel.cs +++ b/GreadyPoang.ViewModelLayer/ViewModelClasses/RoundStartingViewModel.cs @@ -15,12 +15,12 @@ public class RoundStartingViewModel : ViewModelBase } public RoundStartingViewModel( - IRepository repo, + IRepository roundsRepo, IRepository pointsRepo, IMethodSharingService sharingService, ICombinedRepository combined) : base() { - _Repository = repo; + _roundsRepo = roundsRepo; _pointsRepo = pointsRepo; _sharingService = sharingService; _combined = combined; @@ -30,9 +30,9 @@ public class RoundStartingViewModel : ViewModelBase #endregion private GameRound? _GameRoundObject = new(); - private ObservableCollection> _GameRoundList = new(); + private ObservableCollection _GameRoundList = new(); private ObservableCollection _ParticipantList = new(); - private readonly IRepository? _Repository; + private readonly IRepository? _roundsRepo; private readonly IRepository _pointsRepo; private readonly IMethodSharingService _sharingService; private readonly ICombinedRepository _combined; @@ -76,7 +76,7 @@ public class RoundStartingViewModel : ViewModelBase GameStatus = GamePointStatus.New, GameRoundFinished = null }; - var gameRoundId = _Repository?.Save(GameRound).GetAwaiter().GetResult(); + var gameRoundId = _roundsRepo?.Save(GameRound).GetAwaiter().GetResult(); if (gameRoundId != null && gameRoundId != -1) { GameRound.GameRoundId = gameRoundId.Value; @@ -122,7 +122,7 @@ public class RoundStartingViewModel : ViewModelBase } } - public ObservableCollection> GameRoundList + public ObservableCollection GameRoundList { get { return _GameRoundList; } set @@ -143,33 +143,36 @@ public class RoundStartingViewModel : ViewModelBase } #region Get Method - public ObservableCollection Get() + public ObservableCollection Get() { - //if (_Repository != null) if (_combined != null) { - //var gameRoundsTask = _Repository.Get(); - //var gameRounds = gameRoundsTask is Task> task - // ? task.GetAwaiter().GetResult() - // : (IEnumerable)gameRoundsTask; - var GameRoundSummary = _combined.roundBuilderElements(); var groupedRounds = GameRoundSummary - .GroupBy(r => r.GameRoundId) - .Select(g => g.ToList()) - .ToList(); - - //OBS ! Här måste jag skapa en ny lista varje gång för att UI ska uppdateras korrekt + .GroupBy(r => r.GameRoundId) + .Select(g => new RoundBuilderGroup + { + GameRoundId = g.Key, + GameRoundStartDate = g.First().GameRoundStartDate, + Status = g.First().Status, + Elements = g.Select(p => new RoundBuilderElement + { + ParticipantId = p.ParticipantId, + ParticipantName = p.ParticipantName, + GamePointId = p.GamePointId, + GameRoundRegNr = p.GameRoundRegNr, + GameRegPoints = p.GameRegPoints, + GameRoundId = p.GameRoundId, + GameRoundStartDate = p.GameRoundStartDate + }).ToList() + }) + .ToList(); - //foreach (var gameRound in gameRounds) - //{ - // if (!_GameRoundList.Any(p => p.GameRoundId == gameRound.GameRoundId)) - // { - // GameRoundList.Add(gameRound); - // } - //} + + GameRoundList = new ObservableCollection(groupedRounds); + } return GameRoundList; } @@ -187,7 +190,7 @@ public class RoundStartingViewModel : ViewModelBase { try { - GameRoundObject = _Repository?.Get(id).GetAwaiter().GetResult(); + GameRoundObject = _roundsRepo?.Get(id).GetAwaiter().GetResult(); } catch (Exception ex) { @@ -198,11 +201,11 @@ public class RoundStartingViewModel : ViewModelBase } public virtual bool Save() { - if (_Repository == null || GameRoundObject == null) + if (_roundsRepo == null || GameRoundObject == null) { return false; } - var tmpTask = _Repository.Save(GameRoundObject); + var tmpTask = _roundsRepo.Save(GameRoundObject); bool tmp = tmpTask.GetAwaiter().GetResult() != -1; if (tmp) { @@ -219,10 +222,20 @@ public class RoundStartingViewModel : ViewModelBase { _pointsRepo.DeleteById(element.GamePointId); } - _Repository?.DeleteById(GameRoundObject?.GameRoundId ?? 0); + _roundsRepo?.DeleteById(GameRoundObject?.GameRoundId ?? 0); RoundElements.Clear(); } + public void RoundSelected(RoundBuilderElement element) + { + Debug.WriteLine($"Du valde raden med Runda {element.GameRoundId} och spelare: {element.ParticipantName}"); + } + + public void SelectNewlyAddedParticipant(RoundBuilderElement roundBuilder) + { + Debug.WriteLine($"Du valde raden med Runda {roundBuilder.GameRoundId} och spelare: {roundBuilder.ParticipantName}"); + } + #endregion } diff --git a/GreadyPoang/AppShell.xaml b/GreadyPoang/AppShell.xaml index 4d223a3..1197f0e 100644 --- a/GreadyPoang/AppShell.xaml +++ b/GreadyPoang/AppShell.xaml @@ -21,6 +21,10 @@ Title="Starta Ny Runda" ContentTemplate="{DataTemplate views:RoundStartingView}" Route="RoundStartingView" /> + diff --git a/GreadyPoang/CommandClasses/RoundRunningViewModelCommands.cs b/GreadyPoang/CommandClasses/RoundRunningViewModelCommands.cs new file mode 100644 index 0000000..e093561 --- /dev/null +++ b/GreadyPoang/CommandClasses/RoundRunningViewModelCommands.cs @@ -0,0 +1,31 @@ +using Common.Library; +using GreadyPoang.DataLayer; +using GreadyPoang.EntityLayer; +using GreadyPoang.ViewModelLayer; +using System.Windows.Input; + +namespace GreadyPoang.CommandClasses; + +public class RoundRunningViewModelCommands : RoundRunningViewModel +{ + public RoundRunningViewModelCommands() : base() + { + } + + public RoundRunningViewModelCommands( + IRepository roundsRepo, + IRepository pointsRepo, + IMethodSharingService sharingService, + ICombinedRepository combined) : base(roundsRepo, pointsRepo, sharingService, combined) + { + } + + #region Commands + public ICommand SaveCommand { get; private set; } + public ICommand EditCommand { get; private set; } + public ICommand RensaCommand { get; private set; } + public ICommand ElementTappedCommand { get; private set; } + public ICommand ParticipantTappedCommand { get; private set; } + #endregion + +} diff --git a/GreadyPoang/CommandClasses/RoundStartingViewModelCommands.cs b/GreadyPoang/CommandClasses/RoundStartingViewModelCommands.cs index 4af8860..e1b290c 100644 --- a/GreadyPoang/CommandClasses/RoundStartingViewModelCommands.cs +++ b/GreadyPoang/CommandClasses/RoundStartingViewModelCommands.cs @@ -13,10 +13,10 @@ public class RoundStartingViewModelCommands : RoundStartingViewModel } public RoundStartingViewModelCommands( - IRepository repo, + IRepository roundsRepo, IRepository pointsRepo, IMethodSharingService sharingService, - ICombinedRepository combined) : base(repo, pointsRepo, sharingService, combined) + ICombinedRepository combined) : base(roundsRepo, pointsRepo, sharingService, combined) { } @@ -41,6 +41,8 @@ public class RoundStartingViewModelCommands : RoundStartingViewModel public ICommand SaveCommand { get; private set; } public ICommand EditCommand { get; private set; } public ICommand RensaCommand { get; private set; } + public ICommand ElementTappedCommand { get; private set; } + public ICommand ParticipantTappedCommand { get; private set; } #endregion #region Init Method @@ -50,6 +52,9 @@ public class RoundStartingViewModelCommands : RoundStartingViewModel SaveCommand = new Command(async () => SaveAsync(), () => IsSaveCommandEnabled); EditCommand = new Command(async (id) => await EditAsync(id), (id) => id > 0); RensaCommand = new Command(async () => RensaAsync()); + ParticipantTappedCommand = new Command(async (selectedParticipant) => SelectNewlyAddedParticipant(selectedParticipant)); + ElementTappedCommand = new Command((selectedElement) => RoundSelected(selectedElement)); + } private async Task RensaAsync() @@ -75,4 +80,21 @@ public class RoundStartingViewModelCommands : RoundStartingViewModel return ret; } + public async Task RoundSelected(RoundBuilderElement element) + { + bool goneOk = false; + base.RoundSelected(element); + goneOk = true; + return goneOk; + } + + public async Task SelectNewlyAddedParticipant(RoundBuilderElement roundBuilder) + { + bool goneOk = false; + base.SelectNewlyAddedParticipant(roundBuilder); + goneOk = true; + return goneOk; + + } + } diff --git a/GreadyPoang/GreadyPoang.csproj b/GreadyPoang/GreadyPoang.csproj index 3839bbb..b12a59e 100644 --- a/GreadyPoang/GreadyPoang.csproj +++ b/GreadyPoang/GreadyPoang.csproj @@ -88,6 +88,9 @@ MSBuild:Compile + + MSBuild:Compile + MSBuild:Compile diff --git a/GreadyPoang/MainPage.xaml b/GreadyPoang/MainPage.xaml index 3c5009f..f79371a 100644 --- a/GreadyPoang/MainPage.xaml +++ b/GreadyPoang/MainPage.xaml @@ -12,5 +12,14 @@ ViewDescription="Välkommen till Gready"> + diff --git a/GreadyPoang/MauiProgram.cs b/GreadyPoang/MauiProgram.cs index 1fa9d07..1178d22 100644 --- a/GreadyPoang/MauiProgram.cs +++ b/GreadyPoang/MauiProgram.cs @@ -45,6 +45,9 @@ public static class MauiProgram builder.Services.AddScoped(); builder.Services.AddScoped(); + builder.Services.AddScoped(); + builder.Services.AddScoped(); + builder.Services.AddScoped, GamePointRepository>(); diff --git a/GreadyPoang/Resources/Images/snurrtarning.gif b/GreadyPoang/Resources/Images/snurrtarning.gif new file mode 100644 index 0000000..68fb263 Binary files /dev/null and b/GreadyPoang/Resources/Images/snurrtarning.gif differ diff --git a/GreadyPoang/Views/RoundRunningView.xaml b/GreadyPoang/Views/RoundRunningView.xaml new file mode 100644 index 0000000..2b415bb --- /dev/null +++ b/GreadyPoang/Views/RoundRunningView.xaml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/GreadyPoang/Views/RoundRunningView.xaml.cs b/GreadyPoang/Views/RoundRunningView.xaml.cs new file mode 100644 index 0000000..000999e --- /dev/null +++ b/GreadyPoang/Views/RoundRunningView.xaml.cs @@ -0,0 +1,20 @@ +using GreadyPoang.CommandClasses; + +namespace GreadyPoang.Views; + +public partial class RoundRunningView : ContentPage +{ + public RoundRunningView(RoundRunningViewModelCommands viewModel) + { + InitializeComponent(); + ViewModel = viewModel; + } + + protected override void OnAppearing() + { + base.OnAppearing(); + BindingContext = ViewModel; + } + public RoundRunningViewModelCommands ViewModel { get; set; } + public int GameRoundId { get; set; } +} \ No newline at end of file diff --git a/GreadyPoang/Views/RoundStartingView.xaml b/GreadyPoang/Views/RoundStartingView.xaml index ea00284..d212fcd 100644 --- a/GreadyPoang/Views/RoundStartingView.xaml +++ b/GreadyPoang/Views/RoundStartingView.xaml @@ -39,6 +39,7 @@ @@ -54,7 +55,7 @@ StrokeShape="RoundRectangle 10"> @@ -106,53 +107,64 @@ - + - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/zBilder/depositphotos_346384942-stock-illustration-vector-illustration-white-dices-icon.jpg b/zBilder/depositphotos_346384942-stock-illustration-vector-illustration-white-dices-icon.jpg new file mode 100644 index 0000000..0962f99 Binary files /dev/null and b/zBilder/depositphotos_346384942-stock-illustration-vector-illustration-white-dices-icon.jpg differ diff --git a/zBilder/f916d4d869bc69dc391280381cc5ed64.gif b/zBilder/f916d4d869bc69dc391280381cc5ed64.gif new file mode 100644 index 0000000..68fb263 Binary files /dev/null and b/zBilder/f916d4d869bc69dc391280381cc5ed64.gif differ diff --git a/zBilder/gettyimages-1165647019-612x612.jpg b/zBilder/gettyimages-1165647019-612x612.jpg new file mode 100644 index 0000000..41db909 Binary files /dev/null and b/zBilder/gettyimages-1165647019-612x612.jpg differ diff --git a/zBilder/istockphoto-1132091114-612x612.jpg b/zBilder/istockphoto-1132091114-612x612.jpg new file mode 100644 index 0000000..3d3aa32 Binary files /dev/null and b/zBilder/istockphoto-1132091114-612x612.jpg differ diff --git a/zBilder/istockphoto-1309668584-612x612.jpg b/zBilder/istockphoto-1309668584-612x612.jpg new file mode 100644 index 0000000..4d13932 Binary files /dev/null and b/zBilder/istockphoto-1309668584-612x612.jpg differ diff --git a/zBilder/snurrtarning.gif b/zBilder/snurrtarning.gif new file mode 100644 index 0000000..68fb263 Binary files /dev/null and b/zBilder/snurrtarning.gif differ diff --git a/zBilder/unnamed.png b/zBilder/unnamed.png new file mode 100644 index 0000000..e0ccfae Binary files /dev/null and b/zBilder/unnamed.png differ