Add project files.

This commit is contained in:
2025-10-11 08:15:33 +02:00
commit 5d1e7858f2
140 changed files with 7567 additions and 0 deletions

63
.gitattributes vendored Normal file
View File

@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain

363
.gitignore vendored Normal file
View File

@ -0,0 +1,363 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Oo]ut/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd

View File

@ -0,0 +1,29 @@
using System.ComponentModel;
namespace Common.Library;
public abstract class CommonBase : INotifyPropertyChanged
{
#region Constructor
protected CommonBase()
{
Init();
}
#endregion
#region Init Method
public virtual void Init()
{
}
#endregion
#region RaisePropertyChanged Method
public event PropertyChangedEventHandler? PropertyChanged;
public virtual void RaisePropertyChanged(string propertyName)
{
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
#endregion
}

View File

@ -0,0 +1,5 @@
namespace Common.Library;
public class EntityBase : CommonBase
{
}

View File

@ -0,0 +1,14 @@
//using GreadyPoang.DataLayer;
namespace Common.Library;
public class ViewModelBase : CommonBase
{
//private readonly LocalDbService _dbService;
//public ViewModelBase(LocalDbService dbService)
//{
// _dbService = dbService;
//}
}

View File

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>
net9.0-android;
net9.0-ios;
net9.0-maccatalyst;
net9.0-windows10.0.19041
</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,9 @@
using System.Collections.ObjectModel;
namespace Common.Library
{
public interface IMethodSharingService<TEntity>
{
ObservableCollection<TEntity> Get();
}
}

View File

@ -0,0 +1,10 @@
namespace Common.Library;
public interface IRepository<TEntity>
{
Task<IEnumerable<TEntity>> Get();
Task<TEntity?> Get(int id);
Task<int> Save(TEntity entity);
bool Delete(TEntity entity);
Task<bool> DeleteById(int Id);
}

0
Example.cs Normal file
View File

View File

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Common.Library\Common.Library.csproj" />
<ProjectReference Include="..\Gready_Poang.EntityLayer\Gready_Poang.EntityLayer.csproj" />
<ProjectReference Include="..\Gready_Poang.ViewModelLayer\Gready_Poang.ViewModelLayer.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,30 @@
namespace GreadyPoang.Common;
public class BehaviorBase<T> : Behavior<T> where T : BindableObject
{
public T? AssociatedObject { get; private set; }
protected override void OnAttachedTo(T bindable)
{
base.OnAttachedTo(bindable);
AssociatedObject = bindable;
if (bindable.BindingContext != null)
BindingContext = bindable.BindingContext;
bindable.BindingContextChanged += OnBindingContextChanged;
}
protected override void OnDetachingFrom(T bindable)
{
base.OnDetachingFrom(bindable);
bindable.BindingContextChanged -= OnBindingContextChanged;
AssociatedObject = null;
}
void OnBindingContextChanged(object? sender, EventArgs e)
{
if (AssociatedObject != null)
BindingContext = AssociatedObject.BindingContext;
}
}

View File

@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>
net9.0-android;
net9.0-ios;
net9.0-maccatalyst;
net9.0-windows10.0.19041
</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" Version="9.0.100" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,44 @@
using System.Text.RegularExpressions;
namespace GreadyPoang.Common;
public class DigitsOnlyBehavior : Behavior<Entry?>
{
protected override void OnAttachedTo(Entry? entry)
{
if (entry != null)
{
entry.TextChanged += OnTextChanged;
}
base.OnAttachedTo(entry);
}
protected override void OnDetachingFrom(Entry? entry)
{
if (entry != null)
{
entry.TextChanged -= OnTextChanged;
}
base.OnDetachingFrom(entry);
}
private void OnTextChanged(object? sender, TextChangedEventArgs e)
{
var entry = sender as Entry;
if (entry == null) return;
// Tillåt endast siffror (09)
if (!Regex.IsMatch(e.NewTextValue, @"^\d*$"))
{
entry.Text = e.OldTextValue; // Återställ till tidigare giltigt värde
}
/*
* Vill du tillåta decimaler? Ändra regex till @"^\d*\.?\d*$"
Vill du tillåta negativa tal? Använd @"^-?\d*$"
Vill du visa en varning när användaren skriver fel?
Lägg till en BindableProperty för IsValid och bind den till UI.
*
*/
}
}

View File

@ -0,0 +1,59 @@
using System.Reflection;
using System.Windows.Input;
namespace GreadyPoang.Common;
public class EventToCommandBehavior : BehaviorBase<VisualElement>
{
public required string EventName { get; set; }
public static readonly BindableProperty CommandProperty =
BindableProperty.Create(nameof(Command), typeof(ICommand), typeof(EventToCommandBehavior));
public ICommand Command
{
get => (ICommand)GetValue(CommandProperty);
set => SetValue(CommandProperty, value);
}
// Fix for CS8618: Make the field nullable and fix IDE1006: Add '_' prefix
private EventInfo? _eventInfo;
private Delegate? _eventHandler;
protected override void OnAttachedTo(VisualElement bindable)
{
base.OnAttachedTo(bindable);
if (bindable == null || string.IsNullOrEmpty(EventName))
return;
var runtimeEvent = bindable.GetType().GetRuntimeEvent(EventName);
if (runtimeEvent == null)
throw new ArgumentException($"Event '{EventName}' not found on type '{bindable.GetType().Name}'");
_eventInfo = runtimeEvent;
MethodInfo? methodInfo = typeof(EventToCommandBehavior).GetTypeInfo().GetDeclaredMethod(nameof(OnEvent));
if (methodInfo == null)
throw new InvalidOperationException($"Method '{nameof(OnEvent)}' not found on type '{typeof(EventToCommandBehavior).Name}'");
if (_eventInfo.EventHandlerType == null)
throw new InvalidOperationException($"EventHandlerType for event '{EventName}' is null on type '{bindable.GetType().Name}'");
_eventHandler = methodInfo.CreateDelegate(_eventInfo.EventHandlerType, this);
_eventInfo.AddEventHandler(bindable, _eventHandler);
}
protected override void OnDetachingFrom(VisualElement bindable)
{
base.OnDetachingFrom(bindable);
if (_eventInfo != null && _eventHandler != null)
_eventInfo.RemoveEventHandler(bindable, _eventHandler);
}
private void OnEvent(object sender, object eventArgs)
{
if (Command?.CanExecute(eventArgs) == true)
Command.Execute(eventArgs);
}
}

View File

@ -0,0 +1,148 @@
using GreadyPoang.DataLayer.Database;
using GreadyPoang.EntityLayer;
using Microsoft.EntityFrameworkCore;
namespace GreadyPoang.DataLayer;
public class CombinedRepository : ICombinedRepository
{
private readonly DataContext _context;
public CombinedRepository(DataContext context)
{
_context = context;
}
public IEnumerable<RoundBuilderElement> roundBuilderElements()
{
var latestGamePoints = _context.GamePoints
.AsEnumerable()
.GroupBy(gp => new { gp.GameRoundId, gp.ParticipantId })
.Select(g => g.OrderByDescending(gp => gp.GamePointId).First())
.ToList();
var gamerounds = _context.GameRounds.AsEnumerable();
var participants = _context.Participants.AsEnumerable();
var result = (from gameRound in gamerounds
join gamePoint in latestGamePoints on gameRound.GameRoundId equals gamePoint.GameRoundId
join participant in participants on gamePoint.ParticipantId equals participant.ParticipantId
orderby gameRound.GameRoundStartDate descending, participant.LastName, participant.FirstName, gamePoint.GameRoundRegNr
select new RoundBuilderElement
{
ParticipantId = participant.ParticipantId,
ParticipantName = participant.LastNameFirstName,
GamePointId = gamePoint.GamePointId,
GameRoundRegNr = gamePoint.GameRoundRegNr,
GameRegPoints = gamePoint.GameRegPoints,
GameRoundId = gameRound.GameRoundId,
GameRoundStartDate = gameRound.GameRoundStartDate,
Status = gameRound.GameStatus
}).ToList();
return result;
}
public IEnumerable<RoundBuilderElement> roundBuilderElementsDb()
{
var result = _context.RoundBuilderElements
.FromSqlRaw(@"
SELECT
gp.GamePointId,
gp.GameRoundId,
gp.GameRoundRegNr,
latest.totPoints as GameRegPoints,
gr.GameRoundStartDate,
gr.GameStatus AS Status,
p.ParticipantId,
(p.LastName || ' ' || p.FirstName) AS ParticipantName
FROM GamePoints gp
INNER JOIN (
SELECT ParticipantId, GameRoundId, MAX(GamePointId) AS MaxGamePointId , sum(GameRegPoints) AS totPoints
FROM GamePoints
GROUP BY ParticipantId, GameRoundId
) latest ON gp.GamePointId = latest.MaxGamePointId
INNER JOIN GameRounds gr ON gp.GameRoundId = gr.GameRoundId
INNER JOIN Participants p ON gp.ParticipantId = p.ParticipantId
ORDER BY gr.GameRoundStartDate DESC, p.LastName, p.FirstName, gp.GameRoundRegNr
")
.ToList();
return result;
}
public IEnumerable<RoundBuilderElement> roundBuilderElementsDbById(int GameId)
{
var result = _context.RoundBuilderElements
.FromSql($@"
SELECT
gp.GamePointId,
gp.GameRoundId,
gp.GameRoundRegNr,
gp.GameRegPoints,
gr.GameRoundStartDate,
gr.GameStatus AS Status,
p.ParticipantId,
(p.LastName || ' ' || p.FirstName) AS ParticipantName
FROM GamePoints gp
INNER JOIN (
SELECT ParticipantId, GameRoundId, MAX(GamePointId) AS MaxGamePointId
FROM GamePoints
GROUP BY ParticipantId, GameRoundId
) latest ON gp.GamePointId = latest.MaxGamePointId
INNER JOIN GameRounds gr ON gp.GameRoundId = gr.GameRoundId
INNER JOIN Participants p ON gp.ParticipantId = p.ParticipantId
WHERE gp.GameRoundId = {GameId.ToString()}
ORDER BY gr.GameRoundStartDate DESC, p.LastName, p.FirstName, gp.GameRoundRegNr
")
.ToList();
return result;
}
public IEnumerable<RoundBuilderElement> roundBuilderElementsTotal()
{
var result = (from gameRound in _context.GameRounds
join gamePoint in _context.GamePoints on gameRound.GameRoundId equals gamePoint.GameRoundId
join participant in _context.Participants on gamePoint.ParticipantId equals participant.ParticipantId
orderby gameRound.GameRoundStartDate descending, participant.LastName, participant.FirstName, gamePoint.GameRoundRegNr
select new RoundBuilderElement
{
ParticipantId = participant.ParticipantId,
ParticipantName = participant.LastNameFirstName,
GamePointId = gamePoint.GamePointId,
GameRoundRegNr = gamePoint.GameRoundRegNr,
GameRegPoints = gamePoint.GameRegPoints,
GameRoundId = gameRound.GameRoundId,
GameRoundStartDate = gameRound.GameRoundStartDate,
Status = gameRound.GameStatus
}).ToList();
return result;
}
public IEnumerable<RoundBuilderElement> roundBuilderElementsTotalById(int roundId)
{
var result = (from gameRound in _context.GameRounds
join gamePoint in _context.GamePoints on gameRound.GameRoundId equals gamePoint.GameRoundId
join participant in _context.Participants on gamePoint.ParticipantId equals participant.ParticipantId
where gameRound.GameRoundId == roundId
orderby gameRound.GameRoundStartDate descending, participant.LastName, participant.FirstName, gamePoint.GameRoundRegNr
select new RoundBuilderElement
{
ParticipantId = participant.ParticipantId,
ParticipantName = participant.LastNameFirstName,
GamePointId = gamePoint.GamePointId,
GameRoundRegNr = gamePoint.GameRoundRegNr,
GameRegPoints = gamePoint.GameRegPoints,
GameRoundId = gameRound.GameRoundId,
GameRoundStartDate = gameRound.GameRoundStartDate,
Status = gameRound.GameStatus
}).ToList();
return result;
}
}

View File

@ -0,0 +1,83 @@
using Common.Library;
using GreadyPoang.DataLayer.Database;
using GreadyPoang.EntityLayer;
using Microsoft.EntityFrameworkCore;
namespace GreadyPoang.DataLayer;
public class GamePointRepository : IRepository<GamePoint>
{
private readonly DataContext _dataContext;
public GamePointRepository(DataContext dataContext)
{
_dataContext = dataContext;
}
public async Task<IEnumerable<GamePoint>> Get()
{
return await _dataContext.GamePoints.ToListAsync();
}
public async Task<GamePoint?> Get(int id)
{
return await _dataContext.GamePoints.FindAsync(id);
}
public async Task<int> Save(GamePoint entity)
{
var res = -1;
if ((entity.GameRoundRegNr == 0)
&& (entity.GameRegPoints == 0))
{
return res; // Validation failed
}
if (entity.GamePointId == 0)
{
_dataContext.GamePoints.Add(entity);
await _dataContext.SaveChangesAsync();
res = entity.GamePointId;
}
else
{
_dataContext.GamePoints.Update(entity);
await _dataContext.SaveChangesAsync();
res = entity.GamePointId;
}
return res;
}
public bool Delete(GamePoint entity)
{
var res = false;
try
{
_dataContext.GamePoints.Remove(entity);
_dataContext.SaveChangesAsync();
res = true;
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"Error deleting participant: {ex.Message}");
res = false;
}
return res;
}
public async Task<bool> DeleteById(int Id)
{
var ok = false;
var delObject = await this.Get(Id);
if (delObject != null)
{
try
{
ok = this.Delete(delObject);
}
catch (Exception ex)
{
throw new Exception("Unsuccessful remove of GamePoint: " + ex.Message);
}
}
return ok;
}
}

View File

@ -0,0 +1,81 @@
using Common.Library;
using GreadyPoang.DataLayer.Database;
using GreadyPoang.EntityLayer;
using Microsoft.EntityFrameworkCore;
namespace GreadyPoang.DataLayer;
public class GameRoundRepository : IRepository<GameRound>
{
private readonly DataContext _dataContext;
public GameRoundRepository(DataContext dataContext)
{
_dataContext = dataContext;
}
public bool Delete(GameRound entity)
{
var res = false;
try
{
_dataContext.GameRounds.Remove(entity);
_dataContext.SaveChanges();
res = true;
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"Error deleting GameRound: {ex.Message}");
res = false;
}
return res;
}
public async Task<IEnumerable<GameRound>> Get()
{
return await _dataContext.GameRounds.ToListAsync();
}
public async Task<GameRound?> Get(int id)
{
return await _dataContext.GameRounds.FindAsync(id);
}
public async Task<int> Save(GameRound entity)
{
var res = -1;
if (entity.GameRoundId == 0)
{
_dataContext.GameRounds.Add(entity);
await _dataContext.SaveChangesAsync();
res = entity.GameRoundId;
}
else
{
_dataContext.GameRounds.Update(entity);
await _dataContext.SaveChangesAsync();
res = entity.GameRoundId;
}
return res;
}
public async Task<bool> DeleteById(int Id)
{
var ok = false;
var delObject = await this.Get(Id);
if (delObject != null)
{
try
{
ok = this.Delete(delObject);
}
catch (Exception ex)
{
throw new Exception("Unsuccessful remove of GameRound: " + ex.Message);
}
}
return ok;
}
}

View File

@ -0,0 +1,46 @@
using GreadyPoang.EntityLayer;
using SQLite;
namespace GreadyPoang.DataLayer;
public class LocalDbService
{
private const string DB_NAME = "PoangDB";
private readonly SQLiteAsyncConnection _connection;
public LocalDbService()
{
//string dbPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), DB_NAME);
string dbPath = Path.Combine(FileSystem.Current.AppDataDirectory, DB_NAME);
_connection = new SQLiteAsyncConnection(dbPath);
_connection.CreateTableAsync<Participant>().Wait();
}
public async Task<List<Participant>> GetParticipantsAsync()
{
return await _connection.Table<Participant>().ToListAsync();
}
public async Task<Participant?> GetParticipantAsync(int id)
{
return await _connection.Table<Participant>().Where(p => p.ParticipantId == id).FirstOrDefaultAsync();
}
public async Task<int> SaveParticipantAsync(Participant participant)
{
if (participant.ParticipantId != 0)
{
return await _connection.UpdateAsync(participant);
}
else
{
return await _connection.InsertAsync(participant);
}
}
public async Task<int> DeleteParticipantAsync(Participant participant)
{
return await _connection.DeleteAsync(participant);
}
}

View File

@ -0,0 +1,84 @@
using Common.Library;
using GreadyPoang.DataLayer.Database;
using GreadyPoang.EntityLayer;
using Microsoft.EntityFrameworkCore;
namespace GreadyPoang.DataLayer;
public class ParticipantRepository : IRepository<Participant>
{
private readonly DataContext _dataContext;
public ParticipantRepository(DataContext dataContext)
{
_dataContext = dataContext;
}
public async Task<IEnumerable<Participant>> Get()
{
return await _dataContext.Participants.ToListAsync();
}
public async Task<Participant?> Get(int id)
{
// Fix: Use FindAsync with key value array, not a predicate
return await _dataContext.Participants.FindAsync(id);
}
public async Task<int> Save(Participant entity)
{
var res = -1;
if (string.IsNullOrEmpty(entity.FirstName)
|| string.IsNullOrEmpty(entity.LastName))
{
return res; // Validation failed
}
if (entity.ParticipantId == 0)
{
_dataContext.Participants.Add(entity);
await _dataContext.SaveChangesAsync();
res = entity.ParticipantId;
}
else
{
_dataContext.Participants.Update(entity);
await _dataContext.SaveChangesAsync();
res = entity.ParticipantId;
}
return res;
}
public bool Delete(Participant entity)
{
var res = false;
try
{
_dataContext.Participants.Remove(entity);
_dataContext.SaveChanges();
res = true;
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"Error deleting participant: {ex.Message}");
res = false;
}
return res;
}
public async Task<bool> DeleteById(int Id)
{
var ok = false;
var delObject = await this.Get(Id);
if (delObject != null)
{
try
{
ok = this.Delete(delObject);
}
catch (Exception ex)
{
throw new Exception("Unsuccessful remove of Participant: " + ex.Message);
}
}
return ok;
}
}

