Initial commit

This commit is contained in:
1eG0ist 2025-02-26 11:46:28 +03:00
commit f83570775b
33 changed files with 978 additions and 0 deletions

5
.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
bin/
obj/
/packages/
riderModule.iml
/_ReSharper.Caches/

View File

@ -0,0 +1,13 @@
# Default ignored files
/shelf/
/workspace.xml
# Rider ignored files
/modules.xml
/.idea.IposiGospodDemo.iml
/contentModel.xml
/projectSettingsUpdater.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

16
IposiGospodDemo.sln Normal file
View File

@ -0,0 +1,16 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IposiGospodDemo", "IposiGospodDemo\IposiGospodDemo.csproj", "{BCCED67E-248C-4E16-991D-D4CB82502437}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{BCCED67E-248C-4E16-991D-D4CB82502437}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BCCED67E-248C-4E16-991D-D4CB82502437}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BCCED67E-248C-4E16-991D-D4CB82502437}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BCCED67E-248C-4E16-991D-D4CB82502437}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

15
IposiGospodDemo/App.axaml Normal file
View File

@ -0,0 +1,15 @@
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="IposiGospodDemo.App"
xmlns:local="using:IposiGospodDemo"
RequestedThemeVariant="Default">
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->
<Application.DataTemplates>
<local:ViewLocator/>
</Application.DataTemplates>
<Application.Styles>
<FluentTheme />
</Application.Styles>
</Application>

View File

@ -0,0 +1,47 @@
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Data.Core;
using Avalonia.Data.Core.Plugins;
using System.Linq;
using Avalonia.Markup.Xaml;
using IposiGospodDemo.ViewModels;
using IposiGospodDemo.Views;
namespace IposiGospodDemo;
public partial class App : Application
{
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
}
public override void OnFrameworkInitializationCompleted()
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
// Avoid duplicate validations from both Avalonia and the CommunityToolkit.
// More info: https://docs.avaloniaui.net/docs/guides/development-guides/data-validation#manage-validationplugins
DisableAvaloniaDataAnnotationValidation();
desktop.MainWindow = new MainWindow
{
DataContext = new MainWindowViewModel(),
};
}
base.OnFrameworkInitializationCompleted();
}
private void DisableAvaloniaDataAnnotationValidation()
{
// Get an array of plugins to remove
var dataValidationPluginsToRemove =
BindingPlugins.DataValidators.OfType<DataAnnotationsValidationPlugin>().ToArray();
// remove each entry found
foreach (var plugin in dataValidationPluginsToRemove)
{
BindingPlugins.DataValidators.Remove(plugin);
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 KiB

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
namespace IposiGospodDemo.Context;
public partial class Charity
{
public int CharityId { get; set; }
public string CharityName { get; set; } = null!;
public string? CharityDescription { get; set; }
public string? CharityLogo { get; set; }
public virtual ICollection<Registration> Registrations { get; set; } = new List<Registration>();
}

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
namespace IposiGospodDemo.Context;
public partial class Country
{
public string CountryCode { get; set; } = null!;
public string CountryName { get; set; } = null!;
public string CountryFlag { get; set; } = null!;
public virtual ICollection<Marathon> Marathons { get; set; } = new List<Marathon>();
public virtual ICollection<Runner> Runners { get; set; } = new List<Runner>();
public virtual ICollection<Volunteer> Volunteers { get; set; } = new List<Volunteer>();
}

View File

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
namespace IposiGospodDemo.Context;
public partial class Event
{
public string EventId { get; set; } = null!;
public string EventName { get; set; } = null!;
public string EventTypeId { get; set; } = null!;
public short MarathonId { get; set; }
public DateTime? StartDateTime { get; set; }
public decimal? Cost { get; set; }
public short? MaxParticipants { get; set; }
public virtual EventType EventType { get; set; } = null!;
public virtual Marathon Marathon { get; set; } = null!;
public virtual ICollection<RegistrationEvent> RegistrationEvents { get; set; } = new List<RegistrationEvent>();
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
namespace IposiGospodDemo.Context;
public partial class EventType
{
public string EventTypeId { get; set; } = null!;
public string EventTypeName { get; set; } = null!;
public virtual ICollection<Event> Events { get; set; } = new List<Event>();
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
namespace IposiGospodDemo.Context;
public partial class Gender
{
public string Gender1 { get; set; } = null!;
public virtual ICollection<Runner> Runners { get; set; } = new List<Runner>();
public virtual ICollection<Volunteer> Volunteers { get; set; } = new List<Volunteer>();
}

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
namespace IposiGospodDemo.Context;
public partial class Marathon
{
public short MarathonId { get; set; }
public string MarathonName { get; set; } = null!;
public string? CityName { get; set; }
public string CountryCode { get; set; } = null!;
public short? YearHeld { get; set; }
public virtual Country CountryCodeNavigation { get; set; } = null!;
public virtual ICollection<Event> Events { get; set; } = new List<Event>();
}

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
namespace IposiGospodDemo.Context;
public partial class Position
{
public int PositionId { get; set; }
public string PositionName { get; set; } = null!;
public string? PositionDescription { get; set; }
public string PayPeriod { get; set; } = null!;
public decimal PayRate { get; set; }
public virtual ICollection<Staff> Staff { get; set; } = new List<Staff>();
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
namespace IposiGospodDemo.Context;
public partial class RaceKitOption
{
public char RaceKitOptionId { get; set; }
public string RaceKitOption1 { get; set; } = null!;
public decimal Cost { get; set; }
public virtual ICollection<Registration> Registrations { get; set; } = new List<Registration>();
}

View File

@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
namespace IposiGospodDemo.Context;
public partial class Registration
{
public int RegistrationId { get; set; }
public int RunnerId { get; set; }
public DateTime RegistrationDateTime { get; set; }
public char RaceKitOptionId { get; set; }
public short RegistrationStatusId { get; set; }
public decimal Cost { get; set; }
public int CharityId { get; set; }
public decimal SponsorshipTarget { get; set; }
public virtual Charity Charity { get; set; } = null!;
public virtual RaceKitOption RaceKitOption { get; set; } = null!;
public virtual ICollection<RegistrationEvent> RegistrationEvents { get; set; } = new List<RegistrationEvent>();
public virtual RegistrationStatus RegistrationStatus { get; set; } = null!;
public virtual Runner Runner { get; set; } = null!;
public virtual ICollection<Sponsorship> Sponsorships { get; set; } = new List<Sponsorship>();
}

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
namespace IposiGospodDemo.Context;
public partial class RegistrationEvent
{
public int RegistrationEventId { get; set; }
public int RegistrationId { get; set; }
public string EventId { get; set; } = null!;
public short? BibNumber { get; set; }
public int? RaceTime { get; set; }
public virtual Event Event { get; set; } = null!;
public virtual Registration Registration { get; set; } = null!;
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
namespace IposiGospodDemo.Context;
public partial class RegistrationStatus
{
public short RegistrationStatusId { get; set; }
public string RegistrationStatus1 { get; set; } = null!;
public virtual ICollection<Registration> Registrations { get; set; } = new List<Registration>();
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
namespace IposiGospodDemo.Context;
public partial class Role
{
public char RoleId { get; set; }
public string RoleName { get; set; } = null!;
public virtual ICollection<User> Users { get; set; } = new List<User>();
}

View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
namespace IposiGospodDemo.Context;
public partial class Runner
{
public int RunnerId { get; set; }
public string Email { get; set; } = null!;
public string Gender { get; set; } = null!;
public DateTime? DateOfBirth { get; set; }
public string CountryCode { get; set; } = null!;
public virtual Country CountryCodeNavigation { get; set; } = null!;
public virtual User EmailNavigation { get; set; } = null!;
public virtual Gender GenderNavigation { get; set; } = null!;
public virtual ICollection<Registration> Registrations { get; set; } = new List<Registration>();
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
namespace IposiGospodDemo.Context;
public partial class Sponsorship
{
public int SponsorshipId { get; set; }
public string SponsorName { get; set; } = null!;
public int RegistrationId { get; set; }
public decimal Amount { get; set; }
public virtual Registration Registration { get; set; } = null!;
}

View File

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
namespace IposiGospodDemo.Context;
public partial class Staff
{
public int StaffId { get; set; }
public string FirstName { get; set; } = null!;
public string LastName { get; set; } = null!;
public DateOnly DateOfBirth { get; set; }
public char Gender { get; set; }
public int PositionId { get; set; }
public string Email { get; set; } = null!;
public string? Comments { get; set; }
public virtual Position Position { get; set; } = null!;
public virtual ICollection<Timesheet> Timesheets { get; set; } = new List<Timesheet>();
}

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
namespace IposiGospodDemo.Context;
public partial class Timesheet
{
public int TimesheetId { get; set; }
public int StaffId { get; set; }
public DateTime StartDateTime { get; set; }
public DateTime EndDateTime { get; set; }
public decimal PayAmount { get; set; }
public virtual Staff Staff { get; set; } = null!;
}

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
namespace IposiGospodDemo.Context;
public partial class User
{
public string Email { get; set; } = null!;
public string Password { get; set; } = null!;
public string? FirstName { get; set; }
public string? LastName { get; set; }
public char RoleId { get; set; }
public virtual Role Role { get; set; } = null!;
public virtual ICollection<Runner> Runners { get; set; } = new List<Runner>();
}

View File

@ -0,0 +1,379 @@
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
namespace IposiGospodDemo.Context;
public partial class User3Context : DbContext
{
public User3Context()
{
}
public User3Context(DbContextOptions<User3Context> options)
: base(options)
{
}
public virtual DbSet<Charity> Charities { get; set; }
public virtual DbSet<Country> Countries { get; set; }
public virtual DbSet<Event> Events { get; set; }
public virtual DbSet<EventType> EventTypes { get; set; }
public virtual DbSet<Gender> Genders { get; set; }
public virtual DbSet<Marathon> Marathons { get; set; }
public virtual DbSet<Position> Positions { get; set; }
public virtual DbSet<RaceKitOption> RaceKitOptions { get; set; }
public virtual DbSet<Registration> Registrations { get; set; }
public virtual DbSet<RegistrationEvent> RegistrationEvents { get; set; }
public virtual DbSet<RegistrationStatus> RegistrationStatuses { get; set; }
public virtual DbSet<Role> Roles { get; set; }
public virtual DbSet<Runner> Runners { get; set; }
public virtual DbSet<Sponsorship> Sponsorships { get; set; }
public virtual DbSet<Staff> Staff { get; set; }
public virtual DbSet<Timesheet> Timesheets { get; set; }
public virtual DbSet<User> Users { get; set; }
public virtual DbSet<Volunteer> Volunteers { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see https://go.microsoft.com/fwlink/?LinkId=723263.
=> optionsBuilder.UseNpgsql("Host=45.67.56.214;Port=5454;Database=user3;Username=user3;password=VOTfZ8PQ");
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Charity>(entity =>
{
entity.HasKey(e => e.CharityId).HasName("Charity_pkey");
entity.ToTable("Charity", "public3");
entity.Property(e => e.CharityDescription).HasMaxLength(2000);
entity.Property(e => e.CharityLogo).HasMaxLength(50);
entity.Property(e => e.CharityName).HasMaxLength(100);
});
modelBuilder.Entity<Country>(entity =>
{
entity.HasKey(e => e.CountryCode).HasName("Country_pkey");
entity.ToTable("Country", "public3");
entity.Property(e => e.CountryCode)
.HasMaxLength(3)
.IsFixedLength();
entity.Property(e => e.CountryFlag).HasMaxLength(100);
entity.Property(e => e.CountryName).HasMaxLength(100);
});
modelBuilder.Entity<Event>(entity =>
{
entity.HasKey(e => e.EventId).HasName("Event_pkey");
entity.ToTable("Event", "public3");
entity.Property(e => e.EventId)
.HasMaxLength(6)
.IsFixedLength();
entity.Property(e => e.Cost).HasPrecision(10, 2);
entity.Property(e => e.EventName).HasMaxLength(50);
entity.Property(e => e.EventTypeId)
.HasMaxLength(2)
.IsFixedLength();
entity.Property(e => e.StartDateTime).HasColumnType("timestamp without time zone");
entity.HasOne(d => d.EventType).WithMany(p => p.Events)
.HasForeignKey(d => d.EventTypeId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("Event_EventTypeId_fkey");
entity.HasOne(d => d.Marathon).WithMany(p => p.Events)
.HasForeignKey(d => d.MarathonId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("Event_MarathonId_fkey");
});
modelBuilder.Entity<EventType>(entity =>
{
entity.HasKey(e => e.EventTypeId).HasName("EventType_pkey");
entity.ToTable("EventType", "public3");
entity.Property(e => e.EventTypeId)
.HasMaxLength(2)
.IsFixedLength();
entity.Property(e => e.EventTypeName).HasMaxLength(50);
});
modelBuilder.Entity<Gender>(entity =>
{
entity.HasKey(e => e.Gender1).HasName("Gender_pkey");
entity.ToTable("Gender", "public3");
entity.Property(e => e.Gender1)
.HasMaxLength(10)
.HasColumnName("Gender");
});
modelBuilder.Entity<Marathon>(entity =>
{
entity.HasKey(e => e.MarathonId).HasName("Marathon_pkey");
entity.ToTable("Marathon", "public3");
entity.Property(e => e.MarathonId).ValueGeneratedNever();
entity.Property(e => e.CityName).HasMaxLength(80);
entity.Property(e => e.CountryCode)
.HasMaxLength(3)
.IsFixedLength();
entity.Property(e => e.MarathonName).HasMaxLength(80);
entity.HasOne(d => d.CountryCodeNavigation).WithMany(p => p.Marathons)
.HasForeignKey(d => d.CountryCode)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("Marathon_CountryCode_fkey");
});
modelBuilder.Entity<Position>(entity =>
{
entity.HasKey(e => e.PositionId).HasName("Position_pkey");
entity.ToTable("Position", "public3");
entity.Property(e => e.PayRate).HasPrecision(10, 2);
entity.Property(e => e.PositionDescription).HasMaxLength(255);
entity.Property(e => e.PositionName).HasMaxLength(100);
});
modelBuilder.Entity<RaceKitOption>(entity =>
{
entity.HasKey(e => e.RaceKitOptionId).HasName("RaceKitOption_pkey");
entity.ToTable("RaceKitOption", "public3");
entity.Property(e => e.RaceKitOptionId)
.HasMaxLength(1)
.ValueGeneratedNever();
entity.Property(e => e.Cost).HasPrecision(10, 2);
entity.Property(e => e.RaceKitOption1)
.HasMaxLength(80)
.HasColumnName("RaceKitOption");
});
modelBuilder.Entity<Registration>(entity =>
{
entity.HasKey(e => e.RegistrationId).HasName("Registration_pkey");
entity.ToTable("Registration", "public3");
entity.Property(e => e.Cost).HasPrecision(10, 2);
entity.Property(e => e.RaceKitOptionId).HasMaxLength(1);
entity.Property(e => e.RegistrationDateTime).HasColumnType("timestamp without time zone");
entity.Property(e => e.SponsorshipTarget).HasPrecision(10, 2);
entity.HasOne(d => d.Charity).WithMany(p => p.Registrations)
.HasForeignKey(d => d.CharityId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("Registration_CharityId_fkey");
entity.HasOne(d => d.RaceKitOption).WithMany(p => p.Registrations)
.HasForeignKey(d => d.RaceKitOptionId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("Registration_RaceKitOptionId_fkey");
entity.HasOne(d => d.RegistrationStatus).WithMany(p => p.Registrations)
.HasForeignKey(d => d.RegistrationStatusId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("Registration_RegistrationStatusId_fkey");
entity.HasOne(d => d.Runner).WithMany(p => p.Registrations)
.HasForeignKey(d => d.RunnerId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("Registration_RunnerId_fkey");
});
modelBuilder.Entity<RegistrationEvent>(entity =>
{
entity.HasKey(e => e.RegistrationEventId).HasName("RegistrationEvent_pkey");
entity.ToTable("RegistrationEvent", "public3");
entity.Property(e => e.EventId)
.HasMaxLength(6)
.IsFixedLength();
entity.HasOne(d => d.Event).WithMany(p => p.RegistrationEvents)
.HasForeignKey(d => d.EventId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("RegistrationEvent_EventId_fkey");
entity.HasOne(d => d.Registration).WithMany(p => p.RegistrationEvents)
.HasForeignKey(d => d.RegistrationId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("RegistrationEvent_RegistrationId_fkey");
});
modelBuilder.Entity<RegistrationStatus>(entity =>
{
entity.HasKey(e => e.RegistrationStatusId).HasName("RegistrationStatus_pkey");
entity.ToTable("RegistrationStatus", "public3");
entity.Property(e => e.RegistrationStatusId).ValueGeneratedNever();
entity.Property(e => e.RegistrationStatus1)
.HasMaxLength(80)
.HasColumnName("RegistrationStatus");
});
modelBuilder.Entity<Role>(entity =>
{
entity.HasKey(e => e.RoleId).HasName("Role_pkey");
entity.ToTable("Role", "public3");
entity.Property(e => e.RoleId)
.HasMaxLength(1)
.ValueGeneratedNever();
entity.Property(e => e.RoleName).HasMaxLength(50);
});
modelBuilder.Entity<Runner>(entity =>
{
entity.HasKey(e => e.RunnerId).HasName("Runner_pkey");
entity.ToTable("Runner", "public3");
entity.Property(e => e.CountryCode)
.HasMaxLength(3)
.IsFixedLength();
entity.Property(e => e.DateOfBirth).HasColumnType("timestamp without time zone");
entity.Property(e => e.Email).HasMaxLength(100);
entity.Property(e => e.Gender).HasMaxLength(10);
entity.HasOne(d => d.CountryCodeNavigation).WithMany(p => p.Runners)
.HasForeignKey(d => d.CountryCode)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("Runner_CountryCode_fkey");
entity.HasOne(d => d.EmailNavigation).WithMany(p => p.Runners)
.HasForeignKey(d => d.Email)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("Runner_Email_fkey");
entity.HasOne(d => d.GenderNavigation).WithMany(p => p.Runners)
.HasForeignKey(d => d.Gender)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("Runner_Gender_fkey");
});
modelBuilder.Entity<Sponsorship>(entity =>
{
entity.HasKey(e => e.SponsorshipId).HasName("Sponsorship_pkey");
entity.ToTable("Sponsorship", "public3");
entity.Property(e => e.Amount).HasPrecision(10, 2);
entity.Property(e => e.SponsorName).HasMaxLength(150);
entity.HasOne(d => d.Registration).WithMany(p => p.Sponsorships)
.HasForeignKey(d => d.RegistrationId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("Sponsorship_RegistrationId_fkey");
});
modelBuilder.Entity<Staff>(entity =>
{
entity.HasKey(e => e.StaffId).HasName("Staff_pkey");
entity.ToTable("Staff", "public3");
entity.Property(e => e.Email).HasMaxLength(100);
entity.Property(e => e.FirstName).HasMaxLength(100);
entity.Property(e => e.Gender).HasMaxLength(1);
entity.Property(e => e.LastName).HasMaxLength(100);
entity.HasOne(d => d.Position).WithMany(p => p.Staff)
.HasForeignKey(d => d.PositionId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("Staff_PositionId_fkey");
});
modelBuilder.Entity<Timesheet>(entity =>
{
entity.HasKey(e => e.TimesheetId).HasName("Timesheet_pkey");
entity.ToTable("Timesheet", "public3");
entity.Property(e => e.EndDateTime).HasColumnType("timestamp without time zone");
entity.Property(e => e.PayAmount).HasPrecision(10, 2);
entity.Property(e => e.StartDateTime).HasColumnType("timestamp without time zone");
entity.HasOne(d => d.Staff).WithMany(p => p.Timesheets)
.HasForeignKey(d => d.StaffId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("Timesheet_StaffId_fkey");
});
modelBuilder.Entity<User>(entity =>
{
entity.HasKey(e => e.Email).HasName("User_pkey");
entity.ToTable("User", "public3");
entity.Property(e => e.Email).HasMaxLength(100);
entity.Property(e => e.FirstName).HasMaxLength(80);
entity.Property(e => e.LastName).HasMaxLength(80);
entity.Property(e => e.Password).HasMaxLength(100);
entity.Property(e => e.RoleId).HasMaxLength(1);
entity.HasOne(d => d.Role).WithMany(p => p.Users)
.HasForeignKey(d => d.RoleId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("User_RoleId_fkey");
});
modelBuilder.Entity<Volunteer>(entity =>
{
entity.HasKey(e => e.VolunteerId).HasName("Volunteer_pkey");
entity.ToTable("Volunteer", "public3");
entity.Property(e => e.CountryCode)
.HasMaxLength(3)
.IsFixedLength();
entity.Property(e => e.FirstName).HasMaxLength(80);
entity.Property(e => e.Gender).HasMaxLength(10);
entity.Property(e => e.LastName).HasMaxLength(80);
entity.HasOne(d => d.CountryCodeNavigation).WithMany(p => p.Volunteers)
.HasForeignKey(d => d.CountryCode)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("Volunteer_CountryCode_fkey");
entity.HasOne(d => d.GenderNavigation).WithMany(p => p.Volunteers)
.HasForeignKey(d => d.Gender)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("Volunteer_Gender_fkey");
});
OnModelCreatingPartial(modelBuilder);
}
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
}

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
namespace IposiGospodDemo.Context;
public partial class Volunteer
{
public int VolunteerId { get; set; }
public string? FirstName { get; set; }
public string? LastName { get; set; }
public string CountryCode { get; set; } = null!;
public string Gender { get; set; } = null!;
public virtual Country CountryCodeNavigation { get; set; } = null!;
public virtual Gender GenderNavigation { get; set; } = null!;
}

View File

@ -0,0 +1,34 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
<ApplicationManifest>app.manifest</ApplicationManifest>
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
</PropertyGroup>
<ItemGroup>
<Folder Include="Models\"/>
<AvaloniaResource Include="Assets\**"/>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="11.2.1"/>
<PackageReference Include="Avalonia.Desktop" Version="11.2.1"/>
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.2.1"/>
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.2.1"/>
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Include="Avalonia.Diagnostics" Version="11.2.1">
<IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets>
<PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets>
</PackageReference>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.1"/>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.3" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,21 @@
using Avalonia;
using System;
namespace IposiGospodDemo;
sealed class Program
{
// Initialization code. Don't use any Avalonia, third-party APIs or any
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
// yet and stuff might break.
[STAThread]
public static void Main(string[] args) => BuildAvaloniaApp()
.StartWithClassicDesktopLifetime(args);
// Avalonia configuration, don't remove; also used by visual designer.
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>()
.UsePlatformDetect()
.WithInterFont()
.LogToTrace();
}

View File

@ -0,0 +1,30 @@
using System;
using Avalonia.Controls;
using Avalonia.Controls.Templates;
using IposiGospodDemo.ViewModels;
namespace IposiGospodDemo;
public class ViewLocator : IDataTemplate
{
public Control? Build(object? param)
{
if (param is null)
return null;
var name = param.GetType().FullName!.Replace("ViewModel", "View", StringComparison.Ordinal);
var type = Type.GetType(name);
if (type != null)
{
return (Control)Activator.CreateInstance(type)!;
}
return new TextBlock { Text = "Not Found: " + name };
}
public bool Match(object? data)
{
return data is ViewModelBase;
}
}

View File

@ -0,0 +1,6 @@
namespace IposiGospodDemo.ViewModels;
public partial class MainWindowViewModel : ViewModelBase
{
public string Greeting { get; } = "Welcome to Avalonia!";
}

View File

@ -0,0 +1,7 @@
using CommunityToolkit.Mvvm.ComponentModel;
namespace IposiGospodDemo.ViewModels;
public class ViewModelBase : ObservableObject
{
}

View File

@ -0,0 +1,20 @@
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="using:IposiGospodDemo.ViewModels"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="IposiGospodDemo.Views.MainWindow"
x:DataType="vm:MainWindowViewModel"
Icon="/Assets/avalonia-logo.ico"
Title="IposiGospodDemo">
<Design.DataContext>
<!-- This only sets the DataContext for the previewer in an IDE,
to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) -->
<vm:MainWindowViewModel/>
</Design.DataContext>
<TextBlock Text="{Binding Greeting}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Window>

View File

@ -0,0 +1,11 @@
using Avalonia.Controls;
namespace IposiGospodDemo.Views;
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<!-- This manifest is used on Windows only.
Don't remove it as it might cause problems with window transparency and embedded controls.
For more details visit https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests -->
<assemblyIdentity version="1.0.0.0" name="IposiGospodDemo.Desktop"/>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- A list of the Windows versions that this application has been tested on
and is designed to work with. Uncomment the appropriate elements
and Windows will automatically select the most compatible environment. -->
<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
</application>
</compatibility>
</assembly>