Infört Observable Property och observable object från Community Toolkit
This commit is contained in:
@ -6,5 +6,19 @@
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="BaseClasses\CommonBase.cs" />
|
||||
<Compile Remove="BaseClasses\EntityBase.cs" />
|
||||
<Compile Remove="BaseClasses\ViewModelBase.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="BaseClasses\" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
</Project>
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
|
||||
<PackageReference Include="Microsoft.Maui.Controls" Version="9.0.100" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.8">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
using Common.Library;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using SQLite;
|
||||
|
||||
namespace GreadyPoang.EntityLayer;
|
||||
[Table("GamePoint")]
|
||||
public class GamePoint : EntityBase
|
||||
public class GamePoint : ObservableObject
|
||||
{
|
||||
public GamePoint()
|
||||
{
|
||||
@ -31,7 +31,7 @@ public class GamePoint : EntityBase
|
||||
set
|
||||
{
|
||||
_gamePointId = value;
|
||||
RaisePropertyChanged(nameof(GamePointId));
|
||||
OnPropertyChanged(nameof(GamePointId));
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ public class GamePoint : EntityBase
|
||||
set
|
||||
{
|
||||
_participantId = value;
|
||||
RaisePropertyChanged(nameof(ParticipantId));
|
||||
OnPropertyChanged(nameof(ParticipantId));
|
||||
}
|
||||
}
|
||||
[Column("GameRoundId")]
|
||||
@ -52,7 +52,7 @@ public class GamePoint : EntityBase
|
||||
set
|
||||
{
|
||||
_gameRoundId = value;
|
||||
RaisePropertyChanged(nameof(GameRoundId));
|
||||
OnPropertyChanged(nameof(GameRoundId));
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,7 +63,7 @@ public class GamePoint : EntityBase
|
||||
set
|
||||
{
|
||||
_gameDate = value;
|
||||
RaisePropertyChanged(nameof(GameDate));
|
||||
OnPropertyChanged(nameof(GameDate));
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,7 +77,7 @@ public class GamePoint : EntityBase
|
||||
set
|
||||
{
|
||||
_gameRoundRegNr = value;
|
||||
RaisePropertyChanged(nameof(GameRoundRegNr));
|
||||
OnPropertyChanged(nameof(GameRoundRegNr));
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,7 +88,7 @@ public class GamePoint : EntityBase
|
||||
set
|
||||
{
|
||||
_gameRegPoints = value;
|
||||
RaisePropertyChanged(nameof(GameRegPoints));
|
||||
OnPropertyChanged(nameof(GameRegPoints));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
using Common.Library;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using SQLite;
|
||||
|
||||
namespace GreadyPoang.EntityLayer;
|
||||
@ -6,7 +6,7 @@ namespace GreadyPoang.EntityLayer;
|
||||
|
||||
[Table("GameRound")]
|
||||
|
||||
public class GameRound : EntityBase
|
||||
public class GameRound : ObservableObject
|
||||
{
|
||||
public GameRound()
|
||||
{
|
||||
@ -28,7 +28,7 @@ public class GameRound : EntityBase
|
||||
set
|
||||
{
|
||||
_gameRoundFinished = value;
|
||||
RaisePropertyChanged(nameof(GameRoundFinished));
|
||||
OnPropertyChanged(nameof(GameRoundFinished));
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ public class GameRound : EntityBase
|
||||
set
|
||||
{
|
||||
_gameRoundStartDate = value;
|
||||
RaisePropertyChanged(nameof(GameRoundStartDate));
|
||||
OnPropertyChanged(nameof(GameRoundStartDate));
|
||||
}
|
||||
}
|
||||
|
||||
@ -50,7 +50,7 @@ public class GameRound : EntityBase
|
||||
set
|
||||
{
|
||||
_gameStatus = value;
|
||||
RaisePropertyChanged(nameof(GameStatus));
|
||||
OnPropertyChanged(nameof(GameStatus));
|
||||
}
|
||||
}
|
||||
|
||||
@ -64,7 +64,7 @@ public class GameRound : EntityBase
|
||||
set
|
||||
{
|
||||
_gameRoundId = value;
|
||||
RaisePropertyChanged(nameof(GameRoundId));
|
||||
OnPropertyChanged(nameof(GameRoundId));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
using Common.Library;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using SQLite;
|
||||
|
||||
namespace GreadyPoang.EntityLayer;
|
||||
[Table("Participants")]
|
||||
public class Participant : EntityBase
|
||||
public class Participant : ObservableObject
|
||||
{
|
||||
public Participant()
|
||||
{
|
||||
@ -26,7 +26,7 @@ public class Participant : EntityBase
|
||||
set
|
||||
{
|
||||
_participantId = value;
|
||||
RaisePropertyChanged(nameof(ParticipantId));
|
||||
OnPropertyChanged(nameof(ParticipantId));
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,7 +37,7 @@ public class Participant : EntityBase
|
||||
set
|
||||
{
|
||||
_firstName = value;
|
||||
RaisePropertyChanged(nameof(FirstName));
|
||||
OnPropertyChanged(nameof(FirstName));
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,7 +48,7 @@ public class Participant : EntityBase
|
||||
set
|
||||
{
|
||||
_lastName = value;
|
||||
RaisePropertyChanged(nameof(LastName));
|
||||
OnPropertyChanged(nameof(LastName));
|
||||
}
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ public class Participant : EntityBase
|
||||
set
|
||||
{
|
||||
_email = value;
|
||||
RaisePropertyChanged(nameof(Email));
|
||||
OnPropertyChanged(nameof(Email));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
|
||||
<PackageReference Include="sqlite-net-pcl" Version="1.9.172" />
|
||||
<PackageReference Include="SQLitePCLRaw.bundle_green" Version="2.1.11" />
|
||||
</ItemGroup>
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
using Common.Library;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace GreadyPoang.EntityLayer;
|
||||
|
||||
public class PlayerColumn : EntityBase
|
||||
public class PlayerColumn : ObservableObject
|
||||
{
|
||||
public PlayerColumn()
|
||||
{
|
||||
@ -20,7 +20,7 @@ public class PlayerColumn : EntityBase
|
||||
set
|
||||
{
|
||||
_playerName = value;
|
||||
RaisePropertyChanged(nameof(PlayerName));
|
||||
OnPropertyChanged(nameof(PlayerName));
|
||||
}
|
||||
}
|
||||
public List<string> Values
|
||||
@ -29,7 +29,7 @@ public class PlayerColumn : EntityBase
|
||||
set
|
||||
{
|
||||
_values = value;
|
||||
RaisePropertyChanged(nameof(Values));
|
||||
OnPropertyChanged(nameof(Values));
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ public class PlayerColumn : EntityBase
|
||||
set
|
||||
{
|
||||
_playerId = value;
|
||||
RaisePropertyChanged(nameof(PlayerId));
|
||||
OnPropertyChanged(nameof(PlayerId));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
using Common.Library;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace GreadyPoang.EntityLayer;
|
||||
|
||||
public class RoundBuilderElement : EntityBase
|
||||
public class RoundBuilderElement : ObservableObject
|
||||
{
|
||||
public RoundBuilderElement()
|
||||
{
|
||||
@ -31,7 +31,7 @@ public class RoundBuilderElement : EntityBase
|
||||
set
|
||||
{
|
||||
_participantId = value;
|
||||
RaisePropertyChanged(nameof(ParticipantId));
|
||||
OnPropertyChanged(nameof(ParticipantId));
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ public class RoundBuilderElement : EntityBase
|
||||
set
|
||||
{
|
||||
_participantName = value;
|
||||
RaisePropertyChanged(nameof(ParticipantName));
|
||||
OnPropertyChanged(nameof(ParticipantName));
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ public class RoundBuilderElement : EntityBase
|
||||
set
|
||||
{
|
||||
_gameRoundRegNr = value;
|
||||
RaisePropertyChanged(nameof(GameRoundRegNr));
|
||||
OnPropertyChanged(nameof(GameRoundRegNr));
|
||||
}
|
||||
}
|
||||
|
||||
@ -64,7 +64,7 @@ public class RoundBuilderElement : EntityBase
|
||||
set
|
||||
{
|
||||
_gameRegPoints = value;
|
||||
RaisePropertyChanged(nameof(GameRegPoints));
|
||||
OnPropertyChanged(nameof(GameRegPoints));
|
||||
}
|
||||
}
|
||||
|
||||
@ -75,8 +75,8 @@ public class RoundBuilderElement : EntityBase
|
||||
set
|
||||
{
|
||||
_status = value;
|
||||
RaisePropertyChanged(nameof(Status));
|
||||
RaisePropertyChanged(nameof(StatusString));
|
||||
OnPropertyChanged(nameof(Status));
|
||||
OnPropertyChanged(nameof(StatusString));
|
||||
}
|
||||
}
|
||||
|
||||
@ -91,8 +91,8 @@ public class RoundBuilderElement : EntityBase
|
||||
set
|
||||
{
|
||||
_gameRoundStartDate = value;
|
||||
RaisePropertyChanged(nameof(GameRoundStartDate));
|
||||
RaisePropertyChanged(nameof(GameRoundStartDateString));
|
||||
OnPropertyChanged(nameof(GameRoundStartDate));
|
||||
OnPropertyChanged(nameof(GameRoundStartDateString));
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,7 +107,7 @@ public class RoundBuilderElement : EntityBase
|
||||
set
|
||||
{
|
||||
_gameRoundId = value;
|
||||
RaisePropertyChanged(nameof(GameRoundId));
|
||||
OnPropertyChanged(nameof(GameRoundId));
|
||||
}
|
||||
}
|
||||
|
||||
@ -118,7 +118,7 @@ public class RoundBuilderElement : EntityBase
|
||||
set
|
||||
{
|
||||
_gamePointId = value;
|
||||
RaisePropertyChanged(nameof(GamePointId));
|
||||
OnPropertyChanged(nameof(GamePointId));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,20 +1,21 @@
|
||||
using Common.Library;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace GreadyPoang.EntityLayer;
|
||||
|
||||
public class RoundBuilderGroup : EntityBase
|
||||
public partial class RoundBuilderGroup : ObservableObject
|
||||
{
|
||||
public RoundBuilderGroup()
|
||||
{
|
||||
_gameRoundId = 0;
|
||||
_gameRoundStartDate = DateTime.MinValue;
|
||||
_status = GamePointStatus.New;
|
||||
_elements = new List<RoundBuilderElement>();
|
||||
Elements = new List<RoundBuilderElement>();
|
||||
}
|
||||
private int _gameRoundId;
|
||||
private DateTime _gameRoundStartDate;
|
||||
private GamePointStatus _status;
|
||||
private List<RoundBuilderElement> _elements;
|
||||
[ObservableProperty]
|
||||
private List<RoundBuilderElement> elements;
|
||||
public int GameRoundId
|
||||
{
|
||||
get { return _gameRoundId; }
|
||||
@ -43,14 +44,14 @@ public class RoundBuilderGroup : EntityBase
|
||||
}
|
||||
}
|
||||
|
||||
public List<RoundBuilderElement> Elements
|
||||
{
|
||||
get { return _elements; }
|
||||
set
|
||||
{
|
||||
_elements = value;
|
||||
RaisePropertyChanged(nameof(Elements));
|
||||
// No need to raise property changed for this example
|
||||
}
|
||||
}
|
||||
//public List<RoundBuilderElement> Elements
|
||||
//{
|
||||
// get { return _elements; }
|
||||
// set
|
||||
// {
|
||||
// _elements = value;
|
||||
// OnPropertyChanged(nameof(Elements));
|
||||
// // No need to raise property changed for this example
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.8">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
|
||||
@ -6,6 +6,10 @@
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\GreadyPoang.EntityLayer\GreadyPoang.EntityLayer.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
@ -6,6 +6,10 @@
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Common.Library\Common.Library.csproj" />
|
||||
<ProjectReference Include="..\GreadyPoang.DataLayer\GreadyPoang.DataLayer.csproj" />
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
using Common.Library;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using GreadyPoang.EntityLayer;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace GreadyPoang.ViewModelLayer;
|
||||
|
||||
public class MethodSharingService : ViewModelBase, IMethodSharingService<Participant>
|
||||
public class MethodSharingService : ObservableObject, IMethodSharingService<Participant>
|
||||
{
|
||||
private readonly IRepository<Participant> _repository;
|
||||
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
using Common.Library;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using GreadyPoang.EntityLayer;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
|
||||
namespace GreadyPoang.ViewModelLayer;
|
||||
|
||||
public class ParticipantViewModel : ViewModelBase
|
||||
public partial class ParticipantViewModel : ObservableObject
|
||||
{
|
||||
#region Constructors
|
||||
public ParticipantViewModel() : base()
|
||||
@ -17,41 +18,21 @@ public class ParticipantViewModel : ViewModelBase
|
||||
{
|
||||
_Repository = repo;
|
||||
_sharingService = sharingService;
|
||||
ParticipantObject = new Participant();
|
||||
ParticipantList = new ObservableCollection<Participant>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Variables
|
||||
private Participant? _ParticipantObject = new();
|
||||
private ObservableCollection<Participant> _ParticipantList = new();
|
||||
[ObservableProperty]
|
||||
private Participant? participantObject;
|
||||
[ObservableProperty]
|
||||
private ObservableCollection<Participant> participantList;
|
||||
private readonly IRepository<Participant>? _Repository;
|
||||
private readonly IMethodSharingService<Participant> _sharingService;
|
||||
#endregion
|
||||
|
||||
#region public Properties
|
||||
|
||||
public Participant? ParticipantObject
|
||||
{
|
||||
get { return _ParticipantObject; }
|
||||
set
|
||||
{
|
||||
_ParticipantObject = value;
|
||||
RaisePropertyChanged(nameof(ParticipantObject));
|
||||
}
|
||||
}
|
||||
|
||||
public ObservableCollection<Participant> ParticipantList
|
||||
{
|
||||
get { return _ParticipantList; }
|
||||
set
|
||||
{
|
||||
_ParticipantList = value;
|
||||
RaisePropertyChanged(nameof(ParticipantList));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Get Method
|
||||
public ObservableCollection<Participant> Get()
|
||||
{
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using Common.Library;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using GreadyPoang.DataLayer;
|
||||
using GreadyPoang.EntityLayer;
|
||||
using GreadyPoang.Services;
|
||||
@ -7,7 +8,7 @@ using System.Diagnostics;
|
||||
|
||||
namespace GreadyPoang.ViewModelLayer;
|
||||
|
||||
public class RoundRunningViewModel : ViewModelBase
|
||||
public partial class RoundRunningViewModel : ObservableObject
|
||||
{
|
||||
|
||||
public event EventHandler RebuildRequested;
|
||||
@ -30,8 +31,8 @@ public class RoundRunningViewModel : ViewModelBase
|
||||
_sharingService = sharingService;
|
||||
_combined = combined;
|
||||
_objectMessage = objectMessage;
|
||||
_roundElements = new ObservableCollection<RoundBuilderElement>();
|
||||
_builderObject = new();
|
||||
RoundElements = new ObservableCollection<RoundBuilderElement>();
|
||||
BuilderObject = new();
|
||||
}
|
||||
|
||||
private readonly IRepository<GameRound>? _roundsRepo;
|
||||
@ -40,11 +41,15 @@ public class RoundRunningViewModel : ViewModelBase
|
||||
private readonly ICombinedRepository _combined;
|
||||
private readonly IObjectMessageService _objectMessage;
|
||||
|
||||
private ObservableCollection<RoundBuilderGroup> _GameRoundList = new();
|
||||
private ObservableCollection<Participant> _ParticipantList = new();
|
||||
private ObservableCollection<RoundBuilderElement> _roundElements;
|
||||
private Collection<PlayerColumn> _playerColumns;
|
||||
private RoundBuilderElement _builderObject;
|
||||
//private ObservableCollection<RoundBuilderGroup> _GameRoundList = new();
|
||||
//private ObservableCollection<Participant> _ParticipantList = new();
|
||||
|
||||
[ObservableProperty]
|
||||
private ObservableCollection<RoundBuilderElement> roundElements;
|
||||
[ObservableProperty]
|
||||
private Collection<PlayerColumn> playerColumns;
|
||||
[ObservableProperty]
|
||||
private RoundBuilderElement builderObject;
|
||||
|
||||
public void TriggerRebuild()
|
||||
{
|
||||
@ -52,35 +57,35 @@ public class RoundRunningViewModel : ViewModelBase
|
||||
RebuildRequested?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
public ObservableCollection<RoundBuilderElement> RoundElements
|
||||
{
|
||||
get { return _roundElements; }
|
||||
set
|
||||
{
|
||||
_roundElements = value;
|
||||
RaisePropertyChanged(nameof(RoundElements));
|
||||
}
|
||||
}
|
||||
//public ObservableCollection<RoundBuilderElement> RoundElements
|
||||
//{
|
||||
// get { return _roundElements; }
|
||||
// set
|
||||
// {
|
||||
// _roundElements = value;
|
||||
// OnPropertyChanged(nameof(RoundElements));
|
||||
// }
|
||||
//}
|
||||
|
||||
public Collection<PlayerColumn> PlayerColumns
|
||||
{
|
||||
get { return _playerColumns; }
|
||||
set
|
||||
{
|
||||
_playerColumns = value;
|
||||
RaisePropertyChanged(nameof(PlayerColumns));
|
||||
}
|
||||
}
|
||||
//public Collection<PlayerColumn> PlayerColumns
|
||||
//{
|
||||
// get { return _playerColumns; }
|
||||
// set
|
||||
// {
|
||||
// _playerColumns = value;
|
||||
// OnPropertyChanged(nameof(PlayerColumns));
|
||||
// }
|
||||
//}
|
||||
|
||||
public RoundBuilderElement BuilderObject
|
||||
{
|
||||
get { return _builderObject; }
|
||||
set
|
||||
{
|
||||
_builderObject = value;
|
||||
RaisePropertyChanged(nameof(BuilderObject));
|
||||
}
|
||||
}
|
||||
//public RoundBuilderElement BuilderObject
|
||||
//{
|
||||
// get { return _builderObject; }
|
||||
// set
|
||||
// {
|
||||
// _builderObject = value;
|
||||
// OnPropertyChanged(nameof(BuilderObject));
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
public ObservableCollection<RoundBuilderElement> Get()
|
||||
@ -97,7 +102,7 @@ public class RoundRunningViewModel : ViewModelBase
|
||||
}
|
||||
foreach (var item in _objectMessage.CurrentGroup.Elements)
|
||||
{
|
||||
_roundElements.Add(item);
|
||||
RoundElements.Add(item);
|
||||
}
|
||||
|
||||
// Räkna ut vem som är nästa spelare
|
||||
@ -113,7 +118,7 @@ public class RoundRunningViewModel : ViewModelBase
|
||||
var localElements = _combined.roundBuilderElementsTotalById(_objectMessage.CurrentGroup.GameRoundId);
|
||||
|
||||
FillupResultTable(localElements);
|
||||
foreach (var col in _playerColumns)
|
||||
foreach (var col in PlayerColumns)
|
||||
{
|
||||
RoundElements.FirstOrDefault(e => e.ParticipantId == col.PlayerId).GameRegPoints = col.PlayerPoints;
|
||||
}
|
||||
@ -166,7 +171,7 @@ public class RoundRunningViewModel : ViewModelBase
|
||||
|
||||
var localElements = _combined.roundBuilderElementsTotalById(BuilderObject.GameRoundId);
|
||||
FillupResultTable(localElements);
|
||||
foreach (var col in _playerColumns)
|
||||
foreach (var col in PlayerColumns)
|
||||
{
|
||||
RoundElements.FirstOrDefault(e => e.ParticipantId == col.PlayerId).GameRegPoints = col.PlayerPoints;
|
||||
}
|
||||
@ -189,13 +194,13 @@ public class RoundRunningViewModel : ViewModelBase
|
||||
|
||||
private void FillupResultTable(IEnumerable<RoundBuilderElement> elements)
|
||||
{
|
||||
if (_playerColumns != null)
|
||||
if (PlayerColumns != null)
|
||||
{
|
||||
_playerColumns.Clear();
|
||||
PlayerColumns.Clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
_playerColumns = new Collection<PlayerColumn>();
|
||||
PlayerColumns = new Collection<PlayerColumn>();
|
||||
}
|
||||
|
||||
// if (elements.Any(g => g.GameRegPoints > 0))
|
||||
@ -205,7 +210,7 @@ public class RoundRunningViewModel : ViewModelBase
|
||||
|
||||
foreach (var element in elements)
|
||||
{
|
||||
player = _playerColumns.FirstOrDefault(p => p.PlayerId == element.ParticipantId);
|
||||
player = PlayerColumns.FirstOrDefault(p => p.PlayerId == element.ParticipantId);
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
@ -224,9 +229,9 @@ public class RoundRunningViewModel : ViewModelBase
|
||||
}
|
||||
//oldPart = element.ParticipantId;
|
||||
|
||||
if (!_playerColumns.Contains(player))
|
||||
if (!PlayerColumns.Contains(player))
|
||||
{
|
||||
_playerColumns.Add(player);
|
||||
PlayerColumns.Add(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -238,7 +243,9 @@ public class RoundRunningViewModel : ViewModelBase
|
||||
{
|
||||
var player = new PlayerColumn
|
||||
{
|
||||
PlayerName = element.ParticipantName
|
||||
PlayerName = element.ParticipantName,
|
||||
PlayerId = element.ParticipantId,
|
||||
PlayerPoints = 0
|
||||
};
|
||||
|
||||
for (int i = 0; i < slumper.Next(6); i++)
|
||||
@ -246,7 +253,7 @@ public class RoundRunningViewModel : ViewModelBase
|
||||
player.Values.Add(slumper.Next(1, 10).ToString());
|
||||
}
|
||||
|
||||
_playerColumns.Add(player);
|
||||
PlayerColumns.Add(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using Common.Library;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using GreadyPoang.DataLayer;
|
||||
using GreadyPoang.EntityLayer;
|
||||
using GreadyPoang.Services;
|
||||
@ -7,7 +8,7 @@ using System.Diagnostics;
|
||||
|
||||
namespace GreadyPoang.ViewModelLayer;
|
||||
|
||||
public class RoundStartingViewModel : ViewModelBase
|
||||
public partial class RoundStartingViewModel : ObservableObject
|
||||
{
|
||||
#region Constructors
|
||||
public RoundStartingViewModel() : base()
|
||||
@ -27,52 +28,100 @@ public class RoundStartingViewModel : ViewModelBase
|
||||
_sharingService = sharingService;
|
||||
_combined = combined;
|
||||
_objectMessage = objectMessage;
|
||||
_roundElements = new ObservableCollection<RoundBuilderElement>();
|
||||
RoundElements = new ObservableCollection<RoundBuilderElement>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private GameRound? _GameRoundObject = new();
|
||||
private ObservableCollection<RoundBuilderGroup> _GameRoundList = new();
|
||||
private ObservableCollection<Participant> _ParticipantList = new();
|
||||
private readonly IRepository<GameRound>? _roundsRepo;
|
||||
private readonly IRepository<GamePoint> _pointsRepo;
|
||||
private readonly IMethodSharingService<Participant> _sharingService;
|
||||
private readonly ICombinedRepository _combined;
|
||||
private readonly IObjectMessageService _objectMessage;
|
||||
private Participant _selectedItem;
|
||||
|
||||
private ObservableCollection<RoundBuilderElement> _roundElements;
|
||||
|
||||
public ObservableCollection<RoundBuilderElement> RoundElements
|
||||
[ObservableProperty]
|
||||
private Participant selectedItem;
|
||||
partial void OnSelectedItemChanged(Participant value)
|
||||
{
|
||||
get { return _roundElements; }
|
||||
set
|
||||
if (value != null)
|
||||
{
|
||||
_roundElements = value;
|
||||
RaisePropertyChanged(nameof(RoundElements));
|
||||
OnItemSelected(value);
|
||||
}
|
||||
}
|
||||
|
||||
[ObservableProperty]
|
||||
private ObservableCollection<RoundBuilderElement> roundElements;
|
||||
|
||||
public Participant SelectedItem
|
||||
{
|
||||
get => _selectedItem;
|
||||
set
|
||||
{
|
||||
if (_selectedItem != value)
|
||||
{
|
||||
[ObservableProperty]
|
||||
private GameRound? gameRoundObject = new();
|
||||
|
||||
_selectedItem = value;
|
||||
RaisePropertyChanged(nameof(SelectedItem));
|
||||
OnItemSelected(value); // Metod som triggas vid val
|
||||
}
|
||||
}
|
||||
}
|
||||
[ObservableProperty]
|
||||
private ObservableCollection<RoundBuilderGroup> gameRoundList = new();
|
||||
|
||||
[ObservableProperty]
|
||||
private ObservableCollection<Participant> participantList = new();
|
||||
|
||||
|
||||
#region commented out
|
||||
|
||||
//public ObservableCollection<RoundBuilderElement> RoundElements
|
||||
//{
|
||||
// get { return _roundElements; }
|
||||
// set
|
||||
// {
|
||||
// _roundElements = value;
|
||||
// OnPropertyChanged(nameof(RoundElements));
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
//public Participant SelectedItem
|
||||
//{
|
||||
// get => _selectedItem;
|
||||
// set
|
||||
// {
|
||||
// if (_selectedItem != value)
|
||||
// {
|
||||
|
||||
// _selectedItem = value;
|
||||
// OnPropertyChanged(nameof(SelectedItem));
|
||||
// OnItemSelected(value); // Metod som triggas vid val
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
//public GameRound? GameRoundObject
|
||||
//{
|
||||
// get { return _GameRoundObject; }
|
||||
// set
|
||||
// {
|
||||
// _GameRoundObject = value;
|
||||
// OnPropertyChanged(nameof(GameRoundObject));
|
||||
// }
|
||||
//}
|
||||
|
||||
//public ObservableCollection<RoundBuilderGroup> GameRoundList
|
||||
//{
|
||||
// get { return _GameRoundList; }
|
||||
// set
|
||||
// {
|
||||
// _GameRoundList = value;
|
||||
// OnPropertyChanged(nameof(GameRoundList));
|
||||
// }
|
||||
//}
|
||||
//public ObservableCollection<Participant> ParticipantList
|
||||
//{
|
||||
// get { return _ParticipantList; }
|
||||
// set
|
||||
// {
|
||||
// _ParticipantList = value;
|
||||
// OnPropertyChanged(nameof(ParticipantList));
|
||||
// }
|
||||
//}
|
||||
#endregion
|
||||
private void OnItemSelected(Participant item)
|
||||
{
|
||||
if (_roundElements.Count == 0)
|
||||
if (RoundElements.Count == 0)
|
||||
{
|
||||
var GameRound = new GameRound
|
||||
{
|
||||
@ -110,42 +159,12 @@ public class RoundStartingViewModel : ViewModelBase
|
||||
newElement.GameRoundId = GamePointStart.GameRoundId;
|
||||
newElement.GamePointId = GamePointStart.GamePointId;
|
||||
|
||||
_roundElements.Add(newElement);
|
||||
RoundElements.Add(newElement);
|
||||
// Gör något med det valda objektet
|
||||
Debug.WriteLine($"Du valde: {item.LastNameFirstName}");
|
||||
}
|
||||
|
||||
|
||||
public GameRound? GameRoundObject
|
||||
{
|
||||
get { return _GameRoundObject; }
|
||||
set
|
||||
{
|
||||
_GameRoundObject = value;
|
||||
RaisePropertyChanged(nameof(GameRoundObject));
|
||||
}
|
||||
}
|
||||
|
||||
public ObservableCollection<RoundBuilderGroup> GameRoundList
|
||||
{
|
||||
get { return _GameRoundList; }
|
||||
set
|
||||
{
|
||||
_GameRoundList = value;
|
||||
RaisePropertyChanged(nameof(GameRoundList));
|
||||
}
|
||||
}
|
||||
|
||||
public ObservableCollection<Participant> ParticipantList
|
||||
{
|
||||
get { return _ParticipantList; }
|
||||
set
|
||||
{
|
||||
_ParticipantList = value;
|
||||
RaisePropertyChanged(nameof(ParticipantList));
|
||||
}
|
||||
}
|
||||
|
||||
#region Get Method
|
||||
public ObservableCollection<RoundBuilderGroup> Get()
|
||||
{
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
using Common.Library;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using GreadyPoang.EntityLayer;
|
||||
using GreadyPoang.ViewModelLayer;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace GreadyPoang.CommandClasses;
|
||||
|
||||
public class ParticipantViewModelCommands : ParticipantViewModel
|
||||
public partial class ParticipantViewModelCommands : ParticipantViewModel
|
||||
{
|
||||
#region constructors
|
||||
public ParticipantViewModelCommands() : base()
|
||||
@ -14,24 +15,15 @@ public class ParticipantViewModelCommands : ParticipantViewModel
|
||||
}
|
||||
public ParticipantViewModelCommands(IRepository<Participant> repo, IMethodSharingService<Participant> sharingService) : base(repo, sharingService)
|
||||
{
|
||||
Init();
|
||||
IsSaveCommandEnabled = true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Variables
|
||||
private bool _IsSaveCommandEnabled = true;
|
||||
#endregion
|
||||
|
||||
#region Public Properties
|
||||
public bool IsSaveCommandEnabled
|
||||
{
|
||||
get { return _IsSaveCommandEnabled; }
|
||||
set
|
||||
{
|
||||
_IsSaveCommandEnabled = value;
|
||||
RaisePropertyChanged(nameof(IsSaveCommandEnabled));
|
||||
}
|
||||
}
|
||||
[ObservableProperty]
|
||||
private bool isSaveCommandEnabled;
|
||||
#endregion
|
||||
|
||||
#region Commands
|
||||
@ -40,9 +32,9 @@ public class ParticipantViewModelCommands : ParticipantViewModel
|
||||
#endregion
|
||||
|
||||
#region Init Method
|
||||
public override void Init()
|
||||
public void Init()
|
||||
{
|
||||
base.Init();
|
||||
//base.Init();
|
||||
SaveCommand = new Command(async () => SaveAsync(), () => IsSaveCommandEnabled);
|
||||
EditCommand = new Command<int>(async (id) => await EditAsync(id), (id) => id > 0);
|
||||
}
|
||||
|
||||
@ -25,27 +25,22 @@ public class RoundRunningViewModelCommands : RoundRunningViewModel
|
||||
combined,
|
||||
objectMessage)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
#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; }
|
||||
//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; }
|
||||
public ICommand StoreAndHandlePointsCommand { get; private set; }
|
||||
|
||||
#endregion
|
||||
|
||||
public override void Init()
|
||||
public void Init()
|
||||
{
|
||||
base.Init();
|
||||
StoreAndHandlePointsCommand = new Command(async () => StoreAndHandleAsync());
|
||||
//EditCommand = new Command<int>(async (id) => await EditAsync(id), (id) => id > 0);
|
||||
//RensaCommand = new Command(async () => RensaAsync());
|
||||
//ParticipantTappedCommand = new Command<RoundBuilderElement>(async (selectedParticipant) => SelectNewlyAddedParticipant(selectedParticipant));
|
||||
//ElementTappedCommand = new Command<RoundBuilderElement>((selectedElement) => RoundSelected(selectedElement));
|
||||
|
||||
}
|
||||
|
||||
private async Task StoreAndHandleAsync()
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using Common.Library;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using GreadyPoang.DataLayer;
|
||||
using GreadyPoang.EntityLayer;
|
||||
using GreadyPoang.Services;
|
||||
@ -7,7 +8,7 @@ using System.Windows.Input;
|
||||
|
||||
namespace GreadyPoang.CommandClasses;
|
||||
|
||||
public class RoundStartingViewModelCommands : RoundStartingViewModel
|
||||
public partial class RoundStartingViewModelCommands : RoundStartingViewModel
|
||||
{
|
||||
public RoundStartingViewModelCommands() : base()
|
||||
{
|
||||
@ -25,23 +26,13 @@ public class RoundStartingViewModelCommands : RoundStartingViewModel
|
||||
combined,
|
||||
objectMessage)
|
||||
{
|
||||
Init();
|
||||
IsSaveCommandEnabled = true;
|
||||
}
|
||||
|
||||
#region Private Variables
|
||||
private bool _IsSaveCommandEnabled = true;
|
||||
#endregion
|
||||
|
||||
#region Public Properties
|
||||
public bool IsSaveCommandEnabled
|
||||
{
|
||||
get { return _IsSaveCommandEnabled; }
|
||||
set
|
||||
{
|
||||
_IsSaveCommandEnabled = value;
|
||||
RaisePropertyChanged(nameof(IsSaveCommandEnabled));
|
||||
}
|
||||
}
|
||||
|
||||
[ObservableProperty]
|
||||
private bool isSaveCommandEnabled;
|
||||
#endregion
|
||||
|
||||
#region Commands
|
||||
@ -53,9 +44,10 @@ public class RoundStartingViewModelCommands : RoundStartingViewModel
|
||||
#endregion
|
||||
|
||||
#region Init Method
|
||||
public override void Init()
|
||||
|
||||
public void Init()
|
||||
{
|
||||
base.Init();
|
||||
//base.Init();
|
||||
SaveCommand = new Command(async () => SaveAsync(), () => IsSaveCommandEnabled);
|
||||
EditCommand = new Command<int>(async (id) => await EditAsync(id), (id) => id > 0);
|
||||
RensaCommand = new Command(async () => RensaAsync());
|
||||
|
||||
@ -60,6 +60,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
|
||||
<PackageReference Include="Microsoft.Maui.Controls" Version="9.0.100" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.8" />
|
||||
|
||||
Reference in New Issue
Block a user