View File

@ -0,0 +1,41 @@
using GreadyPoang.EntityLayer;
using Microsoft.EntityFrameworkCore;
namespace GreadyPoang.DataLayer.Database;
public class DataContext : DbContext
{
public DataContext(DbContextOptions<DataContext> options) : base(options)
{
}
//public DbSet<User> Users => Set<User>();
public DbSet<Participant> Participants { get; set; }
public DbSet<GamePoint> GamePoints { get; set; }
public DbSet<GameRound> GameRounds { get; set; }
public DbSet<RoundBuilderElement> RoundBuilderElements { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<Participant>().HasData(
new Participant { ParticipantId = 1, FirstName = "John", LastName = "Doe", Email = "John.Doe@gmail.com" },
new Participant { ParticipantId = 2, FirstName = "Jane", LastName = "Black", Email = "jb@gmail.com" },
new Participant { ParticipantId = 3, FirstName = "Mary", LastName = "White", Email = "mw@gmail.com" }
);
modelBuilder.Entity<GameRound>().HasData(
new GameRound { GameRoundId = 1, GameRoundStartDate = new DateTime(2025, 10, 15, 19, 10, 15), GameRoundFinished = DateTime.MinValue, GameStatus = GamePointStatus.New },
new GameRound { GameRoundId = 2, GameRoundStartDate = new DateTime(2025, 09, 15, 19, 10, 15), GameRoundFinished = DateTime.MinValue, GameStatus = GamePointStatus.New },
new GameRound { GameRoundId = 3, GameRoundStartDate = new DateTime(2025, 09, 20, 19, 10, 15), GameRoundFinished = DateTime.MinValue, GameStatus = GamePointStatus.New }
);
modelBuilder.Entity<GamePoint>().HasData(
new GamePoint { GamePointId = 1, ParticipantId = 1, GameRoundId = 2, GameDate = new DateTime(2025, 10, 15, 20, 10, 15), GameRoundRegNr = 1, GameRegPoints = 1050 },
new GamePoint { GamePointId = 2, ParticipantId = 1, GameRoundId = 2, GameDate = new DateTime(2025, 10, 15, 20, 15, 15), GameRoundRegNr = 3, GameRegPoints = 350 },
new GamePoint { GamePointId = 3, ParticipantId = 3, GameRoundId = 2, GameDate = new DateTime(2025, 10, 15, 20, 12, 15), GameRoundRegNr = 2, GameRegPoints = 1000 },
new GamePoint { GamePointId = 4, ParticipantId = 3, GameRoundId = 2, GameDate = new DateTime(2025, 10, 15, 20, 20, 15), GameRoundRegNr = 4, GameRegPoints = 400 }
);
modelBuilder.Entity<RoundBuilderElement>().HasNoKey();
}
}

View File

@ -0,0 +1,34 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>
net9.0-android;
net9.0-ios;
net9.0-maccatalyst;
net9.0-windows10.0.19041
</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Compile Remove="DataClasses\LocalDbService.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.8" />
<PackageReference Include="Microsoft.Maui.Controls" Version="9.0.100" />
<PackageReference Include="sqlite-net-pcl" Version="1.9.172" />
<PackageReference Include="SQLitePCLRaw.bundle_green" Version="2.1.11" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Common.Library\Common.Library.csproj" />
<ProjectReference Include="..\Gready_Poang.EntityLayer\Gready_Poang.EntityLayer.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,13 @@

using GreadyPoang.EntityLayer;
namespace GreadyPoang.DataLayer;
public interface ICombinedRepository
{
IEnumerable<RoundBuilderElement> roundBuilderElements();
IEnumerable<RoundBuilderElement> roundBuilderElementsDb();
IEnumerable<RoundBuilderElement> roundBuilderElementsDbById(int GameId);
IEnumerable<RoundBuilderElement> roundBuilderElementsTotal();
IEnumerable<RoundBuilderElement> roundBuilderElementsTotalById(int roundId);
}

View File

