diff --git a/GreadyPoang.Services/GreadyPoang.Services.csproj b/GreadyPoang.Services/GreadyPoang.Services.csproj
new file mode 100644
index 0000000..56ac9b4
--- /dev/null
+++ b/GreadyPoang.Services/GreadyPoang.Services.csproj
@@ -0,0 +1,13 @@
+
+
+
+ net9.0
+ enable
+ enable
+
+
+
+
+
+
+
diff --git a/GreadyPoang.Services/Services/Implements/ObjectMessageService.cs b/GreadyPoang.Services/Services/Implements/ObjectMessageService.cs
new file mode 100644
index 0000000..3325f8f
--- /dev/null
+++ b/GreadyPoang.Services/Services/Implements/ObjectMessageService.cs
@@ -0,0 +1,8 @@
+using GreadyPoang.EntityLayer;
+
+namespace GreadyPoang.Services;
+
+public class ObjectMessageService : IObjectMessageService
+{
+ public RoundBuilderGroup CurrentGroup { get; set; }
+}
diff --git a/GreadyPoang.Services/Services/Interfaces/IObjectMessageService.cs b/GreadyPoang.Services/Services/Interfaces/IObjectMessageService.cs
new file mode 100644
index 0000000..72dca14
--- /dev/null
+++ b/GreadyPoang.Services/Services/Interfaces/IObjectMessageService.cs
@@ -0,0 +1,9 @@
+using GreadyPoang.EntityLayer;
+
+namespace GreadyPoang.Services;
+
+public interface IObjectMessageService
+{
+ RoundBuilderGroup CurrentGroup { get; set; }
+
+}
diff --git a/GreadyPoang.ViewModelLayer/GreadyPoang.ViewModelLayer.csproj b/GreadyPoang.ViewModelLayer/GreadyPoang.ViewModelLayer.csproj
index 3bc24fd..4a57926 100644
--- a/GreadyPoang.ViewModelLayer/GreadyPoang.ViewModelLayer.csproj
+++ b/GreadyPoang.ViewModelLayer/GreadyPoang.ViewModelLayer.csproj
@@ -10,6 +10,7 @@
+
diff --git a/GreadyPoang.ViewModelLayer/ViewModelClasses/RoundRunningViewModel.cs b/GreadyPoang.ViewModelLayer/ViewModelClasses/RoundRunningViewModel.cs
index c3a781c..40f4498 100644
--- a/GreadyPoang.ViewModelLayer/ViewModelClasses/RoundRunningViewModel.cs
+++ b/GreadyPoang.ViewModelLayer/ViewModelClasses/RoundRunningViewModel.cs
@@ -1,7 +1,9 @@
using Common.Library;
using GreadyPoang.DataLayer;
using GreadyPoang.EntityLayer;
+using GreadyPoang.Services;
using System.Collections.ObjectModel;
+using System.Diagnostics;
namespace GreadyPoang.ViewModelLayer;
@@ -17,23 +19,54 @@ public class RoundRunningViewModel : ViewModelBase
IRepository roundsRepo,
IRepository pointsRepo,
IMethodSharingService sharingService,
- ICombinedRepository combined
+ ICombinedRepository combined,
+ IObjectMessageService objectMessage
) : base()
{
_roundsRepo = roundsRepo;
_pointsRepo = pointsRepo;
_sharingService = sharingService;
_combined = combined;
+ _objectMessage = objectMessage;
+ _roundElements = new ObservableCollection();
}
private readonly IRepository? _roundsRepo;
private readonly IRepository _pointsRepo;
private readonly IMethodSharingService _sharingService;
private readonly ICombinedRepository _combined;
+ private readonly IObjectMessageService _objectMessage;
+ private ObservableCollection _roundElements;
private ObservableCollection _GameRoundList = new();
private ObservableCollection _ParticipantList = new();
- private ObservableCollection _roundElements;
+ public ObservableCollection RoundElements
+ {
+ get { return _roundElements; }
+ set
+ {
+ _roundElements = value;
+ RaisePropertyChanged(nameof(RoundElements));
+ }
+ }
+ public ObservableCollection Get()
+ {
+ if (_objectMessage.CurrentGroup != null)
+ {
+ Debug.WriteLine($"Chosen round: {_objectMessage.CurrentGroup.GameRoundId}");
+ if (RoundElements.Count > 0)
+ {
+ RoundElements.Clear();
+ }
+ foreach (var item in _objectMessage.CurrentGroup.Elements)
+ {
+ _roundElements.Add(item);
+ }
+ }
+ return RoundElements;
+ }
}
+
+
diff --git a/GreadyPoang.ViewModelLayer/ViewModelClasses/RoundStartingViewModel.cs b/GreadyPoang.ViewModelLayer/ViewModelClasses/RoundStartingViewModel.cs
index e81e49a..fd096a9 100644
--- a/GreadyPoang.ViewModelLayer/ViewModelClasses/RoundStartingViewModel.cs
+++ b/GreadyPoang.ViewModelLayer/ViewModelClasses/RoundStartingViewModel.cs
@@ -1,6 +1,7 @@
using Common.Library;
using GreadyPoang.DataLayer;
using GreadyPoang.EntityLayer;
+using GreadyPoang.Services;
using System.Collections.ObjectModel;
using System.Diagnostics;
@@ -18,12 +19,14 @@ public class RoundStartingViewModel : ViewModelBase
IRepository roundsRepo,
IRepository pointsRepo,
IMethodSharingService sharingService,
- ICombinedRepository combined) : base()
+ ICombinedRepository combined,
+ IObjectMessageService objectMessage) : base()
{
_roundsRepo = roundsRepo;
_pointsRepo = pointsRepo;
_sharingService = sharingService;
_combined = combined;
+ _objectMessage = objectMessage;
_roundElements = new ObservableCollection();
}
@@ -36,6 +39,7 @@ public class RoundStartingViewModel : ViewModelBase
private readonly IRepository _pointsRepo;
private readonly IMethodSharingService _sharingService;
private readonly ICombinedRepository _combined;
+ private readonly IObjectMessageService _objectMessage;
private Participant _selectedItem;
private ObservableCollection _roundElements;
@@ -228,7 +232,13 @@ public class RoundStartingViewModel : ViewModelBase
public void RoundSelected(RoundBuilderElement element)
{
+ var rbGroup = GameRoundList.FirstOrDefault(g => g.GameRoundId == element.GameRoundId);
Debug.WriteLine($"Du valde raden med Runda {element.GameRoundId} och spelare: {element.ParticipantName}");
+ if (rbGroup != null)
+ {
+ _objectMessage.CurrentGroup = rbGroup;
+ Shell.Current.GoToAsync("//RoundRunningView");
+ }
}
public void SelectNewlyAddedParticipant(RoundBuilderElement roundBuilder)
diff --git a/GreadyPoang.sln b/GreadyPoang.sln
index 7fc7203..8fcaab8 100644
--- a/GreadyPoang.sln
+++ b/GreadyPoang.sln
@@ -15,6 +15,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GreadyPoang.DataLayer", "Gr
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GreadyPoang.Migrations", "GreadyPoang.Migrations\GreadyPoang.Migrations.csproj", "{56EB8207-E108-4498-82AC-BAC8966D3D2D}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GreadyPoang.Services", "GreadyPoang.Services\GreadyPoang.Services.csproj", "{1C70F0EC-370D-4F48-AEDD-DB171D71EA2A}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -46,6 +48,10 @@ Global
{56EB8207-E108-4498-82AC-BAC8966D3D2D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{56EB8207-E108-4498-82AC-BAC8966D3D2D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{56EB8207-E108-4498-82AC-BAC8966D3D2D}.Release|Any CPU.Build.0 = Release|Any CPU
+ {1C70F0EC-370D-4F48-AEDD-DB171D71EA2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {1C70F0EC-370D-4F48-AEDD-DB171D71EA2A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {1C70F0EC-370D-4F48-AEDD-DB171D71EA2A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {1C70F0EC-370D-4F48-AEDD-DB171D71EA2A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/GreadyPoang/CommandClasses/RoundRunningViewModelCommands.cs b/GreadyPoang/CommandClasses/RoundRunningViewModelCommands.cs
index e093561..6f713e1 100644
--- a/GreadyPoang/CommandClasses/RoundRunningViewModelCommands.cs
+++ b/GreadyPoang/CommandClasses/RoundRunningViewModelCommands.cs
@@ -1,6 +1,7 @@
using Common.Library;
using GreadyPoang.DataLayer;
using GreadyPoang.EntityLayer;
+using GreadyPoang.Services;
using GreadyPoang.ViewModelLayer;
using System.Windows.Input;
@@ -16,7 +17,13 @@ public class RoundRunningViewModelCommands : RoundRunningViewModel
IRepository roundsRepo,
IRepository pointsRepo,
IMethodSharingService sharingService,
- ICombinedRepository combined) : base(roundsRepo, pointsRepo, sharingService, combined)
+ ICombinedRepository combined,
+ IObjectMessageService objectMessage)
+ : base(roundsRepo,
+ pointsRepo,
+ sharingService,
+ combined,
+ objectMessage)
{
}
diff --git a/GreadyPoang/CommandClasses/RoundStartingViewModelCommands.cs b/GreadyPoang/CommandClasses/RoundStartingViewModelCommands.cs
index e1b290c..d4a845b 100644
--- a/GreadyPoang/CommandClasses/RoundStartingViewModelCommands.cs
+++ b/GreadyPoang/CommandClasses/RoundStartingViewModelCommands.cs
@@ -1,6 +1,7 @@
using Common.Library;
using GreadyPoang.DataLayer;
using GreadyPoang.EntityLayer;
+using GreadyPoang.Services;
using GreadyPoang.ViewModelLayer;
using System.Windows.Input;
@@ -16,7 +17,13 @@ public class RoundStartingViewModelCommands : RoundStartingViewModel
IRepository roundsRepo,
IRepository pointsRepo,
IMethodSharingService sharingService,
- ICombinedRepository combined) : base(roundsRepo, pointsRepo, sharingService, combined)
+ ICombinedRepository combined,
+ IObjectMessageService objectMessage)
+ : base(roundsRepo,
+ pointsRepo,
+ sharingService,
+ combined,
+ objectMessage)
{
}
diff --git a/GreadyPoang/GreadyPoang.csproj b/GreadyPoang/GreadyPoang.csproj
index b12a59e..42db7ff 100644
--- a/GreadyPoang/GreadyPoang.csproj
+++ b/GreadyPoang/GreadyPoang.csproj
@@ -69,6 +69,7 @@
+
diff --git a/GreadyPoang/MauiProgram.cs b/GreadyPoang/MauiProgram.cs
index 1178d22..9034e53 100644
--- a/GreadyPoang/MauiProgram.cs
+++ b/GreadyPoang/MauiProgram.cs
@@ -3,6 +3,7 @@ using GreadyPoang.CommandClasses;
using GreadyPoang.DataLayer;
using GreadyPoang.DataLayer.Database;
using GreadyPoang.EntityLayer;
+using GreadyPoang.Services;
using GreadyPoang.ViewModelLayer;
using GreadyPoang.Views;
using Microsoft.EntityFrameworkCore;
@@ -45,6 +46,8 @@ public static class MauiProgram
builder.Services.AddScoped();
builder.Services.AddScoped();
+ builder.Services.AddSingleton();
+
builder.Services.AddScoped();
builder.Services.AddScoped();
diff --git a/GreadyPoang/Views/RoundRunningView.xaml b/GreadyPoang/Views/RoundRunningView.xaml
index 2b415bb..7eda743 100644
--- a/GreadyPoang/Views/RoundRunningView.xaml
+++ b/GreadyPoang/Views/RoundRunningView.xaml
@@ -2,12 +2,13 @@
-
+ xmlns:vm ="clr-namespace:GreadyPoang.CommandClasses"
+ xmlns:local="clr-namespace:GreadyPoang.EntityLayer;assembly=GreadyPoang.EntityLayer"
+ xmlns:model="clr-namespace:GreadyPoang.EntityLayer;assembly=GreadyPoang.EntityLayer"
+ x:DataType="vm:RoundRunningViewModelCommands"
+ Title="RoundRunningView">
+
@@ -19,30 +20,31 @@
Grid.ColumnSpan="2"
ViewTitle="Starta eller fortsätt en registrerad Runda"
ViewDescription="Deltagarna visas först!" />
-
-
-
-
-
-
-
+ Margin="5">
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/GreadyPoang/Views/RoundRunningView.xaml.cs b/GreadyPoang/Views/RoundRunningView.xaml.cs
index 000999e..dbb5ada 100644
--- a/GreadyPoang/Views/RoundRunningView.xaml.cs
+++ b/GreadyPoang/Views/RoundRunningView.xaml.cs
@@ -14,7 +14,8 @@ public partial class RoundRunningView : ContentPage
{
base.OnAppearing();
BindingContext = ViewModel;
+ ViewModel.Get();
}
public RoundRunningViewModelCommands ViewModel { get; set; }
- public int GameRoundId { get; set; }
+ //public int GameRoundId { get; set; }
}
\ No newline at end of file