Add project files.

This commit is contained in:
2025-08-28 11:32:25 +02:00
parent 35e29e07f1
commit eb9ea77dd9
54 changed files with 1872 additions and 0 deletions

View File

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

View File

@ -0,0 +1,94 @@
using Common.Library;
using GreadyPoang.EntityLayer;
using System.Collections.ObjectModel;
namespace GreadyPoang.ViewModelLayer;
public class ParticipantViewModel : ViewModelBase
{
#region Constructors
public ParticipantViewModel() : base()
{
}
public ParticipantViewModel(IRepository<Participant> repo) : base()
{
Repository = repo;
}
#endregion
#region Private Variables
private Participant? _ParticipantObject = new();
private ObservableCollection<Participant> _ParticipantList = new();
private readonly IRepository<Participant>? Repository;
#endregion
#region public Properties
public Participant? ParticipantObject
{
get { return _ParticipantObject; }
set
{
_ParticipantObject = value;
RaisePropertyChanged(nameof(ParticipantObject));
}
}
public ObservableCollection<Participant> ParticipantList
{
get { return _ParticipantList; }
set
{
_ParticipantList = value;
RaisePropertyChanged(nameof(ParticipantList));
}
}
#endregion
#region Get Method
public ObservableCollection<Participant> Get()
{
if (Repository != null)
{
ParticipantList = new ObservableCollection<Participant>(Repository.Get());
}
return new();
}
#endregion
#region Get(id) Method
public Participant? Get(int id)
{
try
{
ParticipantObject = Repository.Get(id);
}
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 tmp = Repository.Save(ParticipantObject);
if (tmp)
{
ParticipantObject = new Participant();
this.Get();
}
return tmp;
}
#endregion
}