WIP: Project setup with .NET backend and Next.js frontend

This commit is contained in:
Denis Urs Rudolph
2026-04-03 20:55:58 +02:00
parent fbfa367c16
commit 8bfd49e0ab
34 changed files with 2553 additions and 0 deletions
+53
View File
@@ -0,0 +1,53 @@
# .NET Core
bin/
obj/
*.user
*.userosscache
*.suo
*.cache
*.dll
*.exe
*.pdb
*.db
# Visual Studio
.vs/
*.suo
*.user
# Rider
.idea/
# VS Code
.vscode/
# Environment
.env
appsettings.Development.json
appsettings.Local.json
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
build/
bld/
[Bb]in/
[Oo]bj/
[Oo]ut/
# NuGet
*.nupkg
**/packages/*
!**/packages/build/
# Test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# Entity Framework
Migrations/*.Designer.cs
Migrations/*ModelSnapshot.cs
@@ -0,0 +1,329 @@
// <auto-generated />
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using RacePlannerApi.Data;
#nullable disable
namespace RacePlannerApi.Data.Migrations
{
[DbContext(typeof(RacePlannerDbContext))]
[Migration("20260403185515_InitialCreate")]
partial class InitialCreate
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "10.0.5")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("RacePlannerApi.Models.Announcement", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid>("AuthorId")
.HasColumnType("uuid");
b.Property<string>("Content")
.IsRequired()
.HasMaxLength(5000)
.HasColumnType("character varying(5000)");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<Guid>("EventId")
.HasColumnType("uuid");
b.Property<bool>("IsPublished")
.HasColumnType("boolean");
b.Property<string>("Title")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<DateTime?>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("AuthorId");
b.HasIndex("CreatedAt");
b.HasIndex("EventId");
b.ToTable("Announcements");
});
modelBuilder.Entity("RacePlannerApi.Models.Event", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Category")
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(2000)
.HasColumnType("character varying(2000)");
b.Property<DateTime>("EventDate")
.HasColumnType("timestamp with time zone");
b.Property<string>("Location")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("character varying(500)");
b.Property<int?>("MaxParticipants")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<Guid>("OrganizerId")
.HasColumnType("uuid");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("text");
b.PrimitiveCollection<List<string>>("Tags")
.IsRequired()
.HasColumnType("text[]");
b.Property<DateTime>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("Category");
b.HasIndex("EventDate");
b.HasIndex("OrganizerId");
b.HasIndex("Status");
b.ToTable("Events");
});
modelBuilder.Entity("RacePlannerApi.Models.Payment", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<decimal>("Amount")
.HasPrecision(18, 2)
.HasColumnType("numeric(18,2)");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Method")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Notes")
.HasMaxLength(500)
.HasColumnType("character varying(500)");
b.Property<DateTime>("PaymentDate")
.HasColumnType("timestamp with time zone");
b.Property<Guid>("RegistrationId")
.HasColumnType("uuid");
b.Property<string>("TransactionId")
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.HasKey("Id");
b.HasIndex("PaymentDate");
b.HasIndex("RegistrationId");
b.ToTable("Payments");
});
modelBuilder.Entity("RacePlannerApi.Models.Registration", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Category")
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("EmergencyContact")
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<Guid>("EventId")
.HasColumnType("uuid");
b.Property<Guid>("ParticipantId")
.HasColumnType("uuid");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime?>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("ParticipantId");
b.HasIndex("Status");
b.HasIndex("EventId", "ParticipantId")
.IsUnique();
b.ToTable("Registrations");
});
modelBuilder.Entity("RacePlannerApi.Models.User", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<string>("PasswordHash")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Role")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("Email")
.IsUnique();
b.ToTable("Users");
});
modelBuilder.Entity("RacePlannerApi.Models.Announcement", b =>
{
b.HasOne("RacePlannerApi.Models.User", "Author")
.WithMany()
.HasForeignKey("AuthorId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("RacePlannerApi.Models.Event", "Event")
.WithMany("Announcements")
.HasForeignKey("EventId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Author");
b.Navigation("Event");
});
modelBuilder.Entity("RacePlannerApi.Models.Event", b =>
{
b.HasOne("RacePlannerApi.Models.User", "Organizer")
.WithMany("OrganizedEvents")
.HasForeignKey("OrganizerId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Organizer");
});
modelBuilder.Entity("RacePlannerApi.Models.Payment", b =>
{
b.HasOne("RacePlannerApi.Models.Registration", "Registration")
.WithMany("Payments")
.HasForeignKey("RegistrationId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Registration");
});
modelBuilder.Entity("RacePlannerApi.Models.Registration", b =>
{
b.HasOne("RacePlannerApi.Models.Event", "Event")
.WithMany("Registrations")
.HasForeignKey("EventId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("RacePlannerApi.Models.User", "Participant")
.WithMany("Registrations")
.HasForeignKey("ParticipantId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Event");
b.Navigation("Participant");
});
modelBuilder.Entity("RacePlannerApi.Models.Event", b =>
{
b.Navigation("Announcements");
b.Navigation("Registrations");
});
modelBuilder.Entity("RacePlannerApi.Models.Registration", b =>
{
b.Navigation("Payments");
});
modelBuilder.Entity("RacePlannerApi.Models.User", b =>
{
b.Navigation("OrganizedEvents");
b.Navigation("Registrations");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,230 @@
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace RacePlannerApi.Data.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Users",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Email = table.Column<string>(type: "text", nullable: false),
PasswordHash = table.Column<string>(type: "text", nullable: false),
Name = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
Role = table.Column<string>(type: "text", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Users", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Events",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Name = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: false),
Description = table.Column<string>(type: "character varying(2000)", maxLength: 2000, nullable: false),
EventDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
Location = table.Column<string>(type: "character varying(500)", maxLength: 500, nullable: false),
Status = table.Column<string>(type: "text", nullable: false),
Category = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: true),
Tags = table.Column<List<string>>(type: "text[]", nullable: false),
MaxParticipants = table.Column<int>(type: "integer", nullable: true),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
OrganizerId = table.Column<Guid>(type: "uuid", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Events", x => x.Id);
table.ForeignKey(
name: "FK_Events_Users_OrganizerId",
column: x => x.OrganizerId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "Announcements",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Title = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: false),
Content = table.Column<string>(type: "character varying(5000)", maxLength: 5000, nullable: false),
EventId = table.Column<Guid>(type: "uuid", nullable: false),
AuthorId = table.Column<Guid>(type: "uuid", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
IsPublished = table.Column<bool>(type: "boolean", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Announcements", x => x.Id);
table.ForeignKey(
name: "FK_Announcements_Events_EventId",
column: x => x.EventId,
principalTable: "Events",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Announcements_Users_AuthorId",
column: x => x.AuthorId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "Registrations",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
EventId = table.Column<Guid>(type: "uuid", nullable: false),
ParticipantId = table.Column<Guid>(type: "uuid", nullable: false),
Status = table.Column<string>(type: "text", nullable: false),
Category = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: true),
EmergencyContact = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: true),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Registrations", x => x.Id);
table.ForeignKey(
name: "FK_Registrations_Events_EventId",
column: x => x.EventId,
principalTable: "Events",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Registrations_Users_ParticipantId",
column: x => x.ParticipantId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "Payments",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
RegistrationId = table.Column<Guid>(type: "uuid", nullable: false),
Amount = table.Column<decimal>(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false),
Method = table.Column<string>(type: "text", nullable: false),
TransactionId = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: true),
Notes = table.Column<string>(type: "character varying(500)", maxLength: 500, nullable: true),
PaymentDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Payments", x => x.Id);
table.ForeignKey(
name: "FK_Payments_Registrations_RegistrationId",
column: x => x.RegistrationId,
principalTable: "Registrations",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Announcements_AuthorId",
table: "Announcements",
column: "AuthorId");
migrationBuilder.CreateIndex(
name: "IX_Announcements_CreatedAt",
table: "Announcements",
column: "CreatedAt");
migrationBuilder.CreateIndex(
name: "IX_Announcements_EventId",
table: "Announcements",
column: "EventId");
migrationBuilder.CreateIndex(
name: "IX_Events_Category",
table: "Events",
column: "Category");
migrationBuilder.CreateIndex(
name: "IX_Events_EventDate",
table: "Events",
column: "EventDate");
migrationBuilder.CreateIndex(
name: "IX_Events_OrganizerId",
table: "Events",
column: "OrganizerId");
migrationBuilder.CreateIndex(
name: "IX_Events_Status",
table: "Events",
column: "Status");
migrationBuilder.CreateIndex(
name: "IX_Payments_PaymentDate",
table: "Payments",
column: "PaymentDate");
migrationBuilder.CreateIndex(
name: "IX_Payments_RegistrationId",
table: "Payments",
column: "RegistrationId");
migrationBuilder.CreateIndex(
name: "IX_Registrations_EventId_ParticipantId",
table: "Registrations",
columns: new[] { "EventId", "ParticipantId" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Registrations_ParticipantId",
table: "Registrations",
column: "ParticipantId");
migrationBuilder.CreateIndex(
name: "IX_Registrations_Status",
table: "Registrations",
column: "Status");
migrationBuilder.CreateIndex(
name: "IX_Users_Email",
table: "Users",
column: "Email",
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Announcements");
migrationBuilder.DropTable(
name: "Payments");
migrationBuilder.DropTable(
name: "Registrations");
migrationBuilder.DropTable(
name: "Events");
migrationBuilder.DropTable(
name: "Users");
}
}
}
@@ -0,0 +1,326 @@
// <auto-generated />
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using RacePlannerApi.Data;
#nullable disable
namespace RacePlannerApi.Data.Migrations
{
[DbContext(typeof(RacePlannerDbContext))]
partial class RacePlannerDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "10.0.5")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("RacePlannerApi.Models.Announcement", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid>("AuthorId")
.HasColumnType("uuid");
b.Property<string>("Content")
.IsRequired()
.HasMaxLength(5000)
.HasColumnType("character varying(5000)");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<Guid>("EventId")
.HasColumnType("uuid");
b.Property<bool>("IsPublished")
.HasColumnType("boolean");
b.Property<string>("Title")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<DateTime?>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("AuthorId");
b.HasIndex("CreatedAt");
b.HasIndex("EventId");
b.ToTable("Announcements");
});
modelBuilder.Entity("RacePlannerApi.Models.Event", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Category")
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(2000)
.HasColumnType("character varying(2000)");
b.Property<DateTime>("EventDate")
.HasColumnType("timestamp with time zone");
b.Property<string>("Location")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("character varying(500)");
b.Property<int?>("MaxParticipants")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<Guid>("OrganizerId")
.HasColumnType("uuid");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("text");
b.PrimitiveCollection<List<string>>("Tags")
.IsRequired()
.HasColumnType("text[]");
b.Property<DateTime>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("Category");
b.HasIndex("EventDate");
b.HasIndex("OrganizerId");
b.HasIndex("Status");
b.ToTable("Events");
});
modelBuilder.Entity("RacePlannerApi.Models.Payment", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<decimal>("Amount")
.HasPrecision(18, 2)
.HasColumnType("numeric(18,2)");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Method")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Notes")
.HasMaxLength(500)
.HasColumnType("character varying(500)");
b.Property<DateTime>("PaymentDate")
.HasColumnType("timestamp with time zone");
b.Property<Guid>("RegistrationId")
.HasColumnType("uuid");
b.Property<string>("TransactionId")
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.HasKey("Id");
b.HasIndex("PaymentDate");
b.HasIndex("RegistrationId");
b.ToTable("Payments");
});
modelBuilder.Entity("RacePlannerApi.Models.Registration", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Category")
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("EmergencyContact")
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<Guid>("EventId")
.HasColumnType("uuid");
b.Property<Guid>("ParticipantId")
.HasColumnType("uuid");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime?>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("ParticipantId");
b.HasIndex("Status");
b.HasIndex("EventId", "ParticipantId")
.IsUnique();
b.ToTable("Registrations");
});
modelBuilder.Entity("RacePlannerApi.Models.User", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property<string>("PasswordHash")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Role")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("Email")
.IsUnique();
b.ToTable("Users");
});
modelBuilder.Entity("RacePlannerApi.Models.Announcement", b =>
{
b.HasOne("RacePlannerApi.Models.User", "Author")
.WithMany()
.HasForeignKey("AuthorId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("RacePlannerApi.Models.Event", "Event")
.WithMany("Announcements")
.HasForeignKey("EventId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Author");
b.Navigation("Event");
});
modelBuilder.Entity("RacePlannerApi.Models.Event", b =>
{
b.HasOne("RacePlannerApi.Models.User", "Organizer")
.WithMany("OrganizedEvents")
.HasForeignKey("OrganizerId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Organizer");
});
modelBuilder.Entity("RacePlannerApi.Models.Payment", b =>
{
b.HasOne("RacePlannerApi.Models.Registration", "Registration")
.WithMany("Payments")
.HasForeignKey("RegistrationId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Registration");
});
modelBuilder.Entity("RacePlannerApi.Models.Registration", b =>
{
b.HasOne("RacePlannerApi.Models.Event", "Event")
.WithMany("Registrations")
.HasForeignKey("EventId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("RacePlannerApi.Models.User", "Participant")
.WithMany("Registrations")
.HasForeignKey("ParticipantId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Event");
b.Navigation("Participant");
});
modelBuilder.Entity("RacePlannerApi.Models.Event", b =>
{
b.Navigation("Announcements");
b.Navigation("Registrations");
});
modelBuilder.Entity("RacePlannerApi.Models.Registration", b =>
{
b.Navigation("Payments");
});
modelBuilder.Entity("RacePlannerApi.Models.User", b =>
{
b.Navigation("OrganizedEvents");
b.Navigation("Registrations");
});
#pragma warning restore 612, 618
}
}
}
+94
View File
@@ -0,0 +1,94 @@
using Microsoft.EntityFrameworkCore;
using RacePlannerApi.Models;
namespace RacePlannerApi.Data;
public class RacePlannerDbContext : DbContext
{
public RacePlannerDbContext(DbContextOptions<RacePlannerDbContext> options)
: base(options)
{
}
public DbSet<User> Users { get; set; }
public DbSet<Event> Events { get; set; }
public DbSet<Registration> Registrations { get; set; }
public DbSet<Payment> Payments { get; set; }
public DbSet<Announcement> Announcements { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
// User configurations
modelBuilder.Entity<User>(entity =>
{
entity.HasIndex(u => u.Email).IsUnique();
entity.Property(u => u.Role).HasConversion<string>();
});
// Event configurations
modelBuilder.Entity<Event>(entity =>
{
entity.HasIndex(e => e.EventDate);
entity.HasIndex(e => e.Status);
entity.HasIndex(e => e.Category);
entity.Property(e => e.Status).HasConversion<string>();
entity.Property(e => e.Tags).HasColumnType("text[]");
entity.HasOne(e => e.Organizer)
.WithMany(u => u.OrganizedEvents)
.HasForeignKey(e => e.OrganizerId)
.OnDelete(DeleteBehavior.Restrict);
});
// Registration configurations
modelBuilder.Entity<Registration>(entity =>
{
entity.HasIndex(r => new { r.EventId, r.ParticipantId }).IsUnique();
entity.HasIndex(r => r.Status);
entity.Property(r => r.Status).HasConversion<string>();
entity.HasOne(r => r.Event)
.WithMany(e => e.Registrations)
.HasForeignKey(r => r.EventId)
.OnDelete(DeleteBehavior.Cascade);
entity.HasOne(r => r.Participant)
.WithMany(u => u.Registrations)
.HasForeignKey(r => r.ParticipantId)
.OnDelete(DeleteBehavior.Restrict);
});
// Payment configurations
modelBuilder.Entity<Payment>(entity =>
{
entity.HasIndex(p => p.RegistrationId);
entity.HasIndex(p => p.PaymentDate);
entity.Property(p => p.Method).HasConversion<string>();
entity.Property(p => p.Amount).HasPrecision(18, 2); // For decimal Amount
entity.HasOne(p => p.Registration)
.WithMany(r => r.Payments)
.HasForeignKey(p => p.RegistrationId)
.OnDelete(DeleteBehavior.Cascade);
});
// Announcement configurations
modelBuilder.Entity<Announcement>(entity =>
{
entity.HasIndex(a => a.EventId);
entity.HasIndex(a => a.CreatedAt);
entity.HasOne(a => a.Event)
.WithMany(e => e.Announcements)
.HasForeignKey(a => a.EventId)
.OnDelete(DeleteBehavior.Cascade);
entity.HasOne(a => a.Author)
.WithMany()
.HasForeignKey(a => a.AuthorId)
.OnDelete(DeleteBehavior.Restrict);
});
}
}
+36
View File
@@ -0,0 +1,36 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace RacePlannerApi.Models;
public class Announcement
{
[Key]
public Guid Id { get; set; } = Guid.NewGuid();
[Required]
[MaxLength(200)]
public string Title { get; set; } = string.Empty;
[Required]
[MaxLength(5000)]
public string Content { get; set; } = string.Empty;
[Required]
public Guid EventId { get; set; }
[ForeignKey("EventId")]
public Event Event { get; set; } = null!;
[Required]
public Guid AuthorId { get; set; }
[ForeignKey("AuthorId")]
public User Author { get; set; } = null!;
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
public DateTime? UpdatedAt { get; set; }
public bool IsPublished { get; set; } = true;
}
+56
View File
@@ -0,0 +1,56 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace RacePlannerApi.Models;
public class Event
{
[Key]
public Guid Id { get; set; } = Guid.NewGuid();
[Required]
[MaxLength(200)]
public string Name { get; set; } = string.Empty;
[MaxLength(2000)]
public string Description { get; set; } = string.Empty;
[Required]
public DateTime EventDate { get; set; }
[Required]
[MaxLength(500)]
public string Location { get; set; } = string.Empty;
public EventStatus Status { get; set; } = EventStatus.Draft;
[MaxLength(100)]
public string? Category { get; set; }
public List<string> Tags { get; set; } = new List<string>();
public int? MaxParticipants { get; set; }
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
// Foreign keys
[Required]
public Guid OrganizerId { get; set; }
[ForeignKey("OrganizerId")]
public User Organizer { get; set; } = null!;
// Navigation properties
public ICollection<Registration> Registrations { get; set; } = new List<Registration>();
public ICollection<Announcement> Announcements { get; set; } = new List<Announcement>();
}
public enum EventStatus
{
Draft,
Published,
Cancelled,
Completed
}
+39
View File
@@ -0,0 +1,39 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace RacePlannerApi.Models;
public class Payment
{
[Key]
public Guid Id { get; set; } = Guid.NewGuid();
[Required]
public Guid RegistrationId { get; set; }
[ForeignKey("RegistrationId")]
public Registration Registration { get; set; } = null!;
[Required]
public decimal Amount { get; set; }
[Required]
public PaymentMethod Method { get; set; }
[MaxLength(100)]
public string? TransactionId { get; set; }
[MaxLength(500)]
public string? Notes { get; set; }
public DateTime PaymentDate { get; set; } = DateTime.UtcNow;
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
}
public enum PaymentMethod
{
Cash,
Online,
Transfer
}
+45
View File
@@ -0,0 +1,45 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace RacePlannerApi.Models;
public class Registration
{
[Key]
public Guid Id { get; set; } = Guid.NewGuid();
[Required]
public Guid EventId { get; set; }
[ForeignKey("EventId")]
public Event Event { get; set; } = null!;
[Required]
public Guid ParticipantId { get; set; }
[ForeignKey("ParticipantId")]
public User Participant { get; set; } = null!;
public RegistrationStatus Status { get; set; } = RegistrationStatus.Pending;
[MaxLength(100)]
public string? Category { get; set; }
[MaxLength(200)]
public string? EmergencyContact { get; set; }
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
public DateTime? UpdatedAt { get; set; }
// Navigation properties
public ICollection<Payment> Payments { get; set; } = new List<Payment>();
}
public enum RegistrationStatus
{
Pending,
Confirmed,
Cancelled,
Completed
}
+35
View File
@@ -0,0 +1,35 @@
using System.ComponentModel.DataAnnotations;
namespace RacePlannerApi.Models;
public class User
{
[Key]
public Guid Id { get; set; } = Guid.NewGuid();
[Required]
[EmailAddress]
public string Email { get; set; } = string.Empty;
[Required]
public string PasswordHash { get; set; } = string.Empty;
[Required]
[MaxLength(100)]
public string Name { get; set; } = string.Empty;
[Required]
public UserRole Role { get; set; } = UserRole.Participant;
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
// Navigation properties
public ICollection<Event> OrganizedEvents { get; set; } = new List<Event>();
public ICollection<Registration> Registrations { get; set; } = new List<Registration>();
}
public enum UserRole
{
Participant,
Organizer
}
+47
View File
@@ -0,0 +1,47 @@
using Microsoft.EntityFrameworkCore;
using RacePlannerApi.Data;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddOpenApi();
// Configure Entity Framework Core with PostgreSQL
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection")
?? "Host=localhost;Database=RacePlanner;Username=postgres;Password=postgres";
builder.Services.AddDbContext<RacePlannerDbContext>(options =>
options.UseNpgsql(connectionString));
// Add CORS for frontend
builder.Services.AddCors(options =>
{
options.AddPolicy("AllowFrontend", policy =>
{
policy.WithOrigins("http://localhost:3000")
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials();
});
});
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.MapOpenApi();
}
app.UseHttpsRedirection();
// Apply CORS
app.UseCors("AllowFrontend");
app.UseAuthorization();
app.MapControllers();
app.Run();
+23
View File
@@ -0,0 +1,23 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "http://localhost:5123",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "https://localhost:7269;http://localhost:5123",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
+18
View File
@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.0.1" />
</ItemGroup>
</Project>
+6
View File
@@ -0,0 +1,6 @@
@RacePlannerApi_HostAddress = http://localhost:5123
GET {{RacePlannerApi_HostAddress}}/weatherforecast/
Accept: application/json
###
+9
View File
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}