commit 5d1e7858f245ae45b9ccc54a14431ede8fecc5fb Author: Tommy Öman Date: Sat Oct 11 08:15:33 2025 +0200 Add project files. diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -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 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9491a2f --- /dev/null +++ b/.gitignore @@ -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 \ No newline at end of file diff --git a/Common.Library/BaseClasses/CommonBase.cs b/Common.Library/BaseClasses/CommonBase.cs new file mode 100644 index 0000000..be93963 --- /dev/null +++ b/Common.Library/BaseClasses/CommonBase.cs @@ -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 +} diff --git a/Common.Library/BaseClasses/EntityBase.cs b/Common.Library/BaseClasses/EntityBase.cs new file mode 100644 index 0000000..c9de9fe --- /dev/null +++ b/Common.Library/BaseClasses/EntityBase.cs @@ -0,0 +1,5 @@ +namespace Common.Library; + +public class EntityBase : CommonBase +{ +} diff --git a/Common.Library/BaseClasses/ViewModelBase.cs b/Common.Library/BaseClasses/ViewModelBase.cs new file mode 100644 index 0000000..e33b2e7 --- /dev/null +++ b/Common.Library/BaseClasses/ViewModelBase.cs @@ -0,0 +1,14 @@ +//using GreadyPoang.DataLayer; + +namespace Common.Library; +public class ViewModelBase : CommonBase +{ + //private readonly LocalDbService _dbService; + + //public ViewModelBase(LocalDbService dbService) + //{ + // _dbService = dbService; + //} + +} + diff --git a/Common.Library/Common.Library.csproj b/Common.Library/Common.Library.csproj new file mode 100644 index 0000000..6405f4a --- /dev/null +++ b/Common.Library/Common.Library.csproj @@ -0,0 +1,15 @@ + + + + + net9.0-android; + net9.0-ios; + net9.0-maccatalyst; + net9.0-windows10.0.19041 + + enable + enable + + + + diff --git a/Common.Library/Interfaces/IMethodSharingService.cs b/Common.Library/Interfaces/IMethodSharingService.cs new file mode 100644 index 0000000..3b8c11d --- /dev/null +++ b/Common.Library/Interfaces/IMethodSharingService.cs @@ -0,0 +1,9 @@ +using System.Collections.ObjectModel; + +namespace Common.Library +{ + public interface IMethodSharingService + { + ObservableCollection Get(); + } +} diff --git a/Common.Library/Interfaces/IRepository.cs b/Common.Library/Interfaces/IRepository.cs new file mode 100644 index 0000000..9f2cf62 --- /dev/null +++ b/Common.Library/Interfaces/IRepository.cs @@ -0,0 +1,10 @@ +namespace Common.Library; + +public interface IRepository +{ + Task> Get(); + Task Get(int id); + Task Save(TEntity entity); + bool Delete(TEntity entity); + Task DeleteById(int Id); +} diff --git a/Example.cs b/Example.cs new file mode 100644 index 0000000..e69de29 diff --git a/Gready_Poang.CommandClasses/Gready_Poang.CommandClasses.csproj b/Gready_Poang.CommandClasses/Gready_Poang.CommandClasses.csproj new file mode 100644 index 0000000..8ee39e7 --- /dev/null +++ b/Gready_Poang.CommandClasses/Gready_Poang.CommandClasses.csproj @@ -0,0 +1,15 @@ + + + + net9.0 + enable + enable + + + + + + + + + diff --git a/Gready_Poang.Common/Base/BehaviorBase.cs b/Gready_Poang.Common/Base/BehaviorBase.cs new file mode 100644 index 0000000..f175645 --- /dev/null +++ b/Gready_Poang.Common/Base/BehaviorBase.cs @@ -0,0 +1,30 @@ +namespace GreadyPoang.Common; + +public class BehaviorBase : Behavior 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; + } +} diff --git a/Gready_Poang.Common/Gready_Poang.Common.csproj b/Gready_Poang.Common/Gready_Poang.Common.csproj new file mode 100644 index 0000000..4938e43 --- /dev/null +++ b/Gready_Poang.Common/Gready_Poang.Common.csproj @@ -0,0 +1,19 @@ + + + + + net9.0-android; + net9.0-ios; + net9.0-maccatalyst; + net9.0-windows10.0.19041 + + enable + enable + + + + + + + + diff --git a/Gready_Poang.Common/Specifics/DigitsOnlyBehavior.cs b/Gready_Poang.Common/Specifics/DigitsOnlyBehavior.cs new file mode 100644 index 0000000..4c1f2f7 --- /dev/null +++ b/Gready_Poang.Common/Specifics/DigitsOnlyBehavior.cs @@ -0,0 +1,44 @@ +using System.Text.RegularExpressions; + +namespace GreadyPoang.Common; + +public class DigitsOnlyBehavior : Behavior +{ + 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 (0–9) + 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. + * + */ + + } +} diff --git a/Gready_Poang.Common/Specifics/EventToCommandBehavior.cs b/Gready_Poang.Common/Specifics/EventToCommandBehavior.cs new file mode 100644 index 0000000..bc6c35b --- /dev/null +++ b/Gready_Poang.Common/Specifics/EventToCommandBehavior.cs @@ -0,0 +1,59 @@ +using System.Reflection; +using System.Windows.Input; + +namespace GreadyPoang.Common; +public class EventToCommandBehavior : BehaviorBase +{ + 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); + } +} diff --git a/Gready_Poang.DataLayer/DataClasses/CombinedRepository.cs b/Gready_Poang.DataLayer/DataClasses/CombinedRepository.cs new file mode 100644 index 0000000..46860b7 --- /dev/null +++ b/Gready_Poang.DataLayer/DataClasses/CombinedRepository.cs @@ -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 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 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 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 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 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; + } + + +} diff --git a/Gready_Poang.DataLayer/DataClasses/GamePointRepository.cs b/Gready_Poang.DataLayer/DataClasses/GamePointRepository.cs new file mode 100644 index 0000000..f71a129 --- /dev/null +++ b/Gready_Poang.DataLayer/DataClasses/GamePointRepository.cs @@ -0,0 +1,83 @@ +using Common.Library; +using GreadyPoang.DataLayer.Database; +using GreadyPoang.EntityLayer; +using Microsoft.EntityFrameworkCore; + +namespace GreadyPoang.DataLayer; + +public class GamePointRepository : IRepository +{ + private readonly DataContext _dataContext; + + public GamePointRepository(DataContext dataContext) + { + _dataContext = dataContext; + } + public async Task> Get() + { + return await _dataContext.GamePoints.ToListAsync(); + } + public async Task Get(int id) + { + return await _dataContext.GamePoints.FindAsync(id); + } + public async Task 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 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; + } +} diff --git a/Gready_Poang.DataLayer/DataClasses/GameRoundRepository.cs b/Gready_Poang.DataLayer/DataClasses/GameRoundRepository.cs new file mode 100644 index 0000000..392e467 --- /dev/null +++ b/Gready_Poang.DataLayer/DataClasses/GameRoundRepository.cs @@ -0,0 +1,81 @@ +using Common.Library; +using GreadyPoang.DataLayer.Database; +using GreadyPoang.EntityLayer; +using Microsoft.EntityFrameworkCore; + +namespace GreadyPoang.DataLayer; + +public class GameRoundRepository : IRepository +{ + 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> Get() + { + return await _dataContext.GameRounds.ToListAsync(); + } + + public async Task Get(int id) + { + return await _dataContext.GameRounds.FindAsync(id); + } + + public async Task 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 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; + } + +} diff --git a/Gready_Poang.DataLayer/DataClasses/LocalDbService.cs b/Gready_Poang.DataLayer/DataClasses/LocalDbService.cs new file mode 100644 index 0000000..ba17d5a --- /dev/null +++ b/Gready_Poang.DataLayer/DataClasses/LocalDbService.cs @@ -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().Wait(); + } + + public async Task> GetParticipantsAsync() + { + return await _connection.Table().ToListAsync(); + } + + public async Task GetParticipantAsync(int id) + { + return await _connection.Table().Where(p => p.ParticipantId == id).FirstOrDefaultAsync(); + } + + public async Task SaveParticipantAsync(Participant participant) + { + if (participant.ParticipantId != 0) + { + return await _connection.UpdateAsync(participant); + } + else + { + return await _connection.InsertAsync(participant); + } + } + + public async Task DeleteParticipantAsync(Participant participant) + { + return await _connection.DeleteAsync(participant); + } + +} diff --git a/Gready_Poang.DataLayer/DataClasses/ParticipantRepository.cs b/Gready_Poang.DataLayer/DataClasses/ParticipantRepository.cs new file mode 100644 index 0000000..af72206 --- /dev/null +++ b/Gready_Poang.DataLayer/DataClasses/ParticipantRepository.cs @@ -0,0 +1,84 @@ +using Common.Library; +using GreadyPoang.DataLayer.Database; +using GreadyPoang.EntityLayer; +using Microsoft.EntityFrameworkCore; + +namespace GreadyPoang.DataLayer; + +public class ParticipantRepository : IRepository +{ + private readonly DataContext _dataContext; + + public ParticipantRepository(DataContext dataContext) + { + _dataContext = dataContext; + } + public async Task> Get() + { + return await _dataContext.Participants.ToListAsync(); + } + public async Task Get(int id) + { + // Fix: Use FindAsync with key value array, not a predicate + return await _dataContext.Participants.FindAsync(id); + } + public async Task 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 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; + } +} diff --git a/Gready_Poang.DataLayer/Database/DataContext.cs b/Gready_Poang.DataLayer/Database/DataContext.cs new file mode 100644 index 0000000..f602108 --- /dev/null +++ b/Gready_Poang.DataLayer/Database/DataContext.cs @@ -0,0 +1,41 @@ +using GreadyPoang.EntityLayer; +using Microsoft.EntityFrameworkCore; + +namespace GreadyPoang.DataLayer.Database; + +public class DataContext : DbContext +{ + public DataContext(DbContextOptions options) : base(options) + { + + } + //public DbSet Users => Set(); + public DbSet Participants { get; set; } + public DbSet GamePoints { get; set; } + public DbSet GameRounds { get; set; } + + public DbSet RoundBuilderElements { get; set; } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); + modelBuilder.Entity().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().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().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().HasNoKey(); + } +} + diff --git a/Gready_Poang.DataLayer/Gready_Poang.DataLayer.csproj b/Gready_Poang.DataLayer/Gready_Poang.DataLayer.csproj new file mode 100644 index 0000000..2c5a07a --- /dev/null +++ b/Gready_Poang.DataLayer/Gready_Poang.DataLayer.csproj @@ -0,0 +1,34 @@ + + + + + net9.0-android; + net9.0-ios; + net9.0-maccatalyst; + net9.0-windows10.0.19041 + + enable + enable + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + diff --git a/Gready_Poang.DataLayer/LocalInterfaces/ICombinedRepository.cs b/Gready_Poang.DataLayer/LocalInterfaces/ICombinedRepository.cs new file mode 100644 index 0000000..fe7d614 --- /dev/null +++ b/Gready_Poang.DataLayer/LocalInterfaces/ICombinedRepository.cs @@ -0,0 +1,13 @@ + +using GreadyPoang.EntityLayer; + +namespace GreadyPoang.DataLayer; + +public interface ICombinedRepository +{ + IEnumerable roundBuilderElements(); + IEnumerable roundBuilderElementsDb(); + IEnumerable roundBuilderElementsDbById(int GameId); + IEnumerable roundBuilderElementsTotal(); + IEnumerable roundBuilderElementsTotalById(int roundId); +} \ No newline at end of file diff --git a/Gready_Poang.DataLayer/Migrations/20250901152226_initialCreate.Designer.cs b/Gready_Poang.DataLayer/Migrations/20250901152226_initialCreate.Designer.cs new file mode 100644 index 0000000..680fd3a --- /dev/null +++ b/Gready_Poang.DataLayer/Migrations/20250901152226_initialCreate.Designer.cs @@ -0,0 +1,70 @@ +// +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 + { + /// + 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("ParticipantId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Email") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("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 + } + } +} diff --git a/Gready_Poang.DataLayer/Migrations/20250901152226_initialCreate.cs b/Gready_Poang.DataLayer/Migrations/20250901152226_initialCreate.cs new file mode 100644 index 0000000..72e7638 --- /dev/null +++ b/Gready_Poang.DataLayer/Migrations/20250901152226_initialCreate.cs @@ -0,0 +1,48 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional + +namespace GreadyPoang.DataLayer.Migrations +{ + /// + public partial class initialCreate : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Participants", + columns: table => new + { + ParticipantId = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + FirstName = table.Column(type: "TEXT", nullable: false), + LastName = table.Column(type: "TEXT", nullable: false), + Email = table.Column(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" } + }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Participants"); + } + } +} diff --git a/Gready_Poang.DataLayer/Migrations/20250902115700_GamePointsTable.Designer.cs b/Gready_Poang.DataLayer/Migrations/20250902115700_GamePointsTable.Designer.cs new file mode 100644 index 0000000..05d8650 --- /dev/null +++ b/Gready_Poang.DataLayer/Migrations/20250902115700_GamePointsTable.Designer.cs @@ -0,0 +1,135 @@ +// +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 + { + /// + 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("GamePointId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("GameDate") + .HasColumnType("TEXT"); + + b.Property("GameHeatId") + .HasColumnType("INTEGER"); + + b.Property("GameHeatRegNr") + .HasColumnType("INTEGER"); + + b.Property("GameRegPoints") + .HasColumnType("INTEGER"); + + b.Property("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("ParticipantId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Email") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("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 + } + } +} diff --git a/Gready_Poang.DataLayer/Migrations/20250902115700_GamePointsTable.cs b/Gready_Poang.DataLayer/Migrations/20250902115700_GamePointsTable.cs new file mode 100644 index 0000000..e5f346f --- /dev/null +++ b/Gready_Poang.DataLayer/Migrations/20250902115700_GamePointsTable.cs @@ -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 +{ + /// + public partial class GamePointsTable : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "GamePoints", + columns: table => new + { + GamePointId = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + ParticipantId = table.Column(type: "INTEGER", nullable: false), + GameHeatId = table.Column(type: "INTEGER", nullable: false), + GameDate = table.Column(type: "TEXT", nullable: false), + GameHeatRegNr = table.Column(type: "INTEGER", nullable: false), + GameRegPoints = table.Column(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 } + }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "GamePoints"); + } + } +} diff --git a/Gready_Poang.DataLayer/Migrations/20250902120934_GamePointsTableStaticSeed.Designer.cs b/Gready_Poang.DataLayer/Migrations/20250902120934_GamePointsTableStaticSeed.Designer.cs new file mode 100644 index 0000000..2436097 --- /dev/null +++ b/Gready_Poang.DataLayer/Migrations/20250902120934_GamePointsTableStaticSeed.Designer.cs @@ -0,0 +1,135 @@ +// +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 + { + /// + 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("GamePointId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("GameDate") + .HasColumnType("TEXT"); + + b.Property("GameHeatId") + .HasColumnType("INTEGER"); + + b.Property("GameHeatRegNr") + .HasColumnType("INTEGER"); + + b.Property("GameRegPoints") + .HasColumnType("INTEGER"); + + b.Property("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("ParticipantId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Email") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("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 + } + } +} diff --git a/Gready_Poang.DataLayer/Migrations/20250902120934_GamePointsTableStaticSeed.cs b/Gready_Poang.DataLayer/Migrations/20250902120934_GamePointsTableStaticSeed.cs new file mode 100644 index 0000000..133961e --- /dev/null +++ b/Gready_Poang.DataLayer/Migrations/20250902120934_GamePointsTableStaticSeed.cs @@ -0,0 +1,75 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace GreadyPoang.DataLayer.Migrations +{ + /// + public partial class GamePointsTableStaticSeed : Migration + { + /// + 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)); + } + + /// + 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)); + } + } +} diff --git a/Gready_Poang.DataLayer/Migrations/20250902122130_FixDateTimeSeed.Designer.cs b/Gready_Poang.DataLayer/Migrations/20250902122130_FixDateTimeSeed.Designer.cs new file mode 100644 index 0000000..046bce8 --- /dev/null +++ b/Gready_Poang.DataLayer/Migrations/20250902122130_FixDateTimeSeed.Designer.cs @@ -0,0 +1,135 @@ +// +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 + { + /// + 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("GamePointId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("GameDate") + .HasColumnType("TEXT"); + + b.Property("GameHeatId") + .HasColumnType("INTEGER"); + + b.Property("GameHeatRegNr") + .HasColumnType("INTEGER"); + + b.Property("GameRegPoints") + .HasColumnType("INTEGER"); + + b.Property("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("ParticipantId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Email") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("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 + } + } +} diff --git a/Gready_Poang.DataLayer/Migrations/20250902122130_FixDateTimeSeed.cs b/Gready_Poang.DataLayer/Migrations/20250902122130_FixDateTimeSeed.cs new file mode 100644 index 0000000..5541faa --- /dev/null +++ b/Gready_Poang.DataLayer/Migrations/20250902122130_FixDateTimeSeed.cs @@ -0,0 +1,75 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace GreadyPoang.DataLayer.Migrations +{ + /// + public partial class FixDateTimeSeed : Migration + { + /// + 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)); + } + + /// + 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)); + } + } +} diff --git a/Gready_Poang.DataLayer/Migrations/20250903062957_FixHeatToRoundParameter.Designer.cs b/Gready_Poang.DataLayer/Migrations/20250903062957_FixHeatToRoundParameter.Designer.cs new file mode 100644 index 0000000..8092022 --- /dev/null +++ b/Gready_Poang.DataLayer/Migrations/20250903062957_FixHeatToRoundParameter.Designer.cs @@ -0,0 +1,135 @@ +// +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 + { + /// + 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("GamePointId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("GameDate") + .HasColumnType("TEXT"); + + b.Property("GameHeatId") + .HasColumnType("INTEGER"); + + b.Property("GameHeatRegNr") + .HasColumnType("INTEGER"); + + b.Property("GameRegPoints") + .HasColumnType("INTEGER"); + + b.Property("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("ParticipantId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Email") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("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 + } + } +} diff --git a/Gready_Poang.DataLayer/Migrations/20250903062957_FixHeatToRoundParameter.cs b/Gready_Poang.DataLayer/Migrations/20250903062957_FixHeatToRoundParameter.cs new file mode 100644 index 0000000..8f10e1c --- /dev/null +++ b/Gready_Poang.DataLayer/Migrations/20250903062957_FixHeatToRoundParameter.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace GreadyPoang.DataLayer.Migrations +{ + /// + public partial class FixHeatToRoundParameter : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} diff --git a/Gready_Poang.DataLayer/Migrations/20250903070200_FixHeatToRoundParams.Designer.cs b/Gready_Poang.DataLayer/Migrations/20250903070200_FixHeatToRoundParams.Designer.cs new file mode 100644 index 0000000..0ced9ca --- /dev/null +++ b/Gready_Poang.DataLayer/Migrations/20250903070200_FixHeatToRoundParams.Designer.cs @@ -0,0 +1,135 @@ +// +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 + { + /// + 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("GamePointId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("GameDate") + .HasColumnType("TEXT"); + + b.Property("GameRegPoints") + .HasColumnType("INTEGER"); + + b.Property("GameRoundId") + .HasColumnType("INTEGER"); + + b.Property("GameRoundRegNr") + .HasColumnType("INTEGER"); + + b.Property("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("ParticipantId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Email") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("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 + } + } +} diff --git a/Gready_Poang.DataLayer/Migrations/20250903070200_FixHeatToRoundParams.cs b/Gready_Poang.DataLayer/Migrations/20250903070200_FixHeatToRoundParams.cs new file mode 100644 index 0000000..b51d2a6 --- /dev/null +++ b/Gready_Poang.DataLayer/Migrations/20250903070200_FixHeatToRoundParams.cs @@ -0,0 +1,38 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace GreadyPoang.DataLayer.Migrations +{ + /// + public partial class FixHeatToRoundParams : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.RenameColumn( + name: "GameHeatRegNr", + table: "GamePoints", + newName: "GameRoundRegNr"); + + migrationBuilder.RenameColumn( + name: "GameHeatId", + table: "GamePoints", + newName: "GameRoundId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.RenameColumn( + name: "GameRoundRegNr", + table: "GamePoints", + newName: "GameHeatRegNr"); + + migrationBuilder.RenameColumn( + name: "GameRoundId", + table: "GamePoints", + newName: "GameHeatId"); + } + } +} diff --git a/Gready_Poang.DataLayer/Migrations/20250903074537_AddedStatusEnum.Designer.cs b/Gready_Poang.DataLayer/Migrations/20250903074537_AddedStatusEnum.Designer.cs new file mode 100644 index 0000000..ea5f5eb --- /dev/null +++ b/Gready_Poang.DataLayer/Migrations/20250903074537_AddedStatusEnum.Designer.cs @@ -0,0 +1,135 @@ +// +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 + { + /// + 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("GamePointId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("GameDate") + .HasColumnType("TEXT"); + + b.Property("GameRegPoints") + .HasColumnType("INTEGER"); + + b.Property("GameRoundId") + .HasColumnType("INTEGER"); + + b.Property("GameRoundRegNr") + .HasColumnType("INTEGER"); + + b.Property("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("ParticipantId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Email") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("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 + } + } +} diff --git a/Gready_Poang.DataLayer/Migrations/20250903074537_AddedStatusEnum.cs b/Gready_Poang.DataLayer/Migrations/20250903074537_AddedStatusEnum.cs new file mode 100644 index 0000000..7a05ec8 --- /dev/null +++ b/Gready_Poang.DataLayer/Migrations/20250903074537_AddedStatusEnum.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace GreadyPoang.DataLayer.Migrations +{ + /// + public partial class AddedStatusEnum : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} diff --git a/Gready_Poang.DataLayer/Migrations/20250903195147_AddedTableGameRounds.Designer.cs b/Gready_Poang.DataLayer/Migrations/20250903195147_AddedTableGameRounds.Designer.cs new file mode 100644 index 0000000..db2a9d7 --- /dev/null +++ b/Gready_Poang.DataLayer/Migrations/20250903195147_AddedTableGameRounds.Designer.cs @@ -0,0 +1,179 @@ +// +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 + { + /// + 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("GamePointId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("GameDate") + .HasColumnType("TEXT"); + + b.Property("GameRegPoints") + .HasColumnType("INTEGER"); + + b.Property("GameRoundId") + .HasColumnType("INTEGER"); + + b.Property("GameRoundRegNr") + .HasColumnType("INTEGER"); + + b.Property("ParticipantId") + .HasColumnType("INTEGER"); + + b.Property("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("GameRoundId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("GameRoundFinished") + .HasColumnType("TEXT"); + + b.Property("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("ParticipantId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Email") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("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 + } + } +} diff --git a/Gready_Poang.DataLayer/Migrations/20250903195147_AddedTableGameRounds.cs b/Gready_Poang.DataLayer/Migrations/20250903195147_AddedTableGameRounds.cs new file mode 100644 index 0000000..d01a536 --- /dev/null +++ b/Gready_Poang.DataLayer/Migrations/20250903195147_AddedTableGameRounds.cs @@ -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 +{ + /// + public partial class AddedTableGameRounds : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "PointStatus", + table: "GamePoints", + type: "INTEGER", + nullable: false, + defaultValue: 0); + + migrationBuilder.CreateTable( + name: "GameRounds", + columns: table => new + { + GameRoundId = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + GameRoundFinished = table.Column(type: "TEXT", nullable: true), + GameRoundStartDate = table.Column(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) } + }); + } + + /// + 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); + } + } +} diff --git a/Gready_Poang.DataLayer/Migrations/20250903195935_ChangedUpdateOrderInSeeding.Designer.cs b/Gready_Poang.DataLayer/Migrations/20250903195935_ChangedUpdateOrderInSeeding.Designer.cs new file mode 100644 index 0000000..13e9a6c --- /dev/null +++ b/Gready_Poang.DataLayer/Migrations/20250903195935_ChangedUpdateOrderInSeeding.Designer.cs @@ -0,0 +1,179 @@ +// +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 + { + /// + 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("GamePointId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("GameDate") + .HasColumnType("TEXT"); + + b.Property("GameRegPoints") + .HasColumnType("INTEGER"); + + b.Property("GameRoundId") + .HasColumnType("INTEGER"); + + b.Property("GameRoundRegNr") + .HasColumnType("INTEGER"); + + b.Property("ParticipantId") + .HasColumnType("INTEGER"); + + b.Property("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("GameRoundId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("GameRoundFinished") + .HasColumnType("TEXT"); + + b.Property("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("ParticipantId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Email") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("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 + } + } +} diff --git a/Gready_Poang.DataLayer/Migrations/20250903195935_ChangedUpdateOrderInSeeding.cs b/Gready_Poang.DataLayer/Migrations/20250903195935_ChangedUpdateOrderInSeeding.cs new file mode 100644 index 0000000..840f094 --- /dev/null +++ b/Gready_Poang.DataLayer/Migrations/20250903195935_ChangedUpdateOrderInSeeding.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace GreadyPoang.DataLayer.Migrations +{ + /// + public partial class ChangedUpdateOrderInSeeding : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} diff --git a/Gready_Poang.DataLayer/Migrations/20250914064850_statusfieldmove.Designer.cs b/Gready_Poang.DataLayer/Migrations/20250914064850_statusfieldmove.Designer.cs new file mode 100644 index 0000000..e1e888f --- /dev/null +++ b/Gready_Poang.DataLayer/Migrations/20250914064850_statusfieldmove.Designer.cs @@ -0,0 +1,178 @@ +// +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 + { + /// + 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("GamePointId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("GameDate") + .HasColumnType("TEXT"); + + b.Property("GameRegPoints") + .HasColumnType("INTEGER"); + + b.Property("GameRoundId") + .HasColumnType("INTEGER"); + + b.Property("GameRoundRegNr") + .HasColumnType("INTEGER"); + + b.Property("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("GameRoundId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("GameRoundFinished") + .HasColumnType("TEXT"); + + b.Property("GameRoundStartDate") + .HasColumnType("TEXT"); + + b.Property("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("ParticipantId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Email") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("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 + } + } +} diff --git a/Gready_Poang.DataLayer/Migrations/20250914064850_statusfieldmove.cs b/Gready_Poang.DataLayer/Migrations/20250914064850_statusfieldmove.cs new file mode 100644 index 0000000..cfed5ae --- /dev/null +++ b/Gready_Poang.DataLayer/Migrations/20250914064850_statusfieldmove.cs @@ -0,0 +1,89 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace GreadyPoang.DataLayer.Migrations +{ + /// + public partial class statusfieldmove : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "PointStatus", + table: "GamePoints"); + + migrationBuilder.AddColumn( + 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); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "GameStatus", + table: "GameRounds"); + + migrationBuilder.AddColumn( + 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); + } + } +} diff --git a/Gready_Poang.DataLayer/Migrations/DataContextModelSnapshot.cs b/Gready_Poang.DataLayer/Migrations/DataContextModelSnapshot.cs new file mode 100644 index 0000000..0eabf33 --- /dev/null +++ b/Gready_Poang.DataLayer/Migrations/DataContextModelSnapshot.cs @@ -0,0 +1,175 @@ +// +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("GamePointId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("GameDate") + .HasColumnType("TEXT"); + + b.Property("GameRegPoints") + .HasColumnType("INTEGER"); + + b.Property("GameRoundId") + .HasColumnType("INTEGER"); + + b.Property("GameRoundRegNr") + .HasColumnType("INTEGER"); + + b.Property("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("GameRoundId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("GameRoundFinished") + .HasColumnType("TEXT"); + + b.Property("GameRoundStartDate") + .HasColumnType("TEXT"); + + b.Property("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("ParticipantId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Email") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("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 + } + } +} diff --git a/Gready_Poang.EntityLayer/EntityClasses/GamePoint.cs b/Gready_Poang.EntityLayer/EntityClasses/GamePoint.cs new file mode 100644 index 0000000..1bd6b85 --- /dev/null +++ b/Gready_Poang.EntityLayer/EntityClasses/GamePoint.cs @@ -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)); + } + } + + + +} diff --git a/Gready_Poang.EntityLayer/EntityClasses/GameRound.cs b/Gready_Poang.EntityLayer/EntityClasses/GameRound.cs new file mode 100644 index 0000000..f1e638e --- /dev/null +++ b/Gready_Poang.EntityLayer/EntityClasses/GameRound.cs @@ -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"); } + } + + +} diff --git a/Gready_Poang.EntityLayer/EntityClasses/Participant.cs b/Gready_Poang.EntityLayer/EntityClasses/Participant.cs new file mode 100644 index 0000000..b18b9bd --- /dev/null +++ b/Gready_Poang.EntityLayer/EntityClasses/Participant.cs @@ -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}"; } + } +} diff --git a/Gready_Poang.EntityLayer/Enums/GamePointStatus.cs b/Gready_Poang.EntityLayer/Enums/GamePointStatus.cs new file mode 100644 index 0000000..c2700de --- /dev/null +++ b/Gready_Poang.EntityLayer/Enums/GamePointStatus.cs @@ -0,0 +1,11 @@ +namespace GreadyPoang.EntityLayer; + +public enum GamePointStatus +{ + New = 0, + InProgress = 1, + Completed = 2, + Cancelled = 3, + Winning = 4, + Winner = 5 +} diff --git a/Gready_Poang.EntityLayer/Gready_Poang.EntityLayer.csproj b/Gready_Poang.EntityLayer/Gready_Poang.EntityLayer.csproj new file mode 100644 index 0000000..1e43643 --- /dev/null +++ b/Gready_Poang.EntityLayer/Gready_Poang.EntityLayer.csproj @@ -0,0 +1,22 @@ + + + + + net9.0-android; + net9.0-ios; + net9.0-maccatalyst; + net9.0-windows10.0.19041 + + enable + enable + + + + + + + + + + + diff --git a/Gready_Poang.EntityLayer/HelperEntities/PlayerColumn.cs b/Gready_Poang.EntityLayer/HelperEntities/PlayerColumn.cs new file mode 100644 index 0000000..41cae42 --- /dev/null +++ b/Gready_Poang.EntityLayer/HelperEntities/PlayerColumn.cs @@ -0,0 +1,55 @@ +using Common.Library; + +namespace GreadyPoang.EntityLayer; + +public class PlayerColumn : EntityBase +{ + public PlayerColumn() + { + _playerName = string.Empty; + _values = new List(); + } + + + private int _playerId; + private string _playerName; + private List _values; + public string PlayerName + { + get { return _playerName; } + set + { + _playerName = value; + RaisePropertyChanged(nameof(PlayerName)); + } + } + public List 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; } + } + + +} diff --git a/Gready_Poang.EntityLayer/HelperEntities/RoundBuilderElement.cs b/Gready_Poang.EntityLayer/HelperEntities/RoundBuilderElement.cs new file mode 100644 index 0000000..f956bf7 --- /dev/null +++ b/Gready_Poang.EntityLayer/HelperEntities/RoundBuilderElement.cs @@ -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)); + } + } + + +} diff --git a/Gready_Poang.EntityLayer/HelperEntities/RoundBuilderGroup.cs b/Gready_Poang.EntityLayer/HelperEntities/RoundBuilderGroup.cs new file mode 100644 index 0000000..7e01867 --- /dev/null +++ b/Gready_Poang.EntityLayer/HelperEntities/RoundBuilderGroup.cs @@ -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(); + } + private int _gameRoundId; + private DateTime _gameRoundStartDate; + private GamePointStatus _status; + private List _elements; + public int GameRoundId + { + get { return _gameRoundId; } + set + { + _gameRoundId = value; + // No need to raise property changed for this example + } + } + public DateTime GameRoundStartDate + { + get { return _gameRoundStartDate; } + set + { + _gameRoundStartDate = value; + // No need to raise property changed for this example + } + } + public GamePointStatus Status + { + get { return _status; } + set + { + _status = value; + // No need to raise property changed for this example + } + } + + public List Elements + { + get { return _elements; } + set + { + _elements = value; + RaisePropertyChanged(nameof(Elements)); + // No need to raise property changed for this example + } + } +} diff --git a/Gready_Poang.Migrations/Gready_Poang.Migrations.csproj b/Gready_Poang.Migrations/Gready_Poang.Migrations.csproj new file mode 100644 index 0000000..0335a6e --- /dev/null +++ b/Gready_Poang.Migrations/Gready_Poang.Migrations.csproj @@ -0,0 +1,29 @@ + + + + Exe + + net9.0-android; + net9.0-ios; + net9.0-maccatalyst; + net9.0-windows10.0.19041 + + enable + enable + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + diff --git a/Gready_Poang.Migrations/Program.cs b/Gready_Poang.Migrations/Program.cs new file mode 100644 index 0000000..d82150b --- /dev/null +++ b/Gready_Poang.Migrations/Program.cs @@ -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(); + 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(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 \ No newline at end of file diff --git a/Gready_Poang.Services/Gready_Poang.Services.csproj b/Gready_Poang.Services/Gready_Poang.Services.csproj new file mode 100644 index 0000000..dc3b306 --- /dev/null +++ b/Gready_Poang.Services/Gready_Poang.Services.csproj @@ -0,0 +1,18 @@ + + + + + net9.0-android; + net9.0-ios; + net9.0-maccatalyst; + net9.0-windows10.0.19041 + + enable + enable + + + + + + + diff --git a/Gready_Poang.Services/Services/Implements/ObjectMessageService.cs b/Gready_Poang.Services/Services/Implements/ObjectMessageService.cs new file mode 100644 index 0000000..2a8fa18 --- /dev/null +++ b/Gready_Poang.Services/Services/Implements/ObjectMessageService.cs @@ -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; +} diff --git a/Gready_Poang.Services/Services/Interfaces/IObjectMessageService.cs b/Gready_Poang.Services/Services/Interfaces/IObjectMessageService.cs new file mode 100644 index 0000000..81203a1 --- /dev/null +++ b/Gready_Poang.Services/Services/Interfaces/IObjectMessageService.cs @@ -0,0 +1,10 @@ +using GreadyPoang.EntityLayer; + +namespace GreadyPoang.Services +{ + public interface IObjectMessageService + { + RoundBuilderGroup CurrentGroup { get; set; } + bool Delivered { get; set; } + } +} \ No newline at end of file diff --git a/Gready_Poang.ViewModelLayer/Gready_Poang.ViewModelLayer.csproj b/Gready_Poang.ViewModelLayer/Gready_Poang.ViewModelLayer.csproj new file mode 100644 index 0000000..69fff70 --- /dev/null +++ b/Gready_Poang.ViewModelLayer/Gready_Poang.ViewModelLayer.csproj @@ -0,0 +1,21 @@ + + + + + net9.0-android; + net9.0-ios; + net9.0-maccatalyst; + net9.0-windows10.0.19041 + + enable + enable + + + + + + + + + + diff --git a/Gready_Poang.ViewModelLayer/Interfaces/INavigationService.cs b/Gready_Poang.ViewModelLayer/Interfaces/INavigationService.cs new file mode 100644 index 0000000..a1a18c0 --- /dev/null +++ b/Gready_Poang.ViewModelLayer/Interfaces/INavigationService.cs @@ -0,0 +1,9 @@ +namespace GreadyPoang.Core; + +public interface INavigationService +{ + Task NavigateToAsync(string route); + Task NavigateToPageAsync(Page page); + +} + diff --git a/Gready_Poang.ViewModelLayer/Interfaces/IPageFactory.cs b/Gready_Poang.ViewModelLayer/Interfaces/IPageFactory.cs new file mode 100644 index 0000000..b45d9df --- /dev/null +++ b/Gready_Poang.ViewModelLayer/Interfaces/IPageFactory.cs @@ -0,0 +1,6 @@ +namespace GreadyPoang.Core; + +public interface IPageFactory +{ + Page CreateRoundPage(); +} \ No newline at end of file diff --git a/Gready_Poang.ViewModelLayer/Interfaces/ISplashService.cs b/Gready_Poang.ViewModelLayer/Interfaces/ISplashService.cs new file mode 100644 index 0000000..31d5247 --- /dev/null +++ b/Gready_Poang.ViewModelLayer/Interfaces/ISplashService.cs @@ -0,0 +1,9 @@ + +namespace GreadyPoang.Core; + +public interface ISplashService +{ + Task ShowSplash(string text = "Välkommen!", int durationMs = 3000); + Task HideAsync(); + +} \ No newline at end of file diff --git a/Gready_Poang.ViewModelLayer/ViewModelClasses/AppShellViewModel.cs b/Gready_Poang.ViewModelLayer/ViewModelClasses/AppShellViewModel.cs new file mode 100644 index 0000000..dfa88c4 --- /dev/null +++ b/Gready_Poang.ViewModelLayer/ViewModelClasses/AppShellViewModel.cs @@ -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)); + } + } + + +} diff --git a/Gready_Poang.ViewModelLayer/ViewModelClasses/MainPageViewModel.cs b/Gready_Poang.ViewModelLayer/ViewModelClasses/MainPageViewModel.cs new file mode 100644 index 0000000..1656052 --- /dev/null +++ b/Gready_Poang.ViewModelLayer/ViewModelClasses/MainPageViewModel.cs @@ -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; + } + } + +} diff --git a/Gready_Poang.ViewModelLayer/ViewModelClasses/MethodSharingService.cs b/Gready_Poang.ViewModelLayer/ViewModelClasses/MethodSharingService.cs new file mode 100644 index 0000000..46a95c2 --- /dev/null +++ b/Gready_Poang.ViewModelLayer/ViewModelClasses/MethodSharingService.cs @@ -0,0 +1,37 @@ +using Common.Library; +using GreadyPoang.EntityLayer; +using System.Collections.ObjectModel; + +namespace GreadyPoang.ViewModelLayer; + +public class MethodSharingService : ViewModelBase, IMethodSharingService +{ + private readonly IRepository _repository; + + public MethodSharingService(IRepository repository) + { + _repository = repository; + } + + + public ObservableCollection Get() + { + ObservableCollection _participantList = new(); + + if (_repository != null) + { + var participantsTask = _repository.Get(); + var participants = participantsTask is Task> task + ? task.GetAwaiter().GetResult() + : (IEnumerable)participantsTask; + foreach (var participant in participants) + { + if (!_participantList.Any(p => p.ParticipantId == participant.ParticipantId)) + { + _participantList.Add(participant); + } + } + } + return _participantList; + } +} diff --git a/Gready_Poang.ViewModelLayer/ViewModelClasses/ParticipantViewModel.cs b/Gready_Poang.ViewModelLayer/ViewModelClasses/ParticipantViewModel.cs new file mode 100644 index 0000000..06105cd --- /dev/null +++ b/Gready_Poang.ViewModelLayer/ViewModelClasses/ParticipantViewModel.cs @@ -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 repo, + IMethodSharingService sharingService, + AppShellViewModel appShell, + IObjectMessageService objectMessage) : base() + { + _Repository = repo; + _sharingService = sharingService; + _appShell = appShell; + _objectMessage = objectMessage; + } + + #endregion + + #region Private Variables + private Participant? _ParticipantObject = new(); + private ObservableCollection _ParticipantList = new(); + private readonly IRepository? _Repository; + private readonly IMethodSharingService _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 ParticipantList + { + get { return _ParticipantList; } + set + { + _ParticipantList = value; + RaisePropertyChanged(nameof(ParticipantList)); + } + } + + #endregion + + #region Get Method + public ObservableCollection 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 +} \ No newline at end of file diff --git a/Gready_Poang.ViewModelLayer/ViewModelClasses/RoundRunningViewModel.cs b/Gready_Poang.ViewModelLayer/ViewModelClasses/RoundRunningViewModel.cs new file mode 100644 index 0000000..234e2c3 --- /dev/null +++ b/Gready_Poang.ViewModelLayer/ViewModelClasses/RoundRunningViewModel.cs @@ -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 roundsRepo, + IRepository pointsRepo, + IMethodSharingService 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(); + _builderObject = new(); + _SplashShowing = false; + + } + + private bool _SplashShowing; + + private readonly IRepository? _roundsRepo; + private readonly IRepository _pointsRepo; + private readonly IMethodSharingService _sharingService; + private readonly ICombinedRepository _combined; + private readonly IObjectMessageService _objectMessage; + private readonly ISplashService _splashService; + private readonly AppShellViewModel _appShell; + private ObservableCollection _GameRoundList = new(); + private ObservableCollection _ParticipantList = new(); + private ObservableCollection _roundElements; + private Collection _playerColumns; + private RoundBuilderElement _builderObject; + + public void TriggerRebuild() + { + // Trigga eventet + RebuildRequested?.Invoke(this, EventArgs.Empty); + } + + // Översta raden + public ObservableCollection RoundElements + { + get { return _roundElements; } + set + { + _roundElements = value; + RaisePropertyChanged(nameof(RoundElements)); + } + } + + // Nedersta strukturen + public Collection 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 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 elements) + { + if (_playerColumns != null) + { + _playerColumns.Clear(); + } + else + { + _playerColumns = new Collection(); + } + + // 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; + } +} + + diff --git a/Gready_Poang.ViewModelLayer/ViewModelClasses/RoundStartingViewModel.cs b/Gready_Poang.ViewModelLayer/ViewModelClasses/RoundStartingViewModel.cs new file mode 100644 index 0000000..f32a9d7 --- /dev/null +++ b/Gready_Poang.ViewModelLayer/ViewModelClasses/RoundStartingViewModel.cs @@ -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 roundsRepo, + IRepository pointsRepo, + IMethodSharingService 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(); + } + + #endregion + + private GameRound? _GameRoundObject = new(); + private ObservableCollection _GameRoundList = new(); + private ObservableCollection _ParticipantList = new(); + private readonly IRepository? _roundsRepo; + private readonly IRepository _pointsRepo; + private readonly IMethodSharingService _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 _roundElements; + + public ObservableCollection 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 GameRoundList + { + get { return _GameRoundList; } + set + { + _GameRoundList = value; + RaisePropertyChanged(nameof(GameRoundList)); + } + } + + public ObservableCollection ParticipantList + { + get { return _ParticipantList; } + set + { + _ParticipantList = value; + RaisePropertyChanged(nameof(ParticipantList)); + } + } + + #region Get Method + public ObservableCollection 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(groupedRounds); + + } + return GameRoundList; + } + + public ObservableCollection 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 + +} diff --git a/Gready_Poang.ViewModelLayer/ViewModelClasses/SplashViewModel.cs b/Gready_Poang.ViewModelLayer/ViewModelClasses/SplashViewModel.cs new file mode 100644 index 0000000..cecf2d0 --- /dev/null +++ b/Gready_Poang.ViewModelLayer/ViewModelClasses/SplashViewModel.cs @@ -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); + } + } +} diff --git a/Gready_Poang.sln b/Gready_Poang.sln new file mode 100644 index 0000000..5c126cb --- /dev/null +++ b/Gready_Poang.sln @@ -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 diff --git a/Gready_Poang/App.xaml b/Gready_Poang/App.xaml new file mode 100644 index 0000000..f937e9c --- /dev/null +++ b/Gready_Poang/App.xaml @@ -0,0 +1,15 @@ + + + + + + + + + + + + diff --git a/Gready_Poang/App.xaml.cs b/Gready_Poang/App.xaml.cs new file mode 100644 index 0000000..ee69b7e --- /dev/null +++ b/Gready_Poang/App.xaml.cs @@ -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(); + //var shell = new AppShell(splashVm); + + var shell = _services.GetRequiredService(); + return new Window(shell); + } +} \ No newline at end of file diff --git a/Gready_Poang/AppShell.xaml b/Gready_Poang/AppShell.xaml new file mode 100644 index 0000000..4bcae85 --- /dev/null +++ b/Gready_Poang/AppShell.xaml @@ -0,0 +1,30 @@ + + + + + + + + + + + diff --git a/Gready_Poang/AppShell.xaml.cs b/Gready_Poang/AppShell.xaml.cs new file mode 100644 index 0000000..ae96b64 --- /dev/null +++ b/Gready_Poang/AppShell.xaml.cs @@ -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; + } + } +} diff --git a/Gready_Poang/BasePage.xaml b/Gready_Poang/BasePage.xaml new file mode 100644 index 0000000..16166ab --- /dev/null +++ b/Gready_Poang/BasePage.xaml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Gready_Poang/BasePage.xaml.cs b/Gready_Poang/BasePage.xaml.cs new file mode 100644 index 0000000..444d4d7 --- /dev/null +++ b/Gready_Poang/BasePage.xaml.cs @@ -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; + } +} \ No newline at end of file diff --git a/Gready_Poang/CommandClasses/AppShellViewModelCommands.cs b/Gready_Poang/CommandClasses/AppShellViewModelCommands.cs new file mode 100644 index 0000000..28ed037 --- /dev/null +++ b/Gready_Poang/CommandClasses/AppShellViewModelCommands.cs @@ -0,0 +1,11 @@ +using GreadyPoang.ViewModelLayer; + +namespace GreadyPoang.CommandClasses; + +public class AppShellViewModelCommands : AppShellViewModel +{ + public AppShellViewModelCommands() : base() + { + + } +} diff --git a/Gready_Poang/CommandClasses/MainPageViewModelCommands.cs b/Gready_Poang/CommandClasses/MainPageViewModelCommands.cs new file mode 100644 index 0000000..c295f5b --- /dev/null +++ b/Gready_Poang/CommandClasses/MainPageViewModelCommands.cs @@ -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) + { + + } +} diff --git a/Gready_Poang/CommandClasses/ParticipantViewModelCommands.cs b/Gready_Poang/CommandClasses/ParticipantViewModelCommands.cs new file mode 100644 index 0000000..9ee4615 --- /dev/null +++ b/Gready_Poang/CommandClasses/ParticipantViewModelCommands.cs @@ -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 repo, + IMethodSharingService 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(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 SaveAsync() + { + var ret = base.Save(); + if (ret) + { + await Shell.Current.GoToAsync(".."); + } + + return ret; + } +} diff --git a/Gready_Poang/CommandClasses/RoundRunningViewModelCommands.cs b/Gready_Poang/CommandClasses/RoundRunningViewModelCommands.cs new file mode 100644 index 0000000..d16ec5e --- /dev/null +++ b/Gready_Poang/CommandClasses/RoundRunningViewModelCommands.cs @@ -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 roundsRepo, + IRepository pointsRepo, + IMethodSharingService 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(); + } +} diff --git a/Gready_Poang/CommandClasses/RoundStartingViewModelCommands.cs b/Gready_Poang/CommandClasses/RoundStartingViewModelCommands.cs new file mode 100644 index 0000000..8784549 --- /dev/null +++ b/Gready_Poang/CommandClasses/RoundStartingViewModelCommands.cs @@ -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 roundsRepo, + IRepository pointsRepo, + IMethodSharingService 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(async (id) => await EditAsync(id), (id) => id > 0); + RensaCommand = new Command(async () => RensaAsync()); + ParticipantTappedCommand = new Command(async (selectedParticipant) => SelectNewlyAddedParticipant(selectedParticipant)); + ElementTappedCommand = new Command((selectedElement) => RoundSelected(selectedElement)); + + } + + private async Task RensaAsync() + { + 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 SaveAsync() + { + var ret = base.Save(); + if (ret) + { + await Shell.Current.GoToAsync(".."); + } + + return ret; + } + + public async Task RoundSelected(RoundBuilderElement element) + { + bool goneOk = false; + base.RoundSelected(element); + goneOk = true; + return goneOk; + } + + public async Task SelectNewlyAddedParticipant(RoundBuilderElement roundBuilder) + { + bool goneOk = false; + base.SelectNewlyAddedParticipant(roundBuilder); + goneOk = true; + return goneOk; + } + +} diff --git a/Gready_Poang/CommandClasses/SplashViewModelCommands.cs b/Gready_Poang/CommandClasses/SplashViewModelCommands.cs new file mode 100644 index 0000000..942444b --- /dev/null +++ b/Gready_Poang/CommandClasses/SplashViewModelCommands.cs @@ -0,0 +1,10 @@ +using GreadyPoang.ViewModelLayer; + +namespace GreadyPoang.CommandClasses; + +public class SplashViewModelCommands : SplashViewModel +{ + public SplashViewModelCommands() : base() + { + } +} diff --git a/Gready_Poang/Core/NavigationService.cs b/Gready_Poang/Core/NavigationService.cs new file mode 100644 index 0000000..06756ff --- /dev/null +++ b/Gready_Poang/Core/NavigationService.cs @@ -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); +} diff --git a/Gready_Poang/Core/PageFactory.cs b/Gready_Poang/Core/PageFactory.cs new file mode 100644 index 0000000..f8982db --- /dev/null +++ b/Gready_Poang/Core/PageFactory.cs @@ -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(); + var splashVm = _services.GetRequiredService(); + return new RoundRunningPage(vm, splashVm); + } + + //public Page CreateStatsPage() + //{ + // //var vm = _services.GetRequiredService(); + // //var splashVm = _services.GetRequiredService(); + // //var view = new StatsView { BindingContext = vm }; + // //return new StatsPage(view, splashVm); + //} +} diff --git a/Gready_Poang/Core/ServiceLocator.cs b/Gready_Poang/Core/ServiceLocator.cs new file mode 100644 index 0000000..898a6f4 --- /dev/null +++ b/Gready_Poang/Core/ServiceLocator.cs @@ -0,0 +1,10 @@ +using GreadyPoang.InterFaces; + +namespace GreadyPoang; + +public class ServiceLocator : IServiceLocator +{ + public static IServiceProvider? Services { get; set; } = default; + public T Get() => (T)Services!.GetService(typeof(T))!; + +} diff --git a/Gready_Poang/Gready_Poang.csproj b/Gready_Poang/Gready_Poang.csproj new file mode 100644 index 0000000..5f24b19 --- /dev/null +++ b/Gready_Poang/Gready_Poang.csproj @@ -0,0 +1,111 @@ + + + + net9.0-android;net9.0-ios;net9.0-maccatalyst + $(TargetFrameworks);net9.0-windows10.0.19041.0 + + + + + + + Exe + Gready_Poang + true + true + enable + enable + + + Gready_Poang + + + com.companyname.Gready_Poang + + + 1.0 + 1 + + + None + + 15.0 + 15.0 + 21.0 + 10.0.17763.0 + 10.0.17763.0 + 6.5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ParticipantListView.xaml + + + + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + + + + + + diff --git a/Gready_Poang/InterFaces/IServiceLocator.cs b/Gready_Poang/InterFaces/IServiceLocator.cs new file mode 100644 index 0000000..d6ae444 --- /dev/null +++ b/Gready_Poang/InterFaces/IServiceLocator.cs @@ -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(); +} diff --git a/Gready_Poang/LocalServices/Implements/SplashService.cs b/Gready_Poang/LocalServices/Implements/SplashService.cs new file mode 100644 index 0000000..7af6a7c --- /dev/null +++ b/Gready_Poang/LocalServices/Implements/SplashService.cs @@ -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(); + } +} diff --git a/Gready_Poang/MainPage.xaml b/Gready_Poang/MainPage.xaml new file mode 100644 index 0000000..a9ffb2f --- /dev/null +++ b/Gready_Poang/MainPage.xaml @@ -0,0 +1,28 @@ + + + + + + + + + diff --git a/Gready_Poang/MainPage.xaml.cs b/Gready_Poang/MainPage.xaml.cs new file mode 100644 index 0000000..2769e9b --- /dev/null +++ b/Gready_Poang/MainPage.xaml.cs @@ -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(); + } + +} diff --git a/Gready_Poang/MauiProgram.cs b/Gready_Poang/MauiProgram.cs new file mode 100644 index 0000000..8a863fa --- /dev/null +++ b/Gready_Poang/MauiProgram.cs @@ -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() + .ConfigureFonts(fonts => + { + fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); + fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold"); + }); + + + + builder.Services.AddDbContext(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(); + builder.Services.AddSingleton(); + builder.Services.AddSingleton(); + + builder.Services.AddScoped, ParticipantRepository>(); + builder.Services.AddScoped(); + builder.Services.AddScoped(); + + builder.Services.AddScoped, GameRoundRepository>(); + builder.Services.AddScoped(); + builder.Services.AddScoped(); + + builder.Services.AddScoped, GamePointRepository>(); + builder.Services.AddScoped(); + builder.Services.AddScoped(); + + builder.Services.AddScoped, MethodSharingService>(); + builder.Services.AddScoped(); + + builder.Services.AddSingleton(); + + builder.Services.AddSingleton(); + builder.Services.AddSingleton(); + + builder.Services.AddSingleton(); + builder.Services.AddSingleton(); + + builder.Services.AddSingleton(); + + +#if DEBUG + builder.Logging.AddDebug(); +#endif + var app = builder.Build(); + ServiceLocator.Services = app.Services; + return app; + } +} diff --git a/Gready_Poang/Pages/ParticipantListPage.cs b/Gready_Poang/Pages/ParticipantListPage.cs new file mode 100644 index 0000000..53cda00 --- /dev/null +++ b/Gready_Poang/Pages/ParticipantListPage.cs @@ -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(); + } + +} diff --git a/Gready_Poang/Pages/RoundRunningPage.cs b/Gready_Poang/Pages/RoundRunningPage.cs new file mode 100644 index 0000000..d8e0f81 --- /dev/null +++ b/Gready_Poang/Pages/RoundRunningPage.cs @@ -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(); + _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(); ; + + } + + + +} diff --git a/Gready_Poang/Pages/RoundStartingPage.cs b/Gready_Poang/Pages/RoundStartingPage.cs new file mode 100644 index 0000000..1c59651 --- /dev/null +++ b/Gready_Poang/Pages/RoundStartingPage.cs @@ -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(); + } + +} diff --git a/Gready_Poang/Platforms/Android/AndroidManifest.xml b/Gready_Poang/Platforms/Android/AndroidManifest.xml new file mode 100644 index 0000000..0236621 --- /dev/null +++ b/Gready_Poang/Platforms/Android/AndroidManifest.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Gready_Poang/Platforms/Android/MainActivity.cs b/Gready_Poang/Platforms/Android/MainActivity.cs new file mode 100644 index 0000000..86052ce --- /dev/null +++ b/Gready_Poang/Platforms/Android/MainActivity.cs @@ -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 + { + } +} diff --git a/Gready_Poang/Platforms/Android/MainApplication.cs b/Gready_Poang/Platforms/Android/MainApplication.cs new file mode 100644 index 0000000..d6129dc --- /dev/null +++ b/Gready_Poang/Platforms/Android/MainApplication.cs @@ -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(); + } +} diff --git a/Gready_Poang/Platforms/Android/Resources/values/colors.xml b/Gready_Poang/Platforms/Android/Resources/values/colors.xml new file mode 100644 index 0000000..c04d749 --- /dev/null +++ b/Gready_Poang/Platforms/Android/Resources/values/colors.xml @@ -0,0 +1,6 @@ + + + #512BD4 + #2B0B98 + #2B0B98 + \ No newline at end of file diff --git a/Gready_Poang/Platforms/MacCatalyst/AppDelegate.cs b/Gready_Poang/Platforms/MacCatalyst/AppDelegate.cs new file mode 100644 index 0000000..f0dea5b --- /dev/null +++ b/Gready_Poang/Platforms/MacCatalyst/AppDelegate.cs @@ -0,0 +1,10 @@ +using Foundation; + +namespace GreadyPoang +{ + [Register("AppDelegate")] + public class AppDelegate : MauiUIApplicationDelegate + { + protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); + } +} diff --git a/Gready_Poang/Platforms/MacCatalyst/Entitlements.plist b/Gready_Poang/Platforms/MacCatalyst/Entitlements.plist new file mode 100644 index 0000000..de4adc9 --- /dev/null +++ b/Gready_Poang/Platforms/MacCatalyst/Entitlements.plist @@ -0,0 +1,14 @@ + + + + + + + com.apple.security.app-sandbox + + + com.apple.security.network.client + + + + diff --git a/Gready_Poang/Platforms/MacCatalyst/Info.plist b/Gready_Poang/Platforms/MacCatalyst/Info.plist new file mode 100644 index 0000000..7268977 --- /dev/null +++ b/Gready_Poang/Platforms/MacCatalyst/Info.plist @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + UIDeviceFamily + + 2 + + UIRequiredDeviceCapabilities + + arm64 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + XSAppIconAssets + Assets.xcassets/appicon.appiconset + + diff --git a/Gready_Poang/Platforms/MacCatalyst/Program.cs b/Gready_Poang/Platforms/MacCatalyst/Program.cs new file mode 100644 index 0000000..ad29e7f --- /dev/null +++ b/Gready_Poang/Platforms/MacCatalyst/Program.cs @@ -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)); + } + } +} diff --git a/Gready_Poang/Platforms/Tizen/Main.cs b/Gready_Poang/Platforms/Tizen/Main.cs new file mode 100644 index 0000000..2b15a15 --- /dev/null +++ b/Gready_Poang/Platforms/Tizen/Main.cs @@ -0,0 +1,17 @@ +using System; +using Microsoft.Maui; +using Microsoft.Maui.Hosting; + +namespace GreadyPoang +{ + internal class Program : MauiApplication + { + protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); + + static void Main(string[] args) + { + var app = new Program(); + app.Run(args); + } + } +} diff --git a/Gready_Poang/Platforms/Tizen/tizen-manifest.xml b/Gready_Poang/Platforms/Tizen/tizen-manifest.xml new file mode 100644 index 0000000..27b0efc --- /dev/null +++ b/Gready_Poang/Platforms/Tizen/tizen-manifest.xml @@ -0,0 +1,15 @@ + + + + + + maui-appicon-placeholder + + + + + http://tizen.org/privilege/internet + + + + \ No newline at end of file diff --git a/Gready_Poang/Platforms/Windows/App.xaml b/Gready_Poang/Platforms/Windows/App.xaml new file mode 100644 index 0000000..996aa2a --- /dev/null +++ b/Gready_Poang/Platforms/Windows/App.xaml @@ -0,0 +1,8 @@ + + + diff --git a/Gready_Poang/Platforms/Windows/App.xaml.cs b/Gready_Poang/Platforms/Windows/App.xaml.cs new file mode 100644 index 0000000..9d538bd --- /dev/null +++ b/Gready_Poang/Platforms/Windows/App.xaml.cs @@ -0,0 +1,25 @@ +using Microsoft.UI.Xaml; + +// To learn more about WinUI, the WinUI project structure, +// and more about our project templates, see: http://aka.ms/winui-project-info. + +namespace GreadyPoang.WinUI +{ + /// + /// Provides application-specific behavior to supplement the default Application class. + /// + public partial class App : MauiWinUIApplication + { + /// + /// Initializes the singleton application object. This is the first line of authored code + /// executed, and as such is the logical equivalent of main() or WinMain(). + /// + public App() + { + this.InitializeComponent(); + } + + protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); + } + +} diff --git a/Gready_Poang/Platforms/Windows/Package.appxmanifest b/Gready_Poang/Platforms/Windows/Package.appxmanifest new file mode 100644 index 0000000..b99e85f --- /dev/null +++ b/Gready_Poang/Platforms/Windows/Package.appxmanifest @@ -0,0 +1,53 @@ + + + + + + + GreadyPoang + Idoit4u + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Gready_Poang/Platforms/Windows/app.manifest b/Gready_Poang/Platforms/Windows/app.manifest new file mode 100644 index 0000000..b365b9d --- /dev/null +++ b/Gready_Poang/Platforms/Windows/app.manifest @@ -0,0 +1,15 @@ + + + + + + + + true/PM + PerMonitorV2, PerMonitor + + + diff --git a/Gready_Poang/Platforms/iOS/AppDelegate.cs b/Gready_Poang/Platforms/iOS/AppDelegate.cs new file mode 100644 index 0000000..f0dea5b --- /dev/null +++ b/Gready_Poang/Platforms/iOS/AppDelegate.cs @@ -0,0 +1,10 @@ +using Foundation; + +namespace GreadyPoang +{ + [Register("AppDelegate")] + public class AppDelegate : MauiUIApplicationDelegate + { + protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); + } +} diff --git a/Gready_Poang/Platforms/iOS/Info.plist b/Gready_Poang/Platforms/iOS/Info.plist new file mode 100644 index 0000000..0004a4f --- /dev/null +++ b/Gready_Poang/Platforms/iOS/Info.plist @@ -0,0 +1,32 @@ + + + + + LSRequiresIPhoneOS + + UIDeviceFamily + + 1 + 2 + + UIRequiredDeviceCapabilities + + arm64 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + XSAppIconAssets + Assets.xcassets/appicon.appiconset + + diff --git a/Gready_Poang/Platforms/iOS/Program.cs b/Gready_Poang/Platforms/iOS/Program.cs new file mode 100644 index 0000000..ad29e7f --- /dev/null +++ b/Gready_Poang/Platforms/iOS/Program.cs @@ -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)); + } + } +} diff --git a/Gready_Poang/Platforms/iOS/Resources/PrivacyInfo.xcprivacy b/Gready_Poang/Platforms/iOS/Resources/PrivacyInfo.xcprivacy new file mode 100644 index 0000000..24ab3b4 --- /dev/null +++ b/Gready_Poang/Platforms/iOS/Resources/PrivacyInfo.xcprivacy @@ -0,0 +1,51 @@ + + + + + + NSPrivacyAccessedAPITypes + + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategoryFileTimestamp + NSPrivacyAccessedAPITypeReasons + + C617.1 + + + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategorySystemBootTime + NSPrivacyAccessedAPITypeReasons + + 35F9.1 + + + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategoryDiskSpace + NSPrivacyAccessedAPITypeReasons + + E174.1 + + + + + + diff --git a/Gready_Poang/Properties/launchSettings.json b/Gready_Poang/Properties/launchSettings.json new file mode 100644 index 0000000..4f85793 --- /dev/null +++ b/Gready_Poang/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "Windows Machine": { + "commandName": "Project", + "nativeDebugging": false + } + } +} \ No newline at end of file diff --git a/Gready_Poang/Resources/AppIcon/appicon.svg b/Gready_Poang/Resources/AppIcon/appicon.svg new file mode 100644 index 0000000..9d63b65 --- /dev/null +++ b/Gready_Poang/Resources/AppIcon/appicon.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Gready_Poang/Resources/AppIcon/appiconfg.svg b/Gready_Poang/Resources/AppIcon/appiconfg.svg new file mode 100644 index 0000000..21dfb25 --- /dev/null +++ b/Gready_Poang/Resources/AppIcon/appiconfg.svg @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Gready_Poang/Resources/Fonts/OpenSans-Regular.ttf b/Gready_Poang/Resources/Fonts/OpenSans-Regular.ttf new file mode 100644 index 0000000..33b3e0d Binary files /dev/null and b/Gready_Poang/Resources/Fonts/OpenSans-Regular.ttf differ diff --git a/Gready_Poang/Resources/Fonts/OpenSans-Semibold.ttf b/Gready_Poang/Resources/Fonts/OpenSans-Semibold.ttf new file mode 100644 index 0000000..a1f8571 Binary files /dev/null and b/Gready_Poang/Resources/Fonts/OpenSans-Semibold.ttf differ diff --git a/Gready_Poang/Resources/Images/dotnet_bot.png b/Gready_Poang/Resources/Images/dotnet_bot.png new file mode 100644 index 0000000..1d1b981 Binary files /dev/null and b/Gready_Poang/Resources/Images/dotnet_bot.png differ diff --git a/Gready_Poang/Resources/Images/snurrtarning.gif b/Gready_Poang/Resources/Images/snurrtarning.gif new file mode 100644 index 0000000..68fb263 Binary files /dev/null and b/Gready_Poang/Resources/Images/snurrtarning.gif differ diff --git a/Gready_Poang/Resources/Raw/AboutAssets.txt b/Gready_Poang/Resources/Raw/AboutAssets.txt new file mode 100644 index 0000000..89dc758 --- /dev/null +++ b/Gready_Poang/Resources/Raw/AboutAssets.txt @@ -0,0 +1,15 @@ +Any raw assets you want to be deployed with your application can be placed in +this directory (and child directories). Deployment of the asset to your application +is automatically handled by the following `MauiAsset` Build Action within your `.csproj`. + + + +These files will be deployed with your package and will be accessible using Essentials: + + async Task LoadMauiAsset() + { + using var stream = await FileSystem.OpenAppPackageFileAsync("AboutAssets.txt"); + using var reader = new StreamReader(stream); + + var contents = reader.ReadToEnd(); + } diff --git a/Gready_Poang/Resources/Splash/splash.svg b/Gready_Poang/Resources/Splash/splash.svg new file mode 100644 index 0000000..21dfb25 --- /dev/null +++ b/Gready_Poang/Resources/Splash/splash.svg @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Gready_Poang/Resources/Styles/AppStyles.xaml b/Gready_Poang/Resources/Styles/AppStyles.xaml new file mode 100644 index 0000000..809eca1 --- /dev/null +++ b/Gready_Poang/Resources/Styles/AppStyles.xaml @@ -0,0 +1,203 @@ + + + + + + + + + + + + + + + Gready Poäng + + + 10 + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Gready_Poang/Resources/Styles/Colors.xaml b/Gready_Poang/Resources/Styles/Colors.xaml new file mode 100644 index 0000000..30307a5 --- /dev/null +++ b/Gready_Poang/Resources/Styles/Colors.xaml @@ -0,0 +1,45 @@ + + + + + + + #512BD4 + #ac99ea + #242424 + #DFD8F7 + #9880e5 + #2B0B98 + + White + Black + #D600AA + #190649 + #1f1f1f + + #E1E1E1 + #C8C8C8 + #ACACAC + #919191 + #6E6E6E + #404040 + #212121 + #141414 + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Gready_Poang/Resources/Styles/Styles.xaml b/Gready_Poang/Resources/Styles/Styles.xaml new file mode 100644 index 0000000..86f574d --- /dev/null +++ b/Gready_Poang/Resources/Styles/Styles.xaml @@ -0,0 +1,451 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Gready_Poang/Views/ParticipantListView.xaml b/Gready_Poang/Views/ParticipantListView.xaml new file mode 100644 index 0000000..3228a54 --- /dev/null +++ b/Gready_Poang/Views/ParticipantListView.xaml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + +