GuestLog - StayEntry - Initial Implementation

- Added new entity "StayEntry" to log stays of guests.
- Added pages for StayEntry management (List and creation).
- New DataList for PaymentMethods.
- Other general changes and improvements.
This commit is contained in:
2026-08-15 19:33:32 +02:00
parent ec7efd867b
commit 6dc2d2426b
29 changed files with 1348 additions and 30 deletions
@@ -0,0 +1,8 @@
namespace Somnia.GuestLog.Infrastructure;
public static class DbConsts
{
public const string DbType_Timestamptz = "timestamp with time zone";
public const string DbType_Timestamptz_0 = "timestamp(0) with time zone";
public const string DbType_Timestamptz_3 = "timestamp(3) with time zone";
}
@@ -0,0 +1,45 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Somnia.GuestLog.Models.Entities;
namespace Somnia.GuestLog.Infrastructure.EntityConfigs;
public class StayEntryEntityConfig : IEntityTypeConfiguration<StayEntry>
{
public void Configure(EntityTypeBuilder<StayEntry> builder)
{
builder.ToTable("StayEntry");
//PK
builder.HasKey(e => e.Id);
builder.Property(e => e.Id)
.IsRequired()
.UseIdentityByDefaultColumn();
builder.Property(e => e.DateIn)
.IsRequired()
.HasColumnType(DbConsts.DbType_Timestamptz_0);
builder.Property(e => e.DateOut)
.IsRequired()
.HasColumnType(DbConsts.DbType_Timestamptz_0);
builder.Property(e => e.RoomNumber)
.HasMaxLength(32);
builder.Property(e => e.PaymentMethod)
.IsRequired()
.HasMaxLength(5);
builder.Property(e => e.CreateTime)
.IsRequired()
.HasColumnType(DbConsts.DbType_Timestamptz);
builder.Property(e => e.UpdateTime)
.IsRequired()
.HasColumnType(DbConsts.DbType_Timestamptz);
builder.HasMany(e => e.GuestDocuments)
.WithMany();
}
}
@@ -11,11 +11,13 @@ public partial class GuestLogContext : DbContext
{ }
public DbSet<GuestDocument> GuestDocuments { get; set; }
public DbSet<StayEntry> StayEntries { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.ApplyConfiguration<GuestDocument>(new GuestDocumentEntityConfig());
modelBuilder.ApplyConfiguration<StayEntry>(new StayEntryEntityConfig());
OnModelCreatingPartial(modelBuilder);
base.OnModelCreating(modelBuilder);
@@ -0,0 +1,191 @@
// <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 Somnia.GuestLog.Infrastructure;
#nullable disable
namespace Somnia.GuestLog.Infrastructure.Migrations
{
[DbContext(typeof(GuestLogContext))]
[Migration("20260813085339_AddTable_StayEntry")]
partial class AddTable_StayEntry
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "10.0.7")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("GuestDocumentStayEntry", b =>
{
b.Property<long>("StayEntryId")
.HasColumnType("bigint");
b.Property<string>("GuestDocumentsDocumentType")
.HasColumnType("character varying(8)");
b.Property<string>("GuestDocumentsDocumentNum")
.HasColumnType("character varying(64)");
b.HasKey("StayEntryId", "GuestDocumentsDocumentType", "GuestDocumentsDocumentNum");
b.HasIndex("GuestDocumentsDocumentType", "GuestDocumentsDocumentNum");
b.ToTable("GuestDocumentStayEntry");
});
modelBuilder.Entity("Somnia.GuestLog.Models.Entities.GuestDocument", b =>
{
b.Property<string>("DocumentType")
.HasMaxLength(8)
.HasColumnType("character varying(8)");
b.Property<string>("DocumentNum")
.HasMaxLength(64)
.HasColumnType("character varying(64)");
b.Property<DateOnly>("BirthDate")
.HasColumnType("date");
b.Property<DateTime>("CreateTime")
.HasColumnType("timestamp with time zone");
b.Property<string>("EmailAddress")
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("Gender")
.HasMaxLength(1)
.HasColumnType("character varying(1)");
b.Property<DateOnly>("IssueDate")
.HasColumnType("date");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("character varying(64)");
b.Property<string>("Nationality")
.IsRequired()
.HasMaxLength(3)
.HasColumnType("character varying(3)");
b.Property<string>("PhoneNumber")
.HasMaxLength(32)
.HasColumnType("character varying(32)");
b.Property<string>("SupportNum")
.HasMaxLength(10)
.HasColumnType("character varying(10)");
b.Property<string>("Surname")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("character varying(64)");
b.Property<string>("Surname2")
.HasMaxLength(64)
.HasColumnType("character varying(64)");
b.Property<DateTime>("UpdateTime")
.HasColumnType("timestamp with time zone");
b.ComplexProperty(typeof(Dictionary<string, object>), "AddressDetails", "Somnia.GuestLog.Models.Entities.GuestDocument.AddressDetails#GuestAddress", b1 =>
{
b1.Property<string>("Address")
.HasMaxLength(128)
.HasColumnType("character varying(128)");
b1.Property<string>("AddressCity")
.HasMaxLength(128)
.HasColumnType("character varying(128)");
b1.Property<string>("AddressCountry")
.IsRequired()
.HasMaxLength(3)
.HasColumnType("character varying(3)");
b1.Property<string>("AddressProvince")
.HasMaxLength(128)
.HasColumnType("character varying(128)");
b1.Property<string>("AddressState")
.HasMaxLength(128)
.HasColumnType("character varying(128)");
b1.Property<string>("ZipCode")
.HasMaxLength(12)
.HasColumnType("character varying(12)");
});
b.HasKey("DocumentType", "DocumentNum");
b.ToTable("GuestDocument", (string)null);
});
modelBuilder.Entity("Somnia.GuestLog.Models.Entities.StayEntry", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
b.Property<DateTime>("CreateTime")
.HasColumnType("timestamp with time zone");
b.Property<DateTime>("DateIn")
.HasColumnType("timestamp(0) with time zone");
b.Property<DateTime>("DateOut")
.HasColumnType("timestamp(0) with time zone");
b.Property<string>("PaymentMethod")
.IsRequired()
.HasMaxLength(5)
.HasColumnType("character varying(5)");
b.Property<int>("RoomCount")
.HasColumnType("integer");
b.Property<string>("RoomNumber")
.HasMaxLength(32)
.HasColumnType("character varying(32)");
b.Property<DateTime>("UpdateTime")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.ToTable("StayEntry", (string)null);
});
modelBuilder.Entity("GuestDocumentStayEntry", b =>
{
b.HasOne("Somnia.GuestLog.Models.Entities.StayEntry", null)
.WithMany()
.HasForeignKey("StayEntryId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Somnia.GuestLog.Models.Entities.GuestDocument", null)
.WithMany()
.HasForeignKey("GuestDocumentsDocumentType", "GuestDocumentsDocumentNum")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,75 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Somnia.GuestLog.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddTable_StayEntry : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "StayEntry",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
DateIn = table.Column<DateTime>(type: "timestamp(0) with time zone", nullable: false),
DateOut = table.Column<DateTime>(type: "timestamp(0) with time zone", nullable: false),
RoomCount = table.Column<int>(type: "integer", nullable: false),
RoomNumber = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: true),
PaymentMethod = table.Column<string>(type: "character varying(5)", maxLength: 5, nullable: false),
CreateTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
UpdateTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_StayEntry", x => x.Id);
});
migrationBuilder.CreateTable(
name: "GuestDocumentStayEntry",
columns: table => new
{
StayEntryId = table.Column<long>(type: "bigint", nullable: false),
GuestDocumentsDocumentType = table.Column<string>(type: "character varying(8)", nullable: false),
GuestDocumentsDocumentNum = table.Column<string>(type: "character varying(64)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_GuestDocumentStayEntry", x => new { x.StayEntryId, x.GuestDocumentsDocumentType, x.GuestDocumentsDocumentNum });
table.ForeignKey(
name: "FK_GuestDocumentStayEntry_GuestDocument_GuestDocumentsDocument~",
columns: x => new { x.GuestDocumentsDocumentType, x.GuestDocumentsDocumentNum },
principalTable: "GuestDocument",
principalColumns: new[] { "DocumentType", "DocumentNum" },
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_GuestDocumentStayEntry_StayEntry_StayEntryId",
column: x => x.StayEntryId,
principalTable: "StayEntry",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_GuestDocumentStayEntry_GuestDocumentsDocumentType_GuestDocu~",
table: "GuestDocumentStayEntry",
columns: new[] { "GuestDocumentsDocumentType", "GuestDocumentsDocumentNum" });
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "GuestDocumentStayEntry");
migrationBuilder.DropTable(
name: "StayEntry");
}
}
}
@@ -23,6 +23,24 @@ namespace Somnia.GuestLog.Infrastructure.Migrations
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("GuestDocumentStayEntry", b =>
{
b.Property<long>("StayEntryId")
.HasColumnType("bigint");
b.Property<string>("GuestDocumentsDocumentType")
.HasColumnType("character varying(8)");
b.Property<string>("GuestDocumentsDocumentNum")
.HasColumnType("character varying(64)");
b.HasKey("StayEntryId", "GuestDocumentsDocumentType", "GuestDocumentsDocumentNum");
b.HasIndex("GuestDocumentsDocumentType", "GuestDocumentsDocumentNum");
b.ToTable("GuestDocumentStayEntry");
});
modelBuilder.Entity("Somnia.GuestLog.Models.Entities.GuestDocument", b =>
{
b.Property<string>("DocumentType")
@@ -112,6 +130,58 @@ namespace Somnia.GuestLog.Infrastructure.Migrations
b.ToTable("GuestDocument", (string)null);
});
modelBuilder.Entity("Somnia.GuestLog.Models.Entities.StayEntry", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
b.Property<DateTime>("CreateTime")
.HasColumnType("timestamp with time zone");
b.Property<DateTime>("DateIn")
.HasColumnType("timestamp(0) with time zone");
b.Property<DateTime>("DateOut")
.HasColumnType("timestamp(0) with time zone");
b.Property<string>("PaymentMethod")
.IsRequired()
.HasMaxLength(5)
.HasColumnType("character varying(5)");
b.Property<int>("RoomCount")
.HasColumnType("integer");
b.Property<string>("RoomNumber")
.HasMaxLength(32)
.HasColumnType("character varying(32)");
b.Property<DateTime>("UpdateTime")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.ToTable("StayEntry", (string)null);
});
modelBuilder.Entity("GuestDocumentStayEntry", b =>
{
b.HasOne("Somnia.GuestLog.Models.Entities.StayEntry", null)
.WithMany()
.HasForeignKey("StayEntryId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Somnia.GuestLog.Models.Entities.GuestDocument", null)
.WithMany()
.HasForeignKey("GuestDocumentsDocumentType", "GuestDocumentsDocumentNum")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}