@ -0,0 +1,70 @@
// <auto-generated />
using GreadyPoang.DataLayer.Database;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace GreadyPoang.DataLayer.Migrations
{
[DbContext(typeof(DataContext))]
[Migration("20250901152226_initialCreate")]
partial class initialCreate
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "9.0.8");
modelBuilder.Entity("GreadyPoang.EntityLayer.Participant", b =>
{
b.Property<int>("ParticipantId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("ParticipantId");
b.ToTable("Participants");
b.HasData(
new
{
ParticipantId = 1,
Email = "John.Doe@gmail.com",
FirstName = "John",
LastName = "Doe"
},
new
{
ParticipantId = 2,
Email = "jb@gmail.com",
FirstName = "Jane",
LastName = "Black"
},
new
{
ParticipantId = 3,
Email = "mw@gmail.com",
FirstName = "Mary",
LastName = "White"
});
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,48 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace GreadyPoang.DataLayer.Migrations
{
/// <inheritdoc />
public partial class initialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Participants",
columns: table => new
{
ParticipantId = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
FirstName = table.Column<string>(type: "TEXT", nullable: false),
LastName = table.Column<string>(type: "TEXT", nullable: false),
Email = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Participants", x => x.ParticipantId);
});
migrationBuilder.InsertData(
table: "Participants",
columns: new[] { "ParticipantId", "Email", "FirstName", "LastName" },
values: new object[,]
{
{ 1, "John.Doe@gmail.com", "John", "Doe" },
{ 2, "jb@gmail.com", "Jane", "Black" },
{ 3, "mw@gmail.com", "Mary", "White" }
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Participants");
}
}
}

View File

@ -0,0 +1,135 @@
// <auto-generated />
using System;
using GreadyPoang.DataLayer.Database;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace GreadyPoang.DataLayer.Migrations
{
[DbContext(typeof(DataContext))]
[Migration("20250902115700_GamePointsTable")]
partial class GamePointsTable
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "9.0.8");
modelBuilder.Entity("GreadyPoang.EntityLayer.GamePoint", b =>
{
b.Property<int>("GamePointId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime>("GameDate")
.HasColumnType("TEXT");
b.Property<int>("GameHeatId")
.HasColumnType("INTEGER");
b.Property<int>("GameHeatRegNr")
.HasColumnType("INTEGER");
b.Property<int>("GameRegPoints")
.HasColumnType("INTEGER");
b.Property<int>("ParticipantId")
.HasColumnType("INTEGER");
b.HasKey("GamePointId");
b.ToTable("GamePoints");
b.HasData(
new
{
GamePointId = 1,
GameDate = new DateTime(2025, 9, 2, 13, 56, 59, 539, DateTimeKind.Local).AddTicks(8341),
GameHeatId = 0,
GameHeatRegNr = 1,
GameRegPoints = 1050,
ParticipantId = 1
},
new
{
GamePointId = 2,
GameDate = new DateTime(2025, 9, 2, 13, 56, 59, 539, DateTimeKind.Local).AddTicks(8923),
GameHeatId = 0,
GameHeatRegNr = 3,
GameRegPoints = 350,
ParticipantId = 1
},
new
{
GamePointId = 3,
GameDate = new DateTime(2025, 9, 2, 13, 56, 59, 539, DateTimeKind.Local).AddTicks(8927),
GameHeatId = 0,
GameHeatRegNr = 2,
GameRegPoints = 1000,
ParticipantId = 3
},
new
{
GamePointId = 4,
GameDate = new DateTime(2025, 9, 2, 13, 56, 59, 539, DateTimeKind.Local).AddTicks(8929),
GameHeatId = 0,
GameHeatRegNr = 4,
GameRegPoints = 400,
ParticipantId = 3
});
});
modelBuilder.Entity("GreadyPoang.EntityLayer.Participant", b =>
{
b.Property<int>("ParticipantId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("ParticipantId");
b.ToTable("Participants");
b.HasData(
new
{
ParticipantId = 1,
Email = "John.Doe@gmail.com",
FirstName = "John",
LastName = "Doe"
},
new
{
ParticipantId = 2,
Email = "jb@gmail.com",
FirstName = "Jane",
LastName = "Black"
},
new
{
ParticipantId = 3,
Email = "mw@gmail.com",
FirstName = "Mary",
LastName = "White"
});
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,52 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace GreadyPoang.DataLayer.Migrations
{
/// <inheritdoc />
public partial class GamePointsTable : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "GamePoints",
columns: table => new
{
GamePointId = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
ParticipantId = table.Column<int>(type: "INTEGER", nullable: false),
GameHeatId = table.Column<int>(type: "INTEGER", nullable: false),
GameDate = table.Column<DateTime>(type: "TEXT", nullable: false),
GameHeatRegNr = table.Column<int>(type: "INTEGER", nullable: false),
GameRegPoints = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_GamePoints", x => x.GamePointId);
});
migrationBuilder.InsertData(
table: "GamePoints",
columns: new[] { "GamePointId", "GameDate", "GameHeatId", "GameHeatRegNr", "GameRegPoints", "ParticipantId" },
values: new object[,]
{
{ 1, new DateTime(2025, 9, 2, 13, 56, 59, 539, DateTimeKind.Local).AddTicks(8341), 0, 1, 1050, 1 },
{ 2, new DateTime(2025, 9, 2, 13, 56, 59, 539, DateTimeKind.Local).AddTicks(8923), 0, 3, 350, 1 },
{ 3, new DateTime(2025, 9, 2, 13, 56, 59, 539, DateTimeKind.Local).AddTicks(8927), 0, 2, 1000, 3 },
{ 4, new DateTime(2025, 9, 2, 13, 56, 59, 539, DateTimeKind.Local).AddTicks(8929), 0, 4, 400, 3 }
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "GamePoints");
}
}
}

View File

@ -0,0 +1,135 @@
// <auto-generated />
using System;
using GreadyPoang.DataLayer.Database;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace GreadyPoang.DataLayer.Migrations
{
[DbContext(typeof(DataContext))]
[Migration("20250902120934_GamePointsTableStaticSeed")]
partial class GamePointsTableStaticSeed
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "9.0.8");
modelBuilder.Entity("GreadyPoang.EntityLayer.GamePoint", b =>
{
b.Property<int>("GamePointId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime>("GameDate")
.HasColumnType("TEXT");
b.Property<int>("GameHeatId")
.HasColumnType("INTEGER");
b.Property<int>("GameHeatRegNr")
.HasColumnType("INTEGER");
b.Property<int>("GameRegPoints")
.HasColumnType("INTEGER");
b.Property<int>("ParticipantId")
.HasColumnType("INTEGER");
b.HasKey("GamePointId");
b.ToTable("GamePoints");
b.HasData(
new
{
GamePointId = 1,
GameDate = new DateTime(2025, 9, 2, 14, 9, 34, 269, DateTimeKind.Local).AddTicks(5394),
GameHeatId = 0,
GameHeatRegNr = 1,
GameRegPoints = 1050,
ParticipantId = 1
},
new
{
GamePointId = 2,
GameDate = new DateTime(2025, 9, 2, 14, 9, 34, 269, DateTimeKind.Local).AddTicks(6081),
GameHeatId = 0,
GameHeatRegNr = 3,
GameRegPoints = 350,
ParticipantId = 1
},
new
{
GamePointId = 3,
GameDate = new DateTime(2025, 9, 2, 14, 9, 34, 269, DateTimeKind.Local).AddTicks(6085),
GameHeatId = 0,
GameHeatRegNr = 2,
GameRegPoints = 1000,
ParticipantId = 3
},
new
{
GamePointId = 4,
GameDate = new DateTime(2025, 9, 2, 14, 9, 34, 269, DateTimeKind.Local).AddTicks(6088),
GameHeatId = 0,
GameHeatRegNr = 4,
GameRegPoints = 400,
ParticipantId = 3
});
});
modelBuilder.Entity("GreadyPoang.EntityLayer.Participant", b =>
{
b.Property<int>("ParticipantId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("ParticipantId");
b.ToTable("Participants");
b.HasData(
new
{
ParticipantId = 1,
Email = "John.Doe@gmail.com",
FirstName = "John",
LastName = "Doe"
},
new
{
ParticipantId = 2,
Email = "jb@gmail.com",
FirstName = "Jane",
LastName = "Black"
},
new
{
ParticipantId = 3,
Email = "mw@gmail.com",
FirstName = "Mary",
LastName = "White"
});
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,75 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace GreadyPoang.DataLayer.Migrations
{
/// <inheritdoc />
public partial class GamePointsTableStaticSeed : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.UpdateData(
table: "GamePoints",
keyColumn: "GamePointId",
keyValue: 1,
column: "GameDate",
value: new DateTime(2025, 9, 2, 14, 9, 34, 269, DateTimeKind.Local).AddTicks(5394));
migrationBuilder.UpdateData(
table: "GamePoints",
keyColumn: "GamePointId",
keyValue: 2,
column: "GameDate",
value: new DateTime(2025, 9, 2, 14, 9, 34, 269, DateTimeKind.Local).AddTicks(6081));
migrationBuilder.UpdateData(
table: "GamePoints",
keyColumn: "GamePointId",
keyValue: 3,
column: "GameDate",
value: new DateTime(2025, 9, 2, 14, 9, 34, 269, DateTimeKind.Local).AddTicks(6085));
migrationBuilder.UpdateData(
table: "GamePoints",
keyColumn: "GamePointId",
keyValue: 4,
column: "GameDate",
value: new DateTime(2025, 9, 2, 14, 9, 34, 269, DateTimeKind.Local).AddTicks(6088));
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.UpdateData(
table: "GamePoints",
keyColumn: "GamePointId",
keyValue: 1,
column: "GameDate",
value: new DateTime(2025, 9, 2, 13, 56, 59, 539, DateTimeKind.Local).AddTicks(8341));
migrationBuilder.UpdateData(
table: "GamePoints",
keyColumn: "GamePointId",
keyValue: 2,
column: "GameDate",
value: new DateTime(2025, 9, 2, 13, 56, 59, 539, DateTimeKind.Local).AddTicks(8923));
migrationBuilder.UpdateData(
table: "GamePoints",
keyColumn: "GamePointId",
keyValue: 3,
column: "GameDate",
value: new DateTime(2025, 9, 2, 13, 56, 59, 539, DateTimeKind.Local).AddTicks(8927));
migrationBuilder.UpdateData(
table: "GamePoints",
keyColumn: "GamePointId",
keyValue: 4,
column: "GameDate",
value: new DateTime(2025, 9, 2, 13, 56, 59, 539, DateTimeKind.Local).AddTicks(8929));
}
}
}

View File

@ -0,0 +1,135 @@
// <auto-generated />
using System;
using GreadyPoang.DataLayer.Database;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace GreadyPoang.DataLayer.Migrations
{
[DbContext(typeof(DataContext))]
[Migration("20250902122130_FixDateTimeSeed")]
partial class FixDateTimeSeed
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "9.0.8");
modelBuilder.Entity("GreadyPoang.EntityLayer.GamePoint", b =>
{
b.Property<int>("GamePointId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime>("GameDate")
.HasColumnType("TEXT");
b.Property<int>("GameHeatId")
.HasColumnType("INTEGER");
b.Property<int>("GameHeatRegNr")
.HasColumnType("INTEGER");
b.Property<int>("GameRegPoints")
.HasColumnType("INTEGER");
b.Property<int>("ParticipantId")
.HasColumnType("INTEGER");
b.HasKey("GamePointId");
b.ToTable("GamePoints");
b.HasData(
new
{
GamePointId = 1,
GameDate = new DateTime(2025, 10, 15, 20, 10, 15, 0, DateTimeKind.Unspecified),
GameHeatId = 0,
GameHeatRegNr = 1,
GameRegPoints = 1050,
ParticipantId = 1
},
new
{
GamePointId = 2,
GameDate = new DateTime(2025, 10, 15, 20, 15, 15, 0, DateTimeKind.Unspecified),
GameHeatId = 0,
GameHeatRegNr = 3,
GameRegPoints = 350,
ParticipantId = 1
},
new
{
GamePointId = 3,
GameDate = new DateTime(2025, 10, 15, 20, 12, 15, 0, DateTimeKind.Unspecified),
GameHeatId = 0,
GameHeatRegNr = 2,
GameRegPoints = 1000,
ParticipantId = 3
},
new
{
GamePointId = 4,
GameDate = new DateTime(2025, 10, 15, 20, 20, 15, 0, DateTimeKind.Unspecified),
GameHeatId = 0,
GameHeatRegNr = 4,
GameRegPoints = 400,
ParticipantId = 3
});
});
modelBuilder.Entity("GreadyPoang.EntityLayer.Participant", b =>
{
b.Property<int>("ParticipantId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("ParticipantId");
b.ToTable("Participants");
b.HasData(
new
{
ParticipantId = 1,
Email = "John.Doe@gmail.com",
FirstName = "John",
LastName = "Doe"
},
new
{
ParticipantId = 2,
Email = "jb@gmail.com",
FirstName = "Jane",
LastName = "Black"
},
new
{
ParticipantId = 3,
Email = "mw@gmail.com",
FirstName = "Mary",
LastName = "White"
});
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,75 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace GreadyPoang.DataLayer.Migrations
{
/// <inheritdoc />
public partial class FixDateTimeSeed : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.UpdateData(
table: "GamePoints",
keyColumn: "GamePointId",
keyValue: 1,
column: "GameDate",
value: new DateTime(2025, 10, 15, 20, 10, 15, 0, DateTimeKind.Unspecified));
migrationBuilder.UpdateData(
table: "GamePoints",
keyColumn: "GamePointId",
keyValue: 2,
column: "GameDate",
value: new DateTime(2025, 10, 15, 20, 15, 15, 0, DateTimeKind.Unspecified));
migrationBuilder.UpdateData(
table: "GamePoints",
keyColumn: "GamePointId",
keyValue: 3,
column: "GameDate",
value: new DateTime(2025, 10, 15, 20, 12, 15, 0, DateTimeKind.Unspecified));
migrationBuilder.UpdateData(
table: "GamePoints",
keyColumn: "GamePointId",
keyValue: 4,
column: "GameDate",
value: new DateTime(2025, 10, 15, 20, 20, 15, 0, DateTimeKind.Unspecified));
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.UpdateData(
table: "GamePoints",
keyColumn: "GamePointId",
keyValue: 1,
column: "GameDate",
value: new DateTime(2025, 9, 2, 14, 9, 34, 269, DateTimeKind.Local).AddTicks(5394));
migrationBuilder.UpdateData(
table: "GamePoints",
keyColumn: "GamePointId",
keyValue: 2,
column: "GameDate",
value: new DateTime(2025, 9, 2, 14, 9, 34, 269, DateTimeKind.Local).AddTicks(6081));
migrationBuilder.UpdateData(
table: "GamePoints",
keyColumn: "GamePointId",
keyValue: 3,
column: "GameDate",
value: new DateTime(2025, 9, 2, 14, 9, 34, 269, DateTimeKind.Local).AddTicks(6085));
migrationBuilder.UpdateData(
table: "GamePoints",
keyColumn: "GamePointId",
keyValue: 4,
column: "GameDate",
value: new DateTime(2025, 9, 2, 14, 9, 34, 269, DateTimeKind.Local).AddTicks(6088));
}
}
}

View File

@ -0,0 +1,135 @@
// <auto-generated />
using System;
using GreadyPoang.DataLayer.Database;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace GreadyPoang.DataLayer.Migrations
{
[DbContext(typeof(DataContext))]
[Migration("20250903062957_FixHeatToRoundParameter")]
partial class FixHeatToRoundParameter
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "9.0.8");
modelBuilder.Entity("GreadyPoang.EntityLayer.GamePoint", b =>
{
b.Property<int>("GamePointId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime>("GameDate")
.HasColumnType("TEXT");
b.Property<int>("GameHeatId")
.HasColumnType("INTEGER");
b.Property<int>("GameHeatRegNr")
.HasColumnType("INTEGER");
b.Property<int>("GameRegPoints")
.HasColumnType("INTEGER");
b.Property<int>("ParticipantId")
.HasColumnType("INTEGER");
b.HasKey("GamePointId");
b.ToTable("GamePoints");
b.HasData(
new
{
GamePointId = 1,
GameDate = new DateTime(2025, 10, 15, 20, 10, 15, 0, DateTimeKind.Unspecified),
GameHeatId = 0,
GameHeatRegNr = 1,
GameRegPoints = 1050,
ParticipantId = 1
},
new
{
GamePointId = 2,
GameDate = new DateTime(2025, 10, 15, 20, 15, 15, 0, DateTimeKind.Unspecified),
GameHeatId = 0,
GameHeatRegNr = 3,
GameRegPoints = 350,
ParticipantId = 1
},
new
{
GamePointId = 3,
GameDate = new DateTime(2025, 10, 15, 20, 12, 15, 0, DateTimeKind.Unspecified),
GameHeatId = 0,
GameHeatRegNr = 2,
GameRegPoints = 1000,
ParticipantId = 3
},
new
{
GamePointId = 4,
GameDate = new DateTime(2025, 10, 15, 20, 20, 15, 0, DateTimeKind.Unspecified),
GameHeatId = 0,
GameHeatRegNr = 4,
GameRegPoints = 400,
ParticipantId = 3
});
});
modelBuilder.Entity("GreadyPoang.EntityLayer.Participant", b =>
{
b.Property<int>("ParticipantId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("ParticipantId");
b.ToTable("Participants");
b.HasData(
new
{
ParticipantId = 1,
Email = "John.Doe@gmail.com",
FirstName = "John",
LastName = "Doe"
},
new
{
ParticipantId = 2,
Email = "jb@gmail.com",
FirstName = "Jane",
LastName = "Black"
},
new
{
ParticipantId = 3,
Email = "mw@gmail.com",
FirstName = "Mary",
LastName = "White"
});
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace GreadyPoang.DataLayer.Migrations
{
/// <inheritdoc />
public partial class FixHeatToRoundParameter : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View File

@ -0,0 +1,135 @@
// <auto-generated />
using System;
using GreadyPoang.DataLayer.Database;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace GreadyPoang.DataLayer.Migrations
{
[DbContext(typeof(DataContext))]
[Migration("20250903070200_FixHeatToRoundParams")]
partial class FixHeatToRoundParams
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "9.0.8");
modelBuilder.Entity("GreadyPoang.EntityLayer.GamePoint", b =>
{
b.Property<int>("GamePointId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime>("GameDate")
.HasColumnType("TEXT");
b.Property<int>("GameRegPoints")
.HasColumnType("INTEGER");
b.Property<int>("GameRoundId")
.HasColumnType("INTEGER");
b.Property<int>("GameRoundRegNr")
.HasColumnType("INTEGER");
b.Property<int>("ParticipantId")
.HasColumnType("INTEGER");
b.HasKey("GamePointId");
b.ToTable("GamePoints");
b.HasData(
new
{
GamePointId = 1,
GameDate = new DateTime(2025, 10, 15, 20, 10, 15, 0, DateTimeKind.Unspecified),
GameRegPoints = 1050,
GameRoundId = 0,
GameRoundRegNr = 1,
ParticipantId = 1
},
new
{
GamePointId = 2,
GameDate = new DateTime(2025, 10, 15, 20, 15, 15, 0, DateTimeKind.Unspecified),
GameRegPoints = 350,
GameRoundId = 0,
GameRoundRegNr = 3,
ParticipantId = 1
},
new
{
GamePointId = 3,
GameDate = new DateTime(2025, 10, 15, 20, 12, 15, 0, DateTimeKind.Unspecified),
GameRegPoints = 1000,
GameRoundId = 0,
GameRoundRegNr = 2,
ParticipantId = 3
},
new
{
GamePointId = 4,
GameDate = new DateTime(2025, 10, 15, 20, 20, 15, 0, DateTimeKind.Unspecified),
GameRegPoints = 400,
GameRoundId = 0,
GameRoundRegNr = 4,
ParticipantId = 3
});
});
modelBuilder.Entity("GreadyPoang.EntityLayer.Participant", b =>
{
b.Property<int>("ParticipantId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("ParticipantId");
b.ToTable("Participants");
b.HasData(
new
{
ParticipantId = 1,
Email = "John.Doe@gmail.com",
FirstName = "John",
LastName = "Doe"
},
new
{
ParticipantId = 2,
Email = "jb@gmail.com",
FirstName = "Jane",
LastName = "Black"
},
new
{
ParticipantId = 3,
Email = "mw@gmail.com",
FirstName = "Mary",
LastName = "White"
});
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,38 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace GreadyPoang.DataLayer.Migrations
{
/// <inheritdoc />
public partial class FixHeatToRoundParams : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "GameHeatRegNr",
table: "GamePoints",
newName: "GameRoundRegNr");
migrationBuilder.RenameColumn(
name: "GameHeatId",
table: "GamePoints",
newName: "GameRoundId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "GameRoundRegNr",
table: "GamePoints",
newName: "GameHeatRegNr");
migrationBuilder.RenameColumn(
name: "GameRoundId",
table: "GamePoints",
newName: "GameHeatId");
}
}
}

View File

@ -0,0 +1,135 @@
// <auto-generated />
using System;
using GreadyPoang.DataLayer.Database;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace GreadyPoang.DataLayer.Migrations
{
[DbContext(typeof(DataContext))]
[Migration("20250903074537_AddedStatusEnum")]
partial class AddedStatusEnum
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "9.0.8");
modelBuilder.Entity("GreadyPoang.EntityLayer.GamePoint", b =>
{
b.Property<int>("GamePointId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime>("GameDate")
.HasColumnType("TEXT");
b.Property<int>("GameRegPoints")
.HasColumnType("INTEGER");
b.Property<int>("GameRoundId")
.HasColumnType("INTEGER");
b.Property<int>("GameRoundRegNr")
.HasColumnType("INTEGER");
b.Property<int>("ParticipantId")
.HasColumnType("INTEGER");
b.HasKey("GamePointId");
b.ToTable("GamePoints");
b.HasData(
new
{
GamePointId = 1,
GameDate = new DateTime(2025, 10, 15, 20, 10, 15, 0, DateTimeKind.Unspecified),
GameRegPoints = 1050,
GameRoundId = 0,
GameRoundRegNr = 1,
ParticipantId = 1
},
new
{
GamePointId = 2,
GameDate = new DateTime(2025, 10, 15, 20, 15, 15, 0, DateTimeKind.Unspecified),
GameRegPoints = 350,
GameRoundId = 0,
GameRoundRegNr = 3,
ParticipantId = 1
},
new
{
GamePointId = 3,
GameDate = new DateTime(2025, 10, 15, 20, 12, 15, 0, DateTimeKind.Unspecified),
GameRegPoints = 1000,
GameRoundId = 0,
GameRoundRegNr = 2,
ParticipantId = 3
},
new
{
GamePointId = 4,
GameDate = new DateTime(2025, 10, 15, 20, 20, 15, 0, DateTimeKind.Unspecified),
GameRegPoints = 400,
GameRoundId = 0,
GameRoundRegNr = 4,
ParticipantId = 3
});
});
modelBuilder.Entity("GreadyPoang.EntityLayer.Participant", b =>
{
b.Property<int>("ParticipantId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("ParticipantId");
b.ToTable("Participants");
b.HasData(
new
{
ParticipantId = 1,
Email = "John.Doe@gmail.com",
FirstName = "John",
LastName = "Doe"
},
new
{
ParticipantId = 2,
Email = "jb@gmail.com",
FirstName = "Jane",
LastName = "Black"
},
new
{
ParticipantId = 3,
Email = "mw@gmail.com",
FirstName = "Mary",
LastName = "White"
});
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace GreadyPoang.DataLayer.Migrations
{
/// <inheritdoc />
public partial class AddedStatusEnum : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View File

@ -0,0 +1,179 @@
// <auto-generated />
using System;
using GreadyPoang.DataLayer.Database;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace GreadyPoang.DataLayer.Migrations
{
[DbContext(typeof(DataContext))]
[Migration("20250903195147_AddedTableGameRounds")]
partial class AddedTableGameRounds
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "9.0.8");
modelBuilder.Entity("GreadyPoang.EntityLayer.GamePoint", b =>
{
b.Property<int>("GamePointId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime>("GameDate")
.HasColumnType("TEXT");
b.Property<int>("GameRegPoints")
.HasColumnType("INTEGER");
b.Property<int>("GameRoundId")
.HasColumnType("INTEGER");
b.Property<int>("GameRoundRegNr")
.HasColumnType("INTEGER");
b.Property<int>("ParticipantId")
.HasColumnType("INTEGER");
b.Property<int>("PointStatus")
.HasColumnType("INTEGER");
b.HasKey("GamePointId");
b.ToTable("GamePoints");
b.HasData(
new
{
GamePointId = 1,
GameDate = new DateTime(2025, 10, 15, 20, 10, 15, 0, DateTimeKind.Unspecified),
GameRegPoints = 1050,
GameRoundId = 2,
GameRoundRegNr = 1,
ParticipantId = 1,
PointStatus = 0
},
new
{
GamePointId = 2,
GameDate = new DateTime(2025, 10, 15, 20, 15, 15, 0, DateTimeKind.Unspecified),
GameRegPoints = 350,
GameRoundId = 2,
GameRoundRegNr = 3,
ParticipantId = 1,
PointStatus = 0
},
new
{
GamePointId = 3,
GameDate = new DateTime(2025, 10, 15, 20, 12, 15, 0, DateTimeKind.Unspecified),
GameRegPoints = 1000,
GameRoundId = 2,
GameRoundRegNr = 2,
ParticipantId = 3,
PointStatus = 0
},
new
{
GamePointId = 4,
GameDate = new DateTime(2025, 10, 15, 20, 20, 15, 0, DateTimeKind.Unspecified),
GameRegPoints = 400,
GameRoundId = 2,
GameRoundRegNr = 4,
ParticipantId = 3,
PointStatus = 0
});
});
modelBuilder.Entity("GreadyPoang.EntityLayer.GameRound", b =>
{
b.Property<int>("GameRoundId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime?>("GameRoundFinished")
.HasColumnType("TEXT");
b.Property<DateTime>("GameRoundStartDate")
.HasColumnType("TEXT");
b.HasKey("GameRoundId");
b.ToTable("GameRounds");
b.HasData(
new
{
GameRoundId = 1,
GameRoundFinished = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
GameRoundStartDate = new DateTime(2025, 10, 15, 19, 10, 15, 0, DateTimeKind.Unspecified)
},
new
{
GameRoundId = 2,
GameRoundFinished = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
GameRoundStartDate = new DateTime(2025, 9, 15, 19, 10, 15, 0, DateTimeKind.Unspecified)
},
new
{
GameRoundId = 3,
GameRoundFinished = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
GameRoundStartDate = new DateTime(2025, 9, 20, 19, 10, 15, 0, DateTimeKind.Unspecified)
});
});
modelBuilder.Entity("GreadyPoang.EntityLayer.Participant", b =>
{
b.Property<int>("ParticipantId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("ParticipantId");
b.ToTable("Participants");
b.HasData(
new
{
ParticipantId = 1,
Email = "John.Doe@gmail.com",
FirstName = "John",
LastName = "Doe"
},
new
{
ParticipantId = 2,
Email = "jb@gmail.com",
FirstName = "Jane",
LastName = "Black"
},
new
{
ParticipantId = 3,
Email = "mw@gmail.com",
FirstName = "Mary",
LastName = "White"
});
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,115 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace GreadyPoang.DataLayer.Migrations
{
/// <inheritdoc />
public partial class AddedTableGameRounds : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "PointStatus",
table: "GamePoints",
type: "INTEGER",
nullable: false,
defaultValue: 0);
migrationBuilder.CreateTable(
name: "GameRounds",
columns: table => new
{
GameRoundId = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
GameRoundFinished = table.Column<DateTime>(type: "TEXT", nullable: true),
GameRoundStartDate = table.Column<DateTime>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_GameRounds", x => x.GameRoundId);
});
migrationBuilder.UpdateData(
table: "GamePoints",
keyColumn: "GamePointId",
keyValue: 1,
columns: new[] { "GameRoundId", "PointStatus" },
values: new object[] { 2, 0 });
migrationBuilder.UpdateData(
table: "GamePoints",
keyColumn: "GamePointId",
keyValue: 2,
columns: new[] { "GameRoundId", "PointStatus" },
values: new object[] { 2, 0 });
migrationBuilder.UpdateData(
table: "GamePoints",
keyColumn: "GamePointId",
keyValue: 3,
columns: new[] { "GameRoundId", "PointStatus" },
values: new object[] { 2, 0 });
migrationBuilder.UpdateData(
table: "GamePoints",
keyColumn: "GamePointId",
keyValue: 4,
columns: new[] { "GameRoundId", "PointStatus" },
values: new object[] { 2, 0 });
migrationBuilder.InsertData(
table: "GameRounds",
columns: new[] { "GameRoundId", "GameRoundFinished", "GameRoundStartDate" },
values: new object[,]
{
{ 1, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new DateTime(2025, 10, 15, 19, 10, 15, 0, DateTimeKind.Unspecified) },
{ 2, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new DateTime(2025, 9, 15, 19, 10, 15, 0, DateTimeKind.Unspecified) },
{ 3, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new DateTime(2025, 9, 20, 19, 10, 15, 0, DateTimeKind.Unspecified) }
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "GameRounds");
migrationBuilder.DropColumn(
name: "PointStatus",
table: "GamePoints");
migrationBuilder.UpdateData(
table: "GamePoints",
keyColumn: "GamePointId",
keyValue: 1,
column: "GameRoundId",
value: 0);
migrationBuilder.UpdateData(
table: "GamePoints",
keyColumn: "GamePointId",
keyValue: 2,
column: "GameRoundId",
value: 0);
migrationBuilder.UpdateData(
table: "GamePoints",
keyColumn: "GamePointId",
keyValue: 3,
column: "GameRoundId",
value: 0);
migrationBuilder.UpdateData(
table: "GamePoints",
keyColumn: "GamePointId",
keyValue: 4,
column: "GameRoundId",
value: 0);
}
}
}

View File

@ -0,0 +1,179 @@
// <auto-generated />
using System;
using GreadyPoang.DataLayer.Database;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace GreadyPoang.DataLayer.Migrations
{
[DbContext(typeof(DataContext))]
[Migration("20250903195935_ChangedUpdateOrderInSeeding")]
partial class ChangedUpdateOrderInSeeding
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "9.0.8");
modelBuilder.Entity("GreadyPoang.EntityLayer.GamePoint", b =>
{
b.Property<int>("GamePointId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime>("GameDate")
.HasColumnType("TEXT");
b.Property<int>("GameRegPoints")
.HasColumnType("INTEGER");
b.Property<int>("GameRoundId")
.HasColumnType("INTEGER");
b.Property<int>("GameRoundRegNr")
.HasColumnType("INTEGER");
b.Property<int>("ParticipantId")
.HasColumnType("INTEGER");
b.Property<int>("PointStatus")
.HasColumnType("INTEGER");
b.HasKey("GamePointId");
b.ToTable("GamePoints");
b.HasData(
new
{
GamePointId = 1,
GameDate = new DateTime(2025, 10, 15, 20, 10, 15, 0, DateTimeKind.Unspecified),
GameRegPoints = 1050,
GameRoundId = 2,
GameRoundRegNr = 1,
ParticipantId = 1,
PointStatus = 0
},
new
{
GamePointId = 2,
GameDate = new DateTime(2025, 10, 15, 20, 15, 15, 0, DateTimeKind.Unspecified),
GameRegPoints = 350,
GameRoundId = 2,
GameRoundRegNr = 3,
ParticipantId = 1,
PointStatus = 0
},
new
{
GamePointId = 3,
GameDate = new DateTime(2025, 10, 15, 20, 12, 15, 0, DateTimeKind.Unspecified),
GameRegPoints = 1000,
GameRoundId = 2,
GameRoundRegNr = 2,
ParticipantId = 3,
PointStatus = 0
},
new
{
GamePointId = 4,
GameDate = new DateTime(2025, 10, 15, 20, 20, 15, 0, DateTimeKind.Unspecified),
GameRegPoints = 400,
GameRoundId = 2,
GameRoundRegNr = 4,
ParticipantId = 3,
PointStatus = 0
});
});
modelBuilder.Entity("GreadyPoang.EntityLayer.GameRound", b =>
{
b.Property<int>("GameRoundId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime?>("GameRoundFinished")
.HasColumnType("TEXT");
b.Property<DateTime>("GameRoundStartDate")
.HasColumnType("TEXT");
b.HasKey("GameRoundId");
b.ToTable("GameRounds");
b.HasData(
new
{
GameRoundId = 1,
GameRoundFinished = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
GameRoundStartDate = new DateTime(2025, 10, 15, 19, 10, 15, 0, DateTimeKind.Unspecified)
},
new
{
GameRoundId = 2,
GameRoundFinished = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
GameRoundStartDate = new DateTime(2025, 9, 15, 19, 10, 15, 0, DateTimeKind.Unspecified)
},
new
{
GameRoundId = 3,
GameRoundFinished = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
GameRoundStartDate = new DateTime(2025, 9, 20, 19, 10, 15, 0, DateTimeKind.Unspecified)
});
});
modelBuilder.Entity("GreadyPoang.EntityLayer.Participant", b =>
{
b.Property<int>("ParticipantId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("ParticipantId");
b.ToTable("Participants");
b.HasData(
new
{
ParticipantId = 1,
Email = "John.Doe@gmail.com",
FirstName = "John",
LastName = "Doe"
},
new
{
ParticipantId = 2,
Email = "jb@gmail.com",
FirstName = "Jane",
LastName = "Black"
},
new
{
ParticipantId = 3,
Email = "mw@gmail.com",
FirstName = "Mary",
LastName = "White"
});
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace GreadyPoang.DataLayer.Migrations
{
/// <inheritdoc />
public partial class ChangedUpdateOrderInSeeding : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View File

@ -0,0 +1,178 @@
// <auto-generated />
using System;
using GreadyPoang.DataLayer.Database;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace GreadyPoang.DataLayer.Migrations
{
[DbContext(typeof(DataContext))]
[Migration("20250914064850_statusfieldmove")]
partial class statusfieldmove
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "9.0.8");
modelBuilder.Entity("GreadyPoang.EntityLayer.GamePoint", b =>
{
b.Property<int>("GamePointId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime>("GameDate")
.HasColumnType("TEXT");
b.Property<int>("GameRegPoints")
.HasColumnType("INTEGER");
b.Property<int>("GameRoundId")
.HasColumnType("INTEGER");
b.Property<int>("GameRoundRegNr")
.HasColumnType("INTEGER");
b.Property<int>("ParticipantId")
.HasColumnType("INTEGER");
b.HasKey("GamePointId");
b.ToTable("GamePoints");
b.HasData(
new
{
GamePointId = 1,
GameDate = new DateTime(2025, 10, 15, 20, 10, 15, 0, DateTimeKind.Unspecified),
GameRegPoints = 1050,
GameRoundId = 2,
GameRoundRegNr = 1,
ParticipantId = 1
},
new
{
GamePointId = 2,
GameDate = new DateTime(2025, 10, 15, 20, 15, 15, 0, DateTimeKind.Unspecified),
GameRegPoints = 350,
GameRoundId = 2,
GameRoundRegNr = 3,
ParticipantId = 1
},
new
{
GamePointId = 3,
GameDate = new DateTime(2025, 10, 15, 20, 12, 15, 0, DateTimeKind.Unspecified),
GameRegPoints = 1000,
GameRoundId = 2,
GameRoundRegNr = 2,
ParticipantId = 3
},
new
{
GamePointId = 4,
GameDate = new DateTime(2025, 10, 15, 20, 20, 15, 0, DateTimeKind.Unspecified),
GameRegPoints = 400,
GameRoundId = 2,
GameRoundRegNr = 4,
ParticipantId = 3
});
});
modelBuilder.Entity("GreadyPoang.EntityLayer.GameRound", b =>
{
b.Property<int>("GameRoundId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime?>("GameRoundFinished")
.HasColumnType("TEXT");
b.Property<DateTime>("GameRoundStartDate")
.HasColumnType("TEXT");
b.Property<int>("GameStatus")
.HasColumnType("INTEGER");
b.HasKey("GameRoundId");
b.ToTable("GameRounds");
b.HasData(
new
{
GameRoundId = 1,
GameRoundFinished = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
GameRoundStartDate = new DateTime(2025, 10, 15, 19, 10, 15, 0, DateTimeKind.Unspecified),
GameStatus = 0
},
new
{
GameRoundId = 2,
GameRoundFinished = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
GameRoundStartDate = new DateTime(2025, 9, 15, 19, 10, 15, 0, DateTimeKind.Unspecified),
GameStatus = 0
},
new
{
GameRoundId = 3,
GameRoundFinished = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
GameRoundStartDate = new DateTime(2025, 9, 20, 19, 10, 15, 0, DateTimeKind.Unspecified),
GameStatus = 0
});
});
modelBuilder.Entity("GreadyPoang.EntityLayer.Participant", b =>
{
b.Property<int>("ParticipantId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("ParticipantId");
b.ToTable("Participants");
b.HasData(
new
{
ParticipantId = 1,
Email = "John.Doe@gmail.com",
FirstName = "John",
LastName = "Doe"
},
new
{
ParticipantId = 2,
Email = "jb@gmail.com",
FirstName = "Jane",
LastName = "Black"
},
new
{
ParticipantId = 3,
Email = "mw@gmail.com",
FirstName = "Mary",
LastName = "White"
});
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,89 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace GreadyPoang.DataLayer.Migrations
{
/// <inheritdoc />
public partial class statusfieldmove : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "PointStatus",
table: "GamePoints");
migrationBuilder.AddColumn<int>(
name: "GameStatus",
table: "GameRounds",
type: "INTEGER",
nullable: false,
defaultValue: 0);
migrationBuilder.UpdateData(
table: "GameRounds",
keyColumn: "GameRoundId",
keyValue: 1,
column: "GameStatus",
value: 0);
migrationBuilder.UpdateData(
table: "GameRounds",
keyColumn: "GameRoundId",
keyValue: 2,
column: "GameStatus",
value: 0);
migrationBuilder.UpdateData(
table: "GameRounds",
keyColumn: "GameRoundId",
keyValue: 3,
column: "GameStatus",
value: 0);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "GameStatus",
table: "GameRounds");
migrationBuilder.AddColumn<int>(
name: "PointStatus",
table: "GamePoints",
type: "INTEGER",
nullable: false,
defaultValue: 0);
migrationBuilder.UpdateData(
table: "GamePoints",
keyColumn: "GamePointId",
keyValue: 1,
column: "PointStatus",
value: 0);
migrationBuilder.UpdateData(
table: "GamePoints",
keyColumn: "GamePointId",
keyValue: 2,
column: "PointStatus",
value: 0);
migrationBuilder.UpdateData(
table: "GamePoints",
keyColumn: "GamePointId",
keyValue: 3,
column: "PointStatus",
value: 0);
migrationBuilder.UpdateData(
table: "GamePoints",
keyColumn: "GamePointId",
keyValue: 4,
column: "PointStatus",
value: 0);
}
}
}

View File

@ -0,0 +1,175 @@
// <auto-generated />
using System;
using GreadyPoang.DataLayer.Database;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace GreadyPoang.DataLayer.Migrations
{
[DbContext(typeof(DataContext))]
partial class DataContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "9.0.8");
modelBuilder.Entity("GreadyPoang.EntityLayer.GamePoint", b =>
{
b.Property<int>("GamePointId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime>("GameDate")
.HasColumnType("TEXT");
b.Property<int>("GameRegPoints")
.HasColumnType("INTEGER");
b.Property<int>("GameRoundId")
.HasColumnType("INTEGER");
b.Property<int>("GameRoundRegNr")
.HasColumnType("INTEGER");
b.Property<int>("ParticipantId")
.HasColumnType("INTEGER");
b.HasKey("GamePointId");
b.ToTable("GamePoints");
b.HasData(
new
{
GamePointId = 1,
GameDate = new DateTime(2025, 10, 15, 20, 10, 15, 0, DateTimeKind.Unspecified),
GameRegPoints = 1050,
GameRoundId = 2,
GameRoundRegNr = 1,
ParticipantId = 1
},
new
{
GamePointId = 2,
GameDate = new DateTime(2025, 10, 15, 20, 15, 15, 0, DateTimeKind.Unspecified),
GameRegPoints = 350,
GameRoundId = 2,
GameRoundRegNr = 3,
ParticipantId = 1
},
new
{
GamePointId = 3,
GameDate = new DateTime(2025, 10, 15, 20, 12, 15, 0, DateTimeKind.Unspecified),
GameRegPoints = 1000,
GameRoundId = 2,
GameRoundRegNr = 2,
ParticipantId = 3
},
new
{
GamePointId = 4,
GameDate = new DateTime(2025, 10, 15, 20, 20, 15, 0, DateTimeKind.Unspecified),
GameRegPoints = 400,
GameRoundId = 2,
GameRoundRegNr = 4,
ParticipantId = 3
});
});
modelBuilder.Entity("GreadyPoang.EntityLayer.GameRound", b =>
{
b.Property<int>("GameRoundId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime?>("GameRoundFinished")
.HasColumnType("TEXT");
b.Property<DateTime>("GameRoundStartDate")
.HasColumnType("TEXT");
b.Property<int>("GameStatus")
.HasColumnType("INTEGER");
b.HasKey("GameRoundId");
b.ToTable("GameRounds");
b.HasData(
new
{
GameRoundId = 1,
GameRoundFinished = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
GameRoundStartDate = new DateTime(2025, 10, 15, 19, 10, 15, 0, DateTimeKind.Unspecified),
GameStatus = 0
},
new
{
GameRoundId = 2,
GameRoundFinished = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
GameRoundStartDate = new DateTime(2025, 9, 15, 19, 10, 15, 0, DateTimeKind.Unspecified),
GameStatus = 0
},
new
{
GameRoundId = 3,
GameRoundFinished = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
GameRoundStartDate = new DateTime(2025, 9, 20, 19, 10, 15, 0, DateTimeKind.Unspecified),
GameStatus = 0
});
});
modelBuilder.Entity("GreadyPoang.EntityLayer.Participant", b =>
{
b.Property<int>("ParticipantId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("ParticipantId");
b.ToTable("Participants");
b.HasData(
new
{
ParticipantId = 1,
Email = "John.Doe@gmail.com",
FirstName = "John",
LastName = "Doe"
},
new
{
ParticipantId = 2,
Email = "jb@gmail.com",
FirstName = "Jane",
LastName = "Black"
},
new
{
ParticipantId = 3,
Email = "mw@gmail.com",
FirstName = "Mary",
LastName = "White"
});
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,97 @@
using Common.Library;
using SQLite;
namespace GreadyPoang.EntityLayer;
[Table("GamePoint")]
public class GamePoint : EntityBase
{
public GamePoint()
{
_gamePointId = 0;
_participantId = 0;
_gameRoundId = 0;
_gameDate = DateTime.Now;
_gameRoundRegNr = 0;
_gameRegPoints = 0;
}
private int _gamePointId;
private int _participantId;
private int _gameRoundId;
private DateTime _gameDate;
private int _gameRoundRegNr;
private int _gameRegPoints;
[PrimaryKey]
[AutoIncrement]
[Column("GamePointId")]
public int GamePointId
{
get { return _gamePointId; }
set
{
_gamePointId = value;
RaisePropertyChanged(nameof(GamePointId));
}
}
[Column("ParticipantId")]
public int ParticipantId
{
get { return _participantId; }
set
{
_participantId = value;
RaisePropertyChanged(nameof(ParticipantId));
}
}
[Column("GameRoundId")]
public int GameRoundId
{
get { return _gameRoundId; }
set
{
_gameRoundId = value;
RaisePropertyChanged(nameof(GameRoundId));
}
}
[Column("GameDate")]
public DateTime GameDate
{
get { return _gameDate; }
set
{
_gameDate = value;
RaisePropertyChanged(nameof(GameDate));
}
}
// 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
{
get { return _gameRoundRegNr; }
set
{
_gameRoundRegNr = value;
RaisePropertyChanged(nameof(GameRoundRegNr));
}
}
[Column("GameRegPoints")]
public int GameRegPoints
{
get { return _gameRegPoints; }
set
{
_gameRegPoints = value;
RaisePropertyChanged(nameof(GameRegPoints));
}
}
}

View File

@ -0,0 +1,77 @@
using Common.Library;
using SQLite;
namespace GreadyPoang.EntityLayer;
[Table("GameRound")]
public class GameRound : EntityBase
{
public GameRound()
{
_gameRoundId = 0;
_gameRoundStartDate = DateTime.Now;
_gameStatus = GamePointStatus.New;
_gameRoundFinished = null;
}
private int _gameRoundId;
private DateTime _gameRoundStartDate;
private GamePointStatus _gameStatus;
private DateTime? _gameRoundFinished;
[Column("GameRoundFinished")]
public DateTime? GameRoundFinished
{
get { return _gameRoundFinished; }
set
{
_gameRoundFinished = value;
RaisePropertyChanged(nameof(GameRoundFinished));
}
}
[Column("GameRoundStartDate")]
public DateTime GameRoundStartDate
{
get { return _gameRoundStartDate; }
set
{
_gameRoundStartDate = value;
RaisePropertyChanged(nameof(GameRoundStartDate));
}
}
[Column("GameStatus")]
public GamePointStatus GameStatus
{
get { return _gameStatus; }
set
{
_gameStatus = value;
RaisePropertyChanged(nameof(GameStatus));
}
}
[PrimaryKey]
[AutoIncrement]
[Column("GameRoundId")]
public int GameRoundId
{
get { return _gameRoundId; }
set
{
_gameRoundId = value;
RaisePropertyChanged(nameof(GameRoundId));
}
}
public string GameRoundStartDateString
{
get { return _gameRoundStartDate.ToString("yyyy-MM-dd"); }
}
}

View File

@ -0,0 +1,75 @@
using Common.Library;
using SQLite;
namespace GreadyPoang.EntityLayer;
[Table("Participants")]
public class Participant : EntityBase
{
public Participant()
{
_firstName = string.Empty;
_lastName = string.Empty;
_email = string.Empty;
}
private int _participantId;
private string _firstName;
private string _lastName;
private string _email;
[PrimaryKey]
[AutoIncrement]
[Column("ParticipantId")]
public int ParticipantId
{
get { return _participantId; }
set
{
_participantId = value;
RaisePropertyChanged(nameof(ParticipantId));
}
}
[Column("FirstName")]
public string FirstName
{
get { return _firstName; }
set
{
_firstName = value;
RaisePropertyChanged(nameof(FirstName));
}
}
[Column("LastName")]
public string LastName
{
get { return _lastName; }
set
{
_lastName = value;
RaisePropertyChanged(nameof(LastName));
}
}
[Column("Email")]
public string Email
{
get { return _email; }
set
{
_email = value;
RaisePropertyChanged(nameof(Email));
}
}
public string FullName
{
get { return $"{FirstName} {LastName}"; }
}
public string LastNameFirstName
{
get { return $"{LastName}, {FirstName}"; }
}
}

View File

@ -0,0 +1,11 @@
namespace GreadyPoang.EntityLayer;
public enum GamePointStatus
{
New = 0,
InProgress = 1,
Completed = 2,
Cancelled = 3,
Winning = 4,
Winner = 5
}

View File

@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>
net9.0-android;
net9.0-ios;
net9.0-maccatalyst;
net9.0-windows10.0.19041
</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Common.Library\Common.Library.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="sqlite-net-pcl" Version="1.9.172" />
<PackageReference Include="SQLitePCLRaw.bundle_green" Version="2.1.11" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,55 @@
using Common.Library;
namespace GreadyPoang.EntityLayer;
public class PlayerColumn : EntityBase
{
public PlayerColumn()
{
_playerName = string.Empty;
_values = new List<string>();
}
private int _playerId;
private string _playerName;
private List<string> _values;
public string PlayerName
{
get { return _playerName; }
set
{
_playerName = value;
RaisePropertyChanged(nameof(PlayerName));
}
}
public List<string> Values
{
get { return _values; }
set
{
_values = value;
RaisePropertyChanged(nameof(Values));
}
}
public int PlayerId
{
get { return _playerId; }
set
{
_playerId = value;
RaisePropertyChanged(nameof(PlayerId));
}
}
private int _playerPoints;
public int PlayerPoints
{
get { return _playerPoints; }
set { _playerPoints = value; }
}
}

View File

@ -0,0 +1,126 @@
using Common.Library;
namespace GreadyPoang.EntityLayer;
public class RoundBuilderElement : EntityBase
{
public RoundBuilderElement()
{
_participantId = 0;
_participantName = string.Empty;
_gameRoundRegNr = 0;
_gameRegPoints = 0;
_status = GamePointStatus.New;
_gameRoundStartDate = DateTime.MinValue;
_gameRoundId = 0;
_gamePointId = 0;
}
private int _participantId;
private string _participantName;
private int _gameRoundRegNr;
private int _gameRegPoints;
private GamePointStatus _status;
private DateTime _gameRoundStartDate;
private int _gameRoundId;
private int _gamePointId;
public int ParticipantId
{
get { return _participantId; }
set
{
_participantId = value;
RaisePropertyChanged(nameof(ParticipantId));
}
}
public string ParticipantName
{
get { return _participantName; }
set
{
_participantName = value;
RaisePropertyChanged(nameof(ParticipantName));
}
}
public int GameRoundRegNr
{
get { return _gameRoundRegNr; }
set
{
_gameRoundRegNr = value;
RaisePropertyChanged(nameof(GameRoundRegNr));
}
}
public int GameRegPoints
{
get { return _gameRegPoints; }
set
{
_gameRegPoints = value;
RaisePropertyChanged(nameof(GameRegPoints));
}
}
public GamePointStatus Status
{
get { return _status; }
set
{
_status = value;
RaisePropertyChanged(nameof(Status));
RaisePropertyChanged(nameof(StatusString));
}
}
public string StatusString
{
get { return _status.ToString(); }
}
public DateTime GameRoundStartDate
{
get { return _gameRoundStartDate; }
set
{
_gameRoundStartDate = value;
RaisePropertyChanged(nameof(GameRoundStartDate));
RaisePropertyChanged(nameof(GameRoundStartDateString));
}
}
public string GameRoundStartDateString
{
get { return _gameRoundStartDate.ToString("yyyy-MM-dd"); }
}
public int GameRoundId
{
get { return _gameRoundId; }
set
{
_gameRoundId = value;
RaisePropertyChanged(nameof(GameRoundId));
}
}
public int GamePointId
{
get { return _gamePointId; }
set
{
_gamePointId = value;
RaisePropertyChanged(nameof(GamePointId));
}
}
}

View File

@ -0,0 +1,56 @@
using Common.Library;
namespace GreadyPoang.EntityLayer;
public class RoundBuilderGroup : EntityBase
{
public RoundBuilderGroup()
{
_gameRoundId = 0;
_gameRoundStartDate = DateTime.MinValue;
_status = GamePointStatus.New;
_elements = new List<RoundBuilderElement>();
}
private int _gameRoundId;
private DateTime _gameRoundStartDate;
private GamePointStatus _status;
private List<RoundBuilderElement> _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<RoundBuilderElement> Elements
{
get { return _elements; }
set
{
_elements = value;
RaisePropertyChanged(nameof(Elements));
// No need to raise property changed for this example
}
}
}

View File

@ -0,0 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>
net9.0-android;
net9.0-ios;
net9.0-maccatalyst;
net9.0-windows10.0.19041
</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.8" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.8" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.8" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Gready_Poang.DataLayer\Gready_Poang.DataLayer.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,33 @@
using GreadyPoang.DataLayer.Database;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Hosting; // Replace with your actual namespace
class Program
{
static void Main(string[] args)
{
using var host = CreateHostBuilder(args).Build();
// Resolve your DbContext
var context = host.Services.GetRequiredService<DataContext>();
context.Database.EnsureCreated();
// Optional: Apply migrations at runtime
context.Database.Migrate();
Console.WriteLine("Migration applied successfully.");
}
static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureServices((_, services) =>
{
var MauiDataPath = string.Empty;
MauiDataPath = File.ReadAllText(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "MauiDataPath_GreadyPoang.txt"));
var dbPath = Path.Combine(MauiDataPath, "PoangDB.db");
services.AddDbContext<DataContext>(options =>
options.UseSqlite($"Data Source={dbPath}"));
});
}
// dotnet ef migrations add FixHeatToRoundParams --project GreadyPoang.DataLayer --startup-project GreadyPoang.Migrations
// dotnet ef database update --project GreadyPoang.DataLayer --startup-project GreadyPoang.Migrations

View File

@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>
net9.0-android;
net9.0-ios;
net9.0-maccatalyst;
net9.0-windows10.0.19041
</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Gready_Poang.EntityLayer\Gready_Poang.EntityLayer.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,9 @@
using GreadyPoang.EntityLayer;
namespace GreadyPoang.Services;
public class ObjectMessageService : IObjectMessageService
{
public required RoundBuilderGroup CurrentGroup { get; set; }
public bool Delivered { get; set; } = false;
}

View File

@ -0,0 +1,10 @@
using GreadyPoang.EntityLayer;
namespace GreadyPoang.Services
{
public interface IObjectMessageService
{
RoundBuilderGroup CurrentGroup { get; set; }
bool Delivered { get; set; }
}
}

View File

@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>
net9.0-android;
net9.0-ios;
net9.0-maccatalyst;
net9.0-windows10.0.19041
</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Common.Library\Common.Library.csproj" />
<ProjectReference Include="..\Gready_Poang.DataLayer\Gready_Poang.DataLayer.csproj" />
<ProjectReference Include="..\Gready_Poang.EntityLayer\Gready_Poang.EntityLayer.csproj" />
<ProjectReference Include="..\Gready_Poang.Services\Gready_Poang.Services.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,9 @@
namespace GreadyPoang.Core;
public interface INavigationService
{
Task NavigateToAsync(string route);
Task NavigateToPageAsync(Page page);
}

View File

@ -0,0 +1,6 @@
namespace GreadyPoang.Core;
public interface IPageFactory
{
Page CreateRoundPage();
}

View File

@ -0,0 +1,9 @@

namespace GreadyPoang.Core;
public interface ISplashService
{
Task ShowSplash(string text = "Välkommen!", int durationMs = 3000);
Task HideAsync();
}

View File

@ -0,0 +1,21 @@
using Common.Library;
namespace GreadyPoang.ViewModelLayer;
public class AppShellViewModel : ViewModelBase
{
private bool _roundRounningVisible = true;
public bool RoundRunningVisible
{
get { return _roundRounningVisible; }
set
{
_roundRounningVisible = value;
RaisePropertyChanged(nameof(RoundRunningVisible));
}
}
}

View File

@ -0,0 +1,30 @@
using Common.Library;
using GreadyPoang.Services;
namespace GreadyPoang.ViewModelLayer;
public class MainPageViewModel : ViewModelBase
{
private readonly AppShellViewModel _appShell;
private readonly IObjectMessageService _messageService;
public MainPageViewModel(
AppShellViewModel appShell,
IObjectMessageService messageService
) : base()
{
_appShell = appShell;
_messageService = messageService;
}
public void InitMessage()
{
if (_appShell.RoundRunningVisible == false)
{
_messageService.Delivered = true;
}
}
}

View File

@ -0,0 +1,37 @@
using Common.Library;
using GreadyPoang.EntityLayer;
using System.Collections.ObjectModel;
namespace GreadyPoang.ViewModelLayer;
public class MethodSharingService : ViewModelBase, IMethodSharingService<Participant>
{
private readonly IRepository<Participant> _repository;
public MethodSharingService(IRepository<Participant> repository)
{
_repository = repository;
}
public ObservableCollection<Participant> Get()
{
ObservableCollection<Participant> _participantList = new();
if (_repository != null)
{
var participantsTask = _repository.Get();
var participants = participantsTask is Task<IEnumerable<Participant>> task
? task.GetAwaiter().GetResult()
: (IEnumerable<Participant>)participantsTask;
foreach (var participant in participants)
{
if (!_participantList.Any(p => p.ParticipantId == participant.ParticipantId))
{
_participantList.Add(participant);
}
}
}
return _participantList;
}
}

View File

@ -0,0 +1,109 @@
using Common.Library;
using GreadyPoang.EntityLayer;
using GreadyPoang.Services;
using System.Collections.ObjectModel;
namespace GreadyPoang.ViewModelLayer;
public class ParticipantViewModel : ViewModelBase
{
#region Constructors
public ParticipantViewModel() : base()
{
}
public ParticipantViewModel(
IRepository<Participant> repo,
IMethodSharingService<Participant> sharingService,
AppShellViewModel appShell,
IObjectMessageService objectMessage) : base()
{
_Repository = repo;
_sharingService = sharingService;
_appShell = appShell;
_objectMessage = objectMessage;
}
#endregion
#region Private Variables
private Participant? _ParticipantObject = new();
private ObservableCollection<Participant> _ParticipantList = new();
private readonly IRepository<Participant>? _Repository;
private readonly IMethodSharingService<Participant> _sharingService;
private readonly AppShellViewModel _appShell;
private readonly IObjectMessageService _objectMessage;
#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()
{
if (_appShell.RoundRunningVisible == false)
{
_objectMessage.Delivered = true;
}
ParticipantList = _sharingService.Get();
return ParticipantList;
}
#endregion
#region Get(id) Method
public Participant? Get(int id)
{
try
{
ParticipantObject = _Repository?.Get(id).GetAwaiter().GetResult();
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"Error in Get method: {ex.Message}");
}
return ParticipantObject;
}
public virtual bool Save()
{
if (_Repository == null || ParticipantObject == null)
{
return false;
}
var tmpTask = _Repository.Save(ParticipantObject);
int tmp = tmpTask.GetAwaiter().GetResult();
if (tmp != -1)
{
ParticipantObject = new Participant();
this.Get();
}
return tmp != -1;
}
#endregion
}

View File

@ -0,0 +1,309 @@
using Common.Library;
using GreadyPoang.Core;
using GreadyPoang.DataLayer;
using GreadyPoang.EntityLayer;
using GreadyPoang.Services;
using System.Collections.ObjectModel;
using System.Diagnostics;
namespace GreadyPoang.ViewModelLayer;
public class RoundRunningViewModel : ViewModelBase
{
public event EventHandler RebuildRequested;
public RoundRunningViewModel() : base()
{
}
public RoundRunningViewModel(
IRepository<GameRound> roundsRepo,
IRepository<GamePoint> pointsRepo,
IMethodSharingService<Participant> sharingService,
ICombinedRepository combined,
IObjectMessageService objectMessage,
ISplashService splashService,
AppShellViewModel appShell
) : base()
{
_roundsRepo = roundsRepo;
_pointsRepo = pointsRepo;
_sharingService = sharingService;
_combined = combined;
_objectMessage = objectMessage;
_splashService = splashService;
_appShell = appShell;
_roundElements = new ObservableCollection<RoundBuilderElement>();
_builderObject = new();
_SplashShowing = false;
}
private bool _SplashShowing;
private readonly IRepository<GameRound>? _roundsRepo;
private readonly IRepository<GamePoint> _pointsRepo;
private readonly IMethodSharingService<Participant> _sharingService;
private readonly ICombinedRepository _combined;
private readonly IObjectMessageService _objectMessage;
private readonly ISplashService _splashService;
private readonly AppShellViewModel _appShell;
private ObservableCollection<RoundBuilderGroup> _GameRoundList = new();
private ObservableCollection<Participant> _ParticipantList = new();
private ObservableCollection<RoundBuilderElement> _roundElements;
private Collection<PlayerColumn> _playerColumns;
private RoundBuilderElement _builderObject;
public void TriggerRebuild()
{
// Trigga eventet
RebuildRequested?.Invoke(this, EventArgs.Empty);
}
// Översta raden
public ObservableCollection<RoundBuilderElement> RoundElements
{
get { return _roundElements; }
set
{
_roundElements = value;
RaisePropertyChanged(nameof(RoundElements));
}
}
// Nedersta strukturen
public Collection<PlayerColumn> PlayerColumns
{
get { return _playerColumns; }
set
{
_playerColumns = value;
RaisePropertyChanged(nameof(PlayerColumns));
}
}
public RoundBuilderElement BuilderObject
{
get { return _builderObject; }
set
{
_builderObject = value;
RaisePropertyChanged(nameof(BuilderObject));
}
}
private bool _gobackVisible = true;
public bool GobackVisible
{
get { return _gobackVisible; }
set
{
_gobackVisible = value;
RaisePropertyChanged(nameof(GobackVisible));
}
}
public ObservableCollection<RoundBuilderElement> Get()
{
//_overlay.ShowSplash("Laddar...", 30);
if (_objectMessage.CurrentGroup != null)
{
GobackVisible = _objectMessage.Delivered;
_objectMessage.Delivered = false;
//CurrentGroup är satt från RoundStarting ViewModel
Debug.WriteLine($"Chosen round: {_objectMessage.CurrentGroup.GameRoundId}");
if (RoundElements.Count > 0)
{
RoundElements.Clear();
}
foreach (var item in _objectMessage.CurrentGroup.Elements)
{
RoundElements.Add(item);
}
// Räkna ut vem som är nästa spelare
var nxt = nextPlayerElement();
// Aktuell spelare sätts som BuilderObject
BuilderObject.ParticipantName = _objectMessage.CurrentGroup.Elements[nxt].ParticipantName;
BuilderObject.GameRoundId = _objectMessage.CurrentGroup.GameRoundId;
BuilderObject.ParticipantId = _objectMessage.CurrentGroup.Elements[nxt].ParticipantId;
BuilderObject.Status = _objectMessage.CurrentGroup.Status;
// Alla poängposter från samtliga spelare i rundan samlas ihop och fördelas per deltagare
var localElements = _combined.roundBuilderElementsTotalById(_objectMessage.CurrentGroup.GameRoundId);
FillupResultTable(localElements);
foreach (var col in _playerColumns)
{
RoundElements.FirstOrDefault(e => e.ParticipantId == col.PlayerId).GameRegPoints = col.PlayerPoints;
}
TriggerRebuild();
}
return RoundElements;
}
public void StoreAndHandlePoints()
{
var game = _roundsRepo.Get(BuilderObject.GameRoundId).GetAwaiter().GetResult();
var regNr = RoundElements.Count > 0 ? RoundElements.Max(e => e.GameRoundRegNr) + 1 : 1;
if (game.GameStatus == GamePointStatus.New)
{
game.GameStatus = GamePointStatus.InProgress;
regNr = regNr == 0 ? 1 : regNr;
_roundsRepo.Save(game);
}
BuilderObject.Status = game.GameStatus;
var points = BuilderObject.GameRegPoints;
var newPoint = new GamePoint
{
ParticipantId = BuilderObject.ParticipantId,
GameRoundId = BuilderObject.GameRoundId,
GameDate = DateTime.Now,
GameRoundRegNr = regNr,
GameRegPoints = points
};
var pointId = _pointsRepo?.Save(newPoint).GetAwaiter().GetResult();
// Uppdatera listan med element
var tmpElements = _combined.roundBuilderElementsDbById(BuilderObject.GameRoundId);
RoundElements.Clear();
foreach (var item in tmpElements)
{
item.Status = GamePointStatus.InProgress;
RoundElements.Add(item);
}
// Uppdatera spelaren som skall spela nästa
var nxt = nextPlayerElement();
BuilderObject.GameRegPoints = 0;
BuilderObject.ParticipantName = RoundElements[nxt].ParticipantName;
BuilderObject.ParticipantId = RoundElements[nxt].ParticipantId;
BuilderObject.GameRoundId = RoundElements[0].GameRoundId;
var localElements = _combined.roundBuilderElementsTotalById(BuilderObject.GameRoundId);
FillupResultTable(localElements);
foreach (var col in _playerColumns)
{
RoundElements.FirstOrDefault(e => e.ParticipantId == col.PlayerId).GameRegPoints = col.PlayerPoints;
}
TriggerRebuild();
}
private int nextPlayerElement()
{
for (int i = 0; i < RoundElements.Count; i++)
{
if (RoundElements[i].GameRoundRegNr == -1 ||
(i > 0 && (RoundElements[i - 1].GameRoundRegNr > RoundElements[i].GameRoundRegNr)) ||
(i == 0 && RoundElements[i].GameRoundRegNr < RoundElements[RoundElements.Count - 1].GameRoundRegNr))
return i;
}
return -1;
}
private void FillupResultTable(IEnumerable<RoundBuilderElement> elements)
{
if (_playerColumns != null)
{
_playerColumns.Clear();
}
else
{
_playerColumns = new Collection<PlayerColumn>();
}
// if (elements.Any(g => g.GameRegPoints > 0))
if (BuilderObject.Status == GamePointStatus.InProgress)
{
PlayerColumn player = new PlayerColumn();
foreach (var element in elements)
{
player = _playerColumns.FirstOrDefault(p => p.PlayerId == element.ParticipantId);
if (player == null)
{
player = new PlayerColumn
{
PlayerName = element.ParticipantName,
PlayerId = element.ParticipantId,
PlayerPoints = 0
};
}
if (element.GameRegPoints > 0)
{
player.Values.Add(element.GameRegPoints.ToString());
player.PlayerPoints += element.GameRegPoints;
if (player.PlayerPoints > 10000)
{
var winner = RoundElements.FirstOrDefault(e => e.ParticipantId == player.PlayerId);
winner.Status = GamePointStatus.Winning;
}
}
//oldPart = element.ParticipantId;
if (!_playerColumns.Contains(player))
{
_playerColumns.Add(player);
}
}
}
else
{
Random slumper = new Random();
foreach (var element in elements)
{
var player = new PlayerColumn
{
PlayerName = element.ParticipantName
};
for (int i = 0; i < slumper.Next(6); i++)
{
player.Values.Add(slumper.Next(1, 10).ToString());
}
_playerColumns.Add(player);
}
}
}
public async void ToggleSplash()
{
if (!_SplashShowing)
{
//_overlay.ShowSplash("Clcicked!", 5000);
await _splashService.ShowSplash("Clicked", 0);
_SplashShowing = true;
}
else
{
await _splashService.HideAsync();
_SplashShowing = false;
}
}
public void GobackAsync()
{
_appShell.RoundRunningVisible = true;
}
}

View File

@ -0,0 +1,274 @@
using Common.Library;
using GreadyPoang.Core;
using GreadyPoang.DataLayer;
using GreadyPoang.EntityLayer;
using GreadyPoang.Services;
using System.Collections.ObjectModel;
using System.Diagnostics;
namespace GreadyPoang.ViewModelLayer;
public class RoundStartingViewModel : ViewModelBase
{
#region Constructors
public RoundStartingViewModel() : base()
{
}
public RoundStartingViewModel(
IRepository<GameRound> roundsRepo,
IRepository<GamePoint> pointsRepo,
IMethodSharingService<Participant> sharingService,
ICombinedRepository combined,
IObjectMessageService objectMessage,
INavigationService nav,
IPageFactory factory,
ISplashService splashService,
AppShellViewModel appShellView
) : base()
{
_roundsRepo = roundsRepo;
_pointsRepo = pointsRepo;
_sharingService = sharingService;
_combined = combined;
_objectMessage = objectMessage;
_nav = nav;
_factory = factory;
_splashService = splashService;
_appShellView = appShellView;
_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 readonly INavigationService _nav;
private readonly IPageFactory _factory;
private readonly ISplashService _splashService;
private readonly AppShellViewModel _appShellView;
private Participant _selectedItem;
private ObservableCollection<RoundBuilderElement> _roundElements;
public ObservableCollection<RoundBuilderElement> RoundElements
{
get { return _roundElements; }
set
{
_roundElements = value;
RaisePropertyChanged(nameof(RoundElements));
}
}
public Participant SelectedItem
{
get => _selectedItem;
set
{
if (_selectedItem != value)
{
_selectedItem = value;
RaisePropertyChanged(nameof(SelectedItem));
OnItemSelected(value); // Metod som triggas vid val
}
}
}
private void OnItemSelected(Participant item)
{
if (_roundElements.Count == 0)
{
var GameRound = new GameRound
{
GameRoundStartDate = DateTime.Now,
GameStatus = GamePointStatus.New,
GameRoundFinished = null
};
var gameRoundId = _roundsRepo?.Save(GameRound).GetAwaiter().GetResult();
if (gameRoundId != null && gameRoundId != -1)
{
GameRound.GameRoundId = gameRoundId.Value;
}
GameRoundObject = GameRound;
}
var GamePointStart = new GamePoint
{
ParticipantId = item.ParticipantId,
GameRoundId = GameRoundObject?.GameRoundId ?? 0,
GameDate = DateTime.Now,
GameRoundRegNr = -1,
GameRegPoints = 0
};
var gamePointId = _pointsRepo.Save(GamePointStart).GetAwaiter().GetResult();
GamePointStart.GamePointId = gamePointId;
var newElement = new RoundBuilderElement();
newElement.ParticipantId = item.ParticipantId;
newElement.ParticipantName = item.LastNameFirstName;
newElement.GameRoundRegNr = GamePointStart.GameRoundRegNr;
newElement.GameRegPoints = GamePointStart.GameRegPoints;
newElement.Status = GameRoundObject!.GameStatus;
newElement.GameRoundStartDate = GameRoundObject?.GameRoundStartDate ?? DateTime.Now;
newElement.GameRoundId = GamePointStart.GameRoundId;
newElement.GamePointId = GamePointStart.GamePointId;
_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()
{
if (_combined != null)
{
// var GameRoundSummary = _combined.roundBuilderElements();
var GameRoundSummary = _combined.roundBuilderElementsDb();
var groupedRounds = GameRoundSummary
.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,
Status = g.First().Status
}).ToList()
})
.ToList();
GameRoundList = new ObservableCollection<RoundBuilderGroup>(groupedRounds);
}
return GameRoundList;
}
public ObservableCollection<Participant> GetParticipants()
{
ParticipantList = _sharingService.Get();
return ParticipantList;
}
#endregion
#region Get(id) Method
public GameRound? Get(int id)
{
try
{
GameRoundObject = _roundsRepo?.Get(id).GetAwaiter().GetResult();
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"Error in Get method: {ex.Message}");
}
return GameRoundObject;
}
public virtual bool Save()
{
if (_roundsRepo == null || GameRoundObject == null)
{
return false;
}
var tmpTask = _roundsRepo.Save(GameRoundObject);
bool tmp = tmpTask.GetAwaiter().GetResult() != -1;
if (tmp)
{
GameRoundObject = new GameRound();
RoundElements.Clear();
this.Get();
}
return tmp;
}
public void Rensa()
{
foreach (var element in RoundElements)
{
_pointsRepo.DeleteById(element.GamePointId);
}
_roundsRepo?.DeleteById(GameRoundObject?.GameRoundId ?? 0);
RoundElements.Clear();
}
public async 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;
_objectMessage.Delivered = true;
//await _splashService.ShowSplash("Runda vald, gå till\r\r 'Påbörja eller fortsätt Runda'", 3000);
await Shell.Current.GoToAsync("RoundRunningPage");
_appShellView.RoundRunningVisible = false;
//_roundRunning.GobackVisible = false;
//var page = _factory.CreateRoundPage();
//_nav.NavigateToPageAsync(page);
}
}
public void SelectNewlyAddedParticipant(RoundBuilderElement roundBuilder)
{
Debug.WriteLine($"Du valde raden med Runda {roundBuilder.GameRoundId} och spelare: {roundBuilder.ParticipantName}");
}
#endregion
}

View File

@ -0,0 +1,103 @@
using Common.Library;
namespace GreadyPoang.ViewModelLayer;
public class SplashViewModel : ViewModelBase
{
// public event PropertyChangedEventHandler PropertyChanged;
private Color _splashBackgroundColor = Colors.DarkSlateBlue;
public Color SplashBackgroundColor
{
get => _splashBackgroundColor;
set
{
_splashBackgroundColor = value;
RaisePropertyChanged(nameof(SplashBackgroundColor));
}
}
private bool _isSplashVisible = false;
public bool IsSplashVisible
{
get => _isSplashVisible;
set
{
_isSplashVisible = value;
RaisePropertyChanged(nameof(IsSplashVisible));
}
}
private double _splashOpacity = 1.0;
public double SplashOpacity
{
get => _splashOpacity;
set
{
_splashOpacity = value;
RaisePropertyChanged(nameof(SplashOpacity));
}
}
private Color _splashTextColor = Colors.White;
public Color SplashTextColor
{
get { return _splashTextColor; }
set
{
_splashTextColor = value;
RaisePropertyChanged(nameof(SplashTextColor));
}
}
private double _splashTranslationY = 0;
public double SplashTranslationY
{
get => _splashTranslationY;
set
{
_splashTranslationY = value;
RaisePropertyChanged(nameof(SplashTranslationY));
}
}
public async Task HideSplashAsync()
{
await Task.Delay(1000); // Simulera laddning
await AnimateSplashOut();
IsSplashVisible = false;
}
private string _splashText = "Välkommen!";
public string SplashText
{
get => _splashText;
set
{
_splashText = value;
RaisePropertyChanged(nameof(SplashText));
}
}
//public Color SplashBackgroundColor { get; set; } = Colors.DarkSlateBlue;
//public string SplashImage { get; set; } = "splash_icon.png";
//protected void OnPropertyChanged(string name) =>
// PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
private async Task AnimateSplashOut()
{
for (int i = 0; i < 10; i++)
{
SplashOpacity -= 0.1;
//SplashTranslationY += 5;
await Task.Delay(30);
}
}
}

68
Gready_Poang.sln Normal file
View File

@ -0,0 +1,68 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.14.36518.9 d17.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gready_Poang", "Gready_Poang\Gready_Poang.csproj", "{B237F7D6-3B04-49AE-81B0-FEFE21A94CA7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common.Library", "Common.Library\Common.Library.csproj", "{28598B2A-3D61-4B2C-8EAE-A18583AB649D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gready_Poang.EntityLayer", "Gready_Poang.EntityLayer\Gready_Poang.EntityLayer.csproj", "{AC6F90B7-EA62-477A-A748-9459AC3CB4E6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gready_Poang.ViewModelLayer", "Gready_Poang.ViewModelLayer\Gready_Poang.ViewModelLayer.csproj", "{D58EEC8D-59E2-4C08-BE60-81EE79F87C8F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gready_Poang.DataLayer", "Gready_Poang.DataLayer\Gready_Poang.DataLayer.csproj", "{48BD841F-C383-4E0B-963E-AC2400FCC678}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gready_Poang.Migrations", "Gready_Poang.Migrations\Gready_Poang.Migrations.csproj", "{56EB8207-E108-4498-82AC-BAC8966D3D2D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gready_Poang.Services", "Gready_Poang.Services\Gready_Poang.Services.csproj", "{1C70F0EC-370D-4F48-AEDD-DB171D71EA2A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gready_Poang.Common", "Gready_Poang.Common\Gready_Poang.Common.csproj", "{BEA80096-7267-4583-8982-A8000192CB31}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B237F7D6-3B04-49AE-81B0-FEFE21A94CA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B237F7D6-3B04-49AE-81B0-FEFE21A94CA7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B237F7D6-3B04-49AE-81B0-FEFE21A94CA7}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{B237F7D6-3B04-49AE-81B0-FEFE21A94CA7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B237F7D6-3B04-49AE-81B0-FEFE21A94CA7}.Release|Any CPU.Build.0 = Release|Any CPU
{28598B2A-3D61-4B2C-8EAE-A18583AB649D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{28598B2A-3D61-4B2C-8EAE-A18583AB649D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{28598B2A-3D61-4B2C-8EAE-A18583AB649D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{28598B2A-3D61-4B2C-8EAE-A18583AB649D}.Release|Any CPU.Build.0 = Release|Any CPU
{AC6F90B7-EA62-477A-A748-9459AC3CB4E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AC6F90B7-EA62-477A-A748-9459AC3CB4E6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AC6F90B7-EA62-477A-A748-9459AC3CB4E6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AC6F90B7-EA62-477A-A748-9459AC3CB4E6}.Release|Any CPU.Build.0 = Release|Any CPU
{D58EEC8D-59E2-4C08-BE60-81EE79F87C8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D58EEC8D-59E2-4C08-BE60-81EE79F87C8F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D58EEC8D-59E2-4C08-BE60-81EE79F87C8F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D58EEC8D-59E2-4C08-BE60-81EE79F87C8F}.Release|Any CPU.Build.0 = Release|Any CPU
{48BD841F-C383-4E0B-963E-AC2400FCC678}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{48BD841F-C383-4E0B-963E-AC2400FCC678}.Debug|Any CPU.Build.0 = Debug|Any CPU
{48BD841F-C383-4E0B-963E-AC2400FCC678}.Release|Any CPU.ActiveCfg = Release|Any CPU
{48BD841F-C383-4E0B-963E-AC2400FCC678}.Release|Any CPU.Build.0 = Release|Any CPU
{56EB8207-E108-4498-82AC-BAC8966D3D2D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{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
{BEA80096-7267-4583-8982-A8000192CB31}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BEA80096-7267-4583-8982-A8000192CB31}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BEA80096-7267-4583-8982-A8000192CB31}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BEA80096-7267-4583-8982-A8000192CB31}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6D6C046F-5DA7-45E4-9DBC-715DC1067E12}
EndGlobalSection
EndGlobal

15
Gready_Poang/App.xaml Normal file
View File

@ -0,0 +1,15 @@
<?xml version = "1.0" encoding = "UTF-8" ?>
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:GreadyPoang"
x:Class="GreadyPoang.App">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
<ResourceDictionary Source="Resources/Styles/AppStyles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>

38
Gready_Poang/App.xaml.cs Normal file
View File

@ -0,0 +1,38 @@
using GreadyPoang.DataLayer.Database;
using System.Diagnostics;
namespace GreadyPoang;
public partial class App : Application
{
private readonly IServiceProvider _services;
public App(IServiceProvider services, DataContext dataContext)
{
InitializeComponent();
dataContext.Database.EnsureCreated();
_services = services;
AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
{
if (Debugger.IsAttached)
Debugger.Break();
};
TaskScheduler.UnobservedTaskException += (sender, e) =>
{
if (Debugger.IsAttached)
Debugger.Break();
};
}
protected override Window CreateWindow(IActivationState? activationState)
{
//var splashVm = ServiceLocator.Services.GetRequiredService<SplashViewModelCommands>();
//var shell = new AppShell(splashVm);
var shell = _services.GetRequiredService<AppShell>();
return new Window(shell);
}
}

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Shell
x:Class="GreadyPoang.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:vm ="clr-namespace:GreadyPoang.ViewModelLayer;assembly=GreadyPoang.ViewModelLayer"
xmlns:views="clr-namespace:GreadyPoang.Views"
xmlns:pages="clr-namespace:GreadyPoang.Pages"
xmlns:local="clr-namespace:GreadyPoang"
Title="GreadyPoang"
Shell.TitleColor="LightYellow"
x:DataType="vm:AppShellViewModel"
Shell.BackgroundColor="CadetBlue">
<TabBar>
<ShellContent
Title="Home" ContentTemplate="{DataTemplate local:MainPage}"
Route="MainPage" />
<ShellContent
Title="Deltagare" ContentTemplate="{DataTemplate pages:ParticipantListPage}"
Route="ParticipantListPage"/>
<ShellContent
Title="Ny Runda" ContentTemplate="{DataTemplate pages:RoundStartingPage}"
Route="RoundStartingPage"/>
<ShellContent
Title="Påbörja eller fortsätt Runda" ContentTemplate="{DataTemplate pages:RoundRunningPage}"
Route="RoundRunningPage" IsVisible="{Binding RoundRunningVisible}"/>
</TabBar>
</Shell>

View File

@ -0,0 +1,21 @@
using GreadyPoang.Core;
using GreadyPoang.ViewModelLayer;
namespace GreadyPoang
{
public partial class AppShell : Shell
{
private readonly IPageFactory _factory;
public AppShell(IPageFactory factory, AppShellViewModel appShellView)
{
InitializeComponent();
Routing.RegisterRoute("RoundStartingPage", typeof(Pages.RoundStartingPage));
Routing.RegisterRoute("ParticipantListPage", typeof(Pages.ParticipantListPage));
Routing.RegisterRoute("RoundRunningPage", typeof(Pages.RoundRunningPage));
_factory = factory;
BindingContext = appShellView;
}
}
}

View File

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="GreadyPoang.BasePage"
xmlns:viewsPartial="clr-namespace:GreadyPoang.ViewsPartial"
x:Name="Root">
<AbsoluteLayout>
<!-- Huvudinnehåll -->
<ContentView x:Name="MainContent"
AbsoluteLayout.LayoutBounds="0,0,1,1"
AbsoluteLayout.LayoutFlags="All" />
<!-- Overlay: Splash -->
<viewsPartial:SplashView
AbsoluteLayout.LayoutBounds="0,0,1,1"
AbsoluteLayout.LayoutFlags="All"
x:Name="SplashView"
IsVisible="True"
Opacity="1"
ZIndex="999"
TranslationY="{Binding SplashTranslationY}"
InputTransparent="True" >
</viewsPartial:SplashView>
<!--
WidthRequest="250"
HeightRequest="150"
IsVisible="{Binding IsSplashVisible}"
BackgroundColor="{Binding SplashBackgroundColor}"
x:Name="SplashView"
BackgroundColor="Black"
Opacity="{Binding SplashOpacity}"
IsVisible="True"
Opacity="0.9"
ZIndex="999"
BackgroundColor="Black" />-->
</AbsoluteLayout>
</ContentPage>

View File

@ -0,0 +1,13 @@
using GreadyPoang.CommandClasses;
namespace GreadyPoang;
public partial class BasePage : ContentPage
{
public BasePage(View content, SplashViewModelCommands splashVm)
{
InitializeComponent();
MainContent.Content = content;
SplashView.BindingContext = splashVm;
}
}

View File

@ -0,0 +1,11 @@
using GreadyPoang.ViewModelLayer;
namespace GreadyPoang.CommandClasses;
public class AppShellViewModelCommands : AppShellViewModel
{
public AppShellViewModelCommands() : base()
{
}
}

View File

@ -0,0 +1,15 @@
using GreadyPoang.Services;
using GreadyPoang.ViewModelLayer;
namespace GreadyPoang.CommandClasses;
public class MainPageViewModelCommands : MainPageViewModel
{
public MainPageViewModelCommands(
AppShellViewModel appShell,
IObjectMessageService messageService
) : base(appShell, messageService)
{
}
}

View File

@ -0,0 +1,72 @@
using Common.Library;
using GreadyPoang.EntityLayer;
using GreadyPoang.Services;
using GreadyPoang.ViewModelLayer;
using System.Windows.Input;
namespace GreadyPoang.CommandClasses;
public class ParticipantViewModelCommands : ParticipantViewModel
{
#region constructors
public ParticipantViewModelCommands() : base()
{
}
public ParticipantViewModelCommands(
IRepository<Participant> repo,
IMethodSharingService<Participant> sharingService,
AppShellViewModel appShell,
IObjectMessageService objectMessage) : base(repo, sharingService, appShell, objectMessage)
{
}
#endregion
#region Private Variables
private bool _IsSaveCommandEnabled = true;
#endregion
#region Public Properties
public bool IsSaveCommandEnabled
{
get { return _IsSaveCommandEnabled; }
set
{
_IsSaveCommandEnabled = value;
RaisePropertyChanged(nameof(IsSaveCommandEnabled));
}
}
#endregion
#region Commands
public ICommand SaveCommand { get; private set; }
public ICommand EditCommand { get; private set; }
#endregion
#region Init Method
public override void Init()
{
base.Init();
SaveCommand = new Command(async () => SaveAsync(), () => IsSaveCommandEnabled);
EditCommand = new Command<int>(async (id) => await EditAsync(id), (id) => id > 0);
}
#endregion
protected async Task EditAsync(int id)
{
await Shell.Current.GoToAsync($"{nameof(Views.ParticipantListView)}?id={id}");
}
public async Task<bool> SaveAsync()
{
var ret = base.Save();
if (ret)
{
await Shell.Current.GoToAsync("..");
}
return ret;
}
}

View File

@ -0,0 +1,67 @@
using Common.Library;
using GreadyPoang.Core;
using GreadyPoang.DataLayer;
using GreadyPoang.EntityLayer;
using GreadyPoang.Services;
using GreadyPoang.ViewModelLayer;
using System.Windows.Input;
namespace GreadyPoang.CommandClasses;
public class RoundRunningViewModelCommands : RoundRunningViewModel
{
public RoundRunningViewModelCommands() : base()
{
}
public RoundRunningViewModelCommands(
IRepository<GameRound> roundsRepo,
IRepository<GamePoint> pointsRepo,
IMethodSharingService<Participant> sharingService,
ICombinedRepository combined,
IObjectMessageService objectMessage,
ISplashService splashService,
AppShellViewModel appShell)
: base(roundsRepo,
pointsRepo,
sharingService,
combined,
objectMessage,
splashService,
appShell)
{
}
#region Commands
public ICommand GobackCommand { get; private set; }
public ICommand StoreAndHandlePointsCommand { get; private set; }
public ICommand OnSplashClickedCommand { get; private set; }
#endregion
public override void Init()
{
base.Init();
StoreAndHandlePointsCommand = new Command(async () => StoreAndHandleAsync());
OnSplashClickedCommand = new Command(async () => await ToggleSplash());
GobackCommand = new Command(async () => GobackAsync());
}
private async void GobackAsync()
{
base.GobackAsync();
await Shell.Current.GoToAsync("..");
}
private async Task StoreAndHandleAsync()
{
base.StoreAndHandlePoints();
//await Shell.Current.GoToAsync("..");
// await Shell.Current.GoToAsync("RoundRunningPage");
}
private async Task ToggleSplash()
{
base.ToggleSplash();
}
}

View File

@ -0,0 +1,115 @@
using Common.Library;
using GreadyPoang.Core;
using GreadyPoang.DataLayer;
using GreadyPoang.EntityLayer;
using GreadyPoang.Services;
using GreadyPoang.ViewModelLayer;
using System.Windows.Input;
namespace GreadyPoang.CommandClasses;
public class RoundStartingViewModelCommands : RoundStartingViewModel
{
public RoundStartingViewModelCommands() : base()
{
}
public RoundStartingViewModelCommands(
IRepository<GameRound> roundsRepo,
IRepository<GamePoint> pointsRepo,
IMethodSharingService<Participant> sharingService,
ICombinedRepository combined,
IObjectMessageService objectMessage,
INavigationService nav,
IPageFactory factory,
ISplashService splashService,
AppShellViewModel appShell)
: base(roundsRepo,
pointsRepo,
sharingService,
combined,
objectMessage,
nav,
factory,
splashService,
appShell)
{
}
#region Private Variables
private bool _IsSaveCommandEnabled = true;
#endregion
#region Public Properties
public bool IsSaveCommandEnabled
{
get { return _IsSaveCommandEnabled; }
set
{
_IsSaveCommandEnabled = value;
RaisePropertyChanged(nameof(IsSaveCommandEnabled));
}
}
#endregion
#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
#region Init Method
public override void 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());
ParticipantTappedCommand = new Command<RoundBuilderElement>(async (selectedParticipant) => SelectNewlyAddedParticipant(selectedParticipant));
ElementTappedCommand = new Command<RoundBuilderElement>((selectedElement) => RoundSelected(selectedElement));
}
private async Task RensaAsync()
{
base.Rensa();
await Shell.Current.GoToAsync("..");
}
#endregion
protected async Task EditAsync(int id)
{
await Shell.Current.GoToAsync($"{nameof(Views.RoundStartingView)}?id={id}");
}
public async Task<bool> SaveAsync()
{
var ret = base.Save();
if (ret)
{
await Shell.Current.GoToAsync("..");
}
return ret;
}
public async Task<bool> RoundSelected(RoundBuilderElement element)
{
bool goneOk = false;
base.RoundSelected(element);
goneOk = true;
return goneOk;
}
public async Task<bool> SelectNewlyAddedParticipant(RoundBuilderElement roundBuilder)
{
bool goneOk = false;
base.SelectNewlyAddedParticipant(roundBuilder);
goneOk = true;
return goneOk;
}
}

View File

@ -0,0 +1,10 @@
using GreadyPoang.ViewModelLayer;
namespace GreadyPoang.CommandClasses;
public class SplashViewModelCommands : SplashViewModel
{
public SplashViewModelCommands() : base()
{
}
}

View File

@ -0,0 +1,11 @@
namespace GreadyPoang.Core;
public class NavigationService : INavigationService
{
public Task NavigateToAsync(string route)
=> Shell.Current.GoToAsync(route);
public Task NavigateToPageAsync(Page page)
=> Shell.Current.Navigation.PushAsync(page);
}

View File

@ -0,0 +1,30 @@
using GreadyPoang.CommandClasses;
using GreadyPoang.Core;
using GreadyPoang.Pages;
namespace GreadyPoang;
public class PageFactory : IPageFactory
{
private readonly IServiceProvider _services;
public PageFactory(IServiceProvider services)
{
_services = services;
}
public Page CreateRoundPage()
{
var vm = _services.GetRequiredService<RoundRunningViewModelCommands>();
var splashVm = _services.GetRequiredService<SplashViewModelCommands>();
return new RoundRunningPage(vm, splashVm);
}
//public Page CreateStatsPage()
//{
// //var vm = _services.GetRequiredService<StatsViewModel>();
// //var splashVm = _services.GetRequiredService<SplashViewModelCommands>();
// //var view = new StatsView { BindingContext = vm };
// //return new StatsPage(view, splashVm);
//}
}

View File

@ -0,0 +1,10 @@
using GreadyPoang.InterFaces;
namespace GreadyPoang;
public class ServiceLocator : IServiceLocator
{
public static IServiceProvider? Services { get; set; } = default;
public T Get<T>() => (T)Services!.GetService(typeof(T))!;
}

View File

@ -0,0 +1,111 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net9.0-android;net9.0-ios;net9.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net9.0-windows10.0.19041.0</TargetFrameworks>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net9.0-tizen</TargetFrameworks> -->
<!-- Note for MacCatalyst:
The default runtime is maccatalyst-x64, except in Release config, in which case the default is maccatalyst-x64;maccatalyst-arm64.
When specifying both architectures, use the plural <RuntimeIdentifiers> instead of the singular <RuntimeIdentifier>.
The Mac App Store will NOT accept apps with ONLY maccatalyst-arm64 indicated;
either BOTH runtimes must be indicated or ONLY macatalyst-x64. -->
<!-- For example: <RuntimeIdentifiers>maccatalyst-x64;maccatalyst-arm64</RuntimeIdentifiers> -->
<OutputType>Exe</OutputType>
<RootNamespace>Gready_Poang</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<!-- Display name -->
<ApplicationTitle>Gready_Poang</ApplicationTitle>
<!-- App Identifier -->
<ApplicationId>com.companyname.Gready_Poang</ApplicationId>
<!-- Versions -->
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>
<!-- To develop, package, and publish an app to the Microsoft Store, see: https://aka.ms/MauiTemplateUnpackaged -->
<WindowsPackageType>None</WindowsPackageType>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">15.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">15.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
</PropertyGroup>
<ItemGroup>
<!-- App Icon -->
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />
<!-- Splash Screen -->
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />
<!-- Images -->
<MauiImage Include="Resources\Images\*" />
<MauiImage Update="Resources\Images\dotnet_bot.png" Resize="True" BaseSize="300,185" />
<!-- Custom Fonts -->
<MauiFont Include="Resources\Fonts\*" />
<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>
<ItemGroup>
<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" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Common.Library\Common.Library.csproj" />
<ProjectReference Include="..\Gready_Poang.Common\Gready_Poang.Common.csproj" />
<ProjectReference Include="..\Gready_Poang.DataLayer\Gready_Poang.DataLayer.csproj" />
<ProjectReference Include="..\Gready_Poang.EntityLayer\Gready_Poang.EntityLayer.csproj" />
<!--<ProjectReference Include="..\Gready_Poang.Services\Gready_Poang.Services.csproj" />-->
<ProjectReference Include="..\Gready_Poang.ViewModelLayer\Gready_Poang.ViewModelLayer.csproj" />
</ItemGroup>
<ItemGroup>
<Compile Update="Views\ParticipantListView.xaml.cs">
<DependentUpon>ParticipantListView.xaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<MauiXaml Update="BasePage.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Resources\Styles\AppStyles.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="ViewsPartial\HeaderView.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\ParticipantListView.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\RoundRunningView.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\RoundStartingView.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="ViewsPartial\SplashView.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
</ItemGroup>
<ItemGroup>
<Folder Include="ViewHelpers\" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GreadyPoang.InterFaces;
public interface IServiceLocator
{
T Get<T>();
}

View File

@ -0,0 +1,34 @@
using GreadyPoang.CommandClasses;
using GreadyPoang.Core;
namespace GreadyPoang.LocalServices;
public class SplashService : ISplashService
{
private readonly SplashViewModelCommands _viewModel;
public SplashService(SplashViewModelCommands viewModel)
{
_viewModel = viewModel;
}
public async Task ShowSplash(string text = "Välkommen!", int durationMs = 3000)
{
_viewModel.SplashText = text;
_viewModel.SplashOpacity = 0.8;
_viewModel.SplashBackgroundColor = Colors.DodgerBlue;
_viewModel.IsSplashVisible = true;
//await Task.Yield(); // ger UI-tråden en chans att uppdatera
if (durationMs > 0)
{
await Task.Delay(durationMs);
_viewModel.IsSplashVisible = false;
}
}
public async Task HideAsync()
{
//_viewModel.IsSplashVisible = false;
await _viewModel.HideSplashAsync();
}
}

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:partial="clr-namespace:GreadyPoang.ViewsPartial"
x:Class="GreadyPoang.MainPage"
xmlns:vm ="clr-namespace:GreadyPoang.CommandClasses"
x:DataType="vm:MainPageViewModelCommands"
Background="LightCyan"
Title="{StaticResource ApplicationTitle}">
<Grid Style="{StaticResource Grid.Page}">
<partial:HeaderView Grid.Row="0"
Grid.ColumnSpan="2"
ViewTitle="{StaticResource ApplicationTitle}"
ViewDescription="Välkommen till Gready">
</partial:HeaderView>
<Image
Source="snurrtarning.gif"
IsAnimationPlaying="True"
HorizontalOptions="Center"
VerticalOptions="Center"
Aspect="AspectFit"
Grid.Row="1"
Grid.Column="0"
HeightRequest="250"
Margin="10"/>
</Grid>
</ContentPage>

View File

@ -0,0 +1,23 @@
using GreadyPoang.CommandClasses;
namespace GreadyPoang;
public partial class MainPage : ContentPage
{
private readonly MainPageViewModelCommands _mainPage;
public MainPage(
MainPageViewModelCommands mainPage)
{
InitializeComponent();
BindingContext = mainPage;
_mainPage = mainPage;
}
protected override void OnAppearing()
{
base.OnAppearing();
_mainPage.InitMessage();
}
}

View File

@ -0,0 +1,81 @@
using Common.Library;
using GreadyPoang.CommandClasses;
using GreadyPoang.Core;
using GreadyPoang.DataLayer;
using GreadyPoang.DataLayer.Database;
using GreadyPoang.EntityLayer;
using GreadyPoang.InterFaces;
using GreadyPoang.LocalServices;
using GreadyPoang.Services;
using GreadyPoang.ViewModelLayer;
using GreadyPoang.Views;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
namespace GreadyPoang;
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
});
builder.Services.AddDbContext<DataContext>(options =>
{
var MauiDataPath = FileSystem.Current.AppDataDirectory;
if (!File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "MauiDataPath_GreadyPoang.txt"))) ;
{
File.WriteAllText(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "MauiDataPath_GreadyPoang.txt"), MauiDataPath);
}
var dbPath = Path.Combine(MauiDataPath, "PoangDB.db");
options.UseSqlite($"Data Source={dbPath}");
});
builder.Services.AddScoped<IPageFactory, PageFactory>();
builder.Services.AddSingleton<INavigationService, NavigationService>();
builder.Services.AddSingleton<IServiceLocator, ServiceLocator>();
builder.Services.AddScoped<IRepository<Participant>, ParticipantRepository>();
builder.Services.AddScoped<ParticipantViewModelCommands>();
builder.Services.AddScoped<ParticipantListView>();
builder.Services.AddScoped<IRepository<GameRound>, GameRoundRepository>();
builder.Services.AddScoped<RoundStartingViewModelCommands>();
builder.Services.AddScoped<RoundStartingView>();
builder.Services.AddScoped<IRepository<GamePoint>, GamePointRepository>();
builder.Services.AddScoped<RoundRunningViewModelCommands>();
builder.Services.AddScoped<RoundRunningView>();
builder.Services.AddScoped<IMethodSharingService<Participant>, MethodSharingService>();
builder.Services.AddScoped<ICombinedRepository, CombinedRepository>();
builder.Services.AddSingleton<IObjectMessageService, ObjectMessageService>();
builder.Services.AddSingleton<AppShellViewModel>();
builder.Services.AddSingleton<AppShell>();
builder.Services.AddSingleton<SplashViewModelCommands>();
builder.Services.AddSingleton<ISplashService, SplashService>();
builder.Services.AddSingleton<MainPageViewModelCommands>();
#if DEBUG
builder.Logging.AddDebug();
#endif
var app = builder.Build();
ServiceLocator.Services = app.Services;
return app;
}
}

View File

@ -0,0 +1,24 @@
using GreadyPoang.CommandClasses;
using GreadyPoang.Views;
namespace GreadyPoang.Pages;
public class ParticipantListPage : BasePage
{
private readonly ParticipantViewModelCommands _vm;
public ParticipantListPage(ParticipantViewModelCommands vm, SplashViewModelCommands splashVm)
: base(new ParticipantListView(vm), splashVm)
{
Title = "Deltagar Lista";
_vm = vm;
}
protected override void OnAppearing()
{
base.OnAppearing();
BindingContext = _vm;
_vm.Get();
}
}

View File

@ -0,0 +1,43 @@
using GreadyPoang.CommandClasses;
using GreadyPoang.Core;
using GreadyPoang.Views;
namespace GreadyPoang.Pages;
public class RoundRunningPage : BasePage
{
private readonly RoundRunningViewModelCommands _vm;
private readonly SplashViewModelCommands _splashVm;
public ISplashService Splash { get; set; }
public RoundRunningPage(RoundRunningViewModelCommands Vm, SplashViewModelCommands splashVm)
: base(new RoundRunningView(Vm), splashVm)
{
Title = "Starta/Fortsätt runda";
_vm = Vm;
Splash = ServiceLocator.Services?.GetRequiredService<ISplashService>();
_splashVm = splashVm;
}
public SplashViewModelCommands SplashVm { get; }
protected override async void OnAppearing()
{
base.OnAppearing();
BindingContext = _vm;
_vm.Get();
//BuildScoreGrid(ViewModel.PlayerColumns); // <-- här bygger du layouten
//// _vm.RebuildRequested += ViewModel_RebuildRequested;
if (_splashVm != null)
{
await Splash.ShowSplash("Nu kan du spela vidare", 3000);
//await Splash.ShowSplash("Nu kan du spela vidare", 3000).GetAwaiter().GetResult();
}
//_splashVm.ShowSplash("Nu kan du spela vidare").GetAwaiter().GetResult(); ;
}
}

View File

@ -0,0 +1,25 @@
using GreadyPoang.CommandClasses;
using GreadyPoang.Views;
namespace GreadyPoang.Pages;
public class RoundStartingPage : BasePage
{
private readonly RoundStartingViewModelCommands _vm;
public RoundStartingPage(RoundStartingViewModelCommands vm, SplashViewModelCommands splashVm)
: base(new RoundStartingView(vm), splashVm)
{
Title = "Starta ny Runda";
_vm = vm;
}
protected override void OnAppearing()
{
base.OnAppearing();
BindingContext = _vm;
_vm.Get();
_vm.GetParticipants();
}
}

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.idoit4u.Gready_Poang" android:versionCode="1" android:versionName="conqueror" android:installLocation="auto">
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:supportsRtl="true" android:label="Gready_Poang"></application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
</manifest>

View File

@ -0,0 +1,11 @@
using Android.App;
using Android.Content.PM;
using Android.OS;
namespace GreadyPoang
{
[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, LaunchMode = LaunchMode.SingleTop, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
public class MainActivity : MauiAppCompatActivity
{
}
}

View File

@ -0,0 +1,16 @@
using Android.App;
using Android.Runtime;
namespace GreadyPoang
{
[Application]
public class MainApplication : MauiApplication
{
public MainApplication(IntPtr handle, JniHandleOwnership ownership)
: base(handle, ownership)
{
}
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}
}

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#512BD4</color>
<color name="colorPrimaryDark">#2B0B98</color>
<color name="colorAccent">#2B0B98</color>
</resources>

View File

@ -0,0 +1,10 @@
using Foundation;
namespace GreadyPoang
{
[Register("AppDelegate")]
public class AppDelegate : MauiUIApplicationDelegate
{
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}
}

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<!-- See https://aka.ms/maui-publish-app-store#add-entitlements for more information about adding entitlements.-->
<dict>
<!-- App Sandbox must be enabled to distribute a MacCatalyst app through the Mac App Store. -->
<key>com.apple.security.app-sandbox</key>
<true/>
<!-- When App Sandbox is enabled, this value is required to open outgoing network connections. -->
<key>com.apple.security.network.client</key>
<true/>
</dict>
</plist>

View File

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<!-- The Mac App Store requires you specify if the app uses encryption. -->
<!-- Please consult https://developer.apple.com/documentation/bundleresources/information_property_list/itsappusesnonexemptencryption -->
<!-- <key>ITSAppUsesNonExemptEncryption</key> -->
<!-- Please indicate <true/> or <false/> here. -->
<!-- Specify the category for your app here. -->
<!-- Please consult https://developer.apple.com/documentation/bundleresources/information_property_list/lsapplicationcategorytype -->
<!-- <key>LSApplicationCategoryType</key> -->
<!-- <string>public.app-category.YOUR-CATEGORY-HERE</string> -->
<key>UIDeviceFamily</key>
<array>
<integer>2</integer>
</array>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>arm64</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>XSAppIconAssets</key>
<string>Assets.xcassets/appicon.appiconset</string>
</dict>
</plist>

View File

@ -0,0 +1,16 @@
using ObjCRuntime;
using UIKit;
namespace GreadyPoang
{
public class Program
{
// This is the main entry point of the application.
static void Main(string[] args)
{
// if you want to use a different Application Delegate class from "AppDelegate"
// you can specify it here.
UIApplication.Main(args, null, typeof(AppDelegate));
}
}
}

Some files were not shown because too many files have changed in this diff Show More