Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ jobs:
version: 10
- name: Install npm modules
run: cd src/evently.client && pnpm i
- name: Run UI Tests
run: cd src/evently.client && pnpm run test
- name: Restore dependencies
run: dotnet restore src/Evently.Server/Evently.Server.csproj
- name: Build
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ test:
dotnet test ./tests/Evently.Server.Test/VisualPatron.Server.Test.csproj

add-migration:
dotnet ef migrations add SeedInit --project=src/Evently.Server --context=AppDbContext --output-dir=Common/Adapters/Data/Migrations
dotnet ef migrations add RenameAccountId --project=src/Evently.Server --context=AppDbContext --output-dir=Common/Adapters/Data/Migrations

update-migration:
dotnet ef database update --project=src/Evently.Server --context=AppDbContext
Expand Down
4 changes: 2 additions & 2 deletions src/Evently.Server/Common/Adapters/Data/AppDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ private static void SeedData(ModelBuilder modelBuilder) {
new Booking {
BookingId = "book_abc123456",
GatheringId = 1,
AccountId = guestUserId,
AttendeeId = guestUserId,
CreationDateTime = fixedCreationTime,
CheckInDateTime = null,
CheckoutDateTime = null,
Expand All @@ -252,7 +252,7 @@ private static void SeedData(ModelBuilder modelBuilder) {
new Booking {
BookingId = "book_def789012",
GatheringId = 2,
AccountId = hostUserId,
AttendeeId = hostUserId,
CreationDateTime = fixedCreationTime.AddHours(1), // Slightly different time
CheckInDateTime = null,
CheckoutDateTime = null,
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Evently.Server.Common.Adapters.Data.Migrations
{
/// <inheritdoc />
public partial class RenameAccountId : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Bookings_AspNetUsers_AccountId",
table: "Bookings");

migrationBuilder.RenameColumn(
name: "AccountId",
table: "Bookings",
newName: "AttendeeId");

migrationBuilder.RenameIndex(
name: "IX_Bookings_AccountId",
table: "Bookings",
newName: "IX_Bookings_AttendeeId");

migrationBuilder.AddForeignKey(
name: "FK_Bookings_AspNetUsers_AttendeeId",
table: "Bookings",
column: "AttendeeId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Bookings_AspNetUsers_AttendeeId",
table: "Bookings");

migrationBuilder.RenameColumn(
name: "AttendeeId",
table: "Bookings",
newName: "AccountId");

migrationBuilder.RenameIndex(
name: "IX_Bookings_AttendeeId",
table: "Bookings",
newName: "IX_Bookings_AccountId");

migrationBuilder.AddForeignKey(
name: "FK_Bookings_AspNetUsers_AccountId",
table: "Bookings",
column: "AccountId",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.HasMaxLength(50)
.HasColumnType("character varying(50)");

b.Property<string>("AccountId")
b.Property<string>("AttendeeId")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
Expand All @@ -157,7 +157,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)

b.HasKey("BookingId");

b.HasIndex("AccountId");
b.HasIndex("AttendeeId");

b.HasIndex("GatheringId");

Expand All @@ -167,14 +167,14 @@ protected override void BuildModel(ModelBuilder modelBuilder)
new
{
BookingId = "book_abc123456",
AccountId = "guest-user-22222",
AttendeeId = "guest-user-22222",
CreationDateTime = new DateTimeOffset(new DateTime(2024, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)),
GatheringId = 1L
},
new
{
BookingId = "book_def789012",
AccountId = "empty-user-12345",
AttendeeId = "empty-user-12345",
CreationDateTime = new DateTimeOffset(new DateTime(2024, 1, 1, 1, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)),
GatheringId = 2L
});
Expand Down Expand Up @@ -664,7 +664,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
{
b.HasOne("Evently.Server.Common.Domains.Entities.Account", "Account")
.WithMany("Bookings")
.HasForeignKey("AccountId")
.HasForeignKey("AttendeeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();

Expand Down
2 changes: 1 addition & 1 deletion src/Evently.Server/Common/Domains/Entities/Booking.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class Booking {
[StringLength(50)]
public string BookingId { get; set; } = $"book_{Nanoid.Generate(size: 10)}";

[StringLength(100)] [ForeignKey("Account")] public string AccountId { get; set; } = string.Empty;
[StringLength(100)] [ForeignKey("Account")] public string AttendeeId { get; set; } = string.Empty;
[JsonIgnore] public Account? Account { get; set; }
[NotMapped] public AccountDto? AccountDto => Account?.ToAccountDto();

Expand Down
4 changes: 2 additions & 2 deletions src/Evently.Server/Common/Extensions/MapperExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static GatheringReqDto ToGatheringDto(this Gathering gathering) {
public static Booking ToBooking(this BookingReqDto bookingReqDto) {
return new Booking {
BookingId = bookingReqDto.BookingId,
AccountId = bookingReqDto.AttendeeId,
AttendeeId = bookingReqDto.AttendeeId,
GatheringId = bookingReqDto.GatheringId,
CreationDateTime = bookingReqDto.CreationDateTime,
CheckInDateTime = bookingReqDto.CheckInDateTime,
Expand All @@ -50,7 +50,7 @@ public static Booking ToBooking(this BookingReqDto bookingReqDto) {
public static BookingReqDto ToBookingDto(this Booking booking) {
return new BookingReqDto(
booking.BookingId,
booking.AccountId,
booking.AttendeeId,
booking.GatheringId,
booking.CreationDateTime,
booking.CheckInDateTime,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public AccountValidator() {
RuleFor((member) => member.Name).NotEmpty().WithMessage("Name is required.");
RuleFor((member) => member.Email).NotEmpty().WithMessage("Email is required.");
RuleForEach((member) => member.Bookings).Custom((value, context) => {
if (value.AccountId == string.Empty) {
if (value.AttendeeId == string.Empty) {
context.AddFailure("MemberId is required.");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public async Task<PageResult<Booking>> GetBookings(string? accountId, long? gath
DateTimeOffset? gatheringStartBefore, DateTimeOffset? gatheringStartAfter, DateTimeOffset? gatheringEndBefore, DateTimeOffset? gatheringEndAfter,
bool? isCancelled, int? offset, int? limit) {
IQueryable<Booking> query = db.Bookings
.Where((b) => accountId == null || b.AccountId == accountId)
.Where((b) => accountId == null || b.AttendeeId == accountId)
.Where((b) => gatheringId == null || b.GatheringId == gatheringId)
.Where((c) => checkInStart == null || checkInStart <= c.CheckInDateTime)
.Where((b) => checkInEnd == null || b.CheckInDateTime <= checkInEnd)
Expand Down Expand Up @@ -89,7 +89,7 @@ public async Task<Booking> UpdateBooking(string bookingId, BookingReqDto booking
.FirstOrDefaultAsync((be) => be.BookingId == bookingId)
?? throw new KeyNotFoundException($"{booking.BookingId} not found");

current.AccountId = booking.AccountId;
current.AttendeeId = booking.AttendeeId;
current.GatheringId = booking.GatheringId;
current.CreationDateTime = booking.CreationDateTime;
current.CheckInDateTime = booking.CheckInDateTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ namespace Evently.Server.Features.Bookings.Services;
public sealed class BookingValidator : AbstractValidator<Booking> {
public BookingValidator() {
RuleFor((booking) => booking.GatheringId).NotEmpty().WithMessage("GatheringId is required.");
RuleFor((booking) => booking.AccountId).NotEmpty().WithMessage("AccountId is required.");
RuleFor((booking) => booking.AttendeeId).NotEmpty().WithMessage("AccountId is required.");
}
}
2 changes: 1 addition & 1 deletion src/Evently.Server/Features/Emails/Views/Ticket.razor
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</style>
</head>
<body
style="font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; margin: 0; padding: 20px; background-color: #f8f9fa;">
style="font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;">
<Container
Style="max-width: 400px; margin: 0 auto; background: white; border-radius: 12px; box-shadow: 0 8px 32px rgba(13, 110, 253, 0.15); overflow: hidden;">
<!-- Confirmation Message -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public async Task<PageResult<Gathering>> GetGatherings(
.Where((gathering) => organiserId == null || gathering.OrganiserId == organiserId)
.Where(gathering => isCancelled == null || gathering.CancellationDateTime.HasValue == isCancelled)
.Where((gathering) =>
attendeeId == null || gathering.Bookings.Any((be) => be.AccountId == attendeeId))
.Include(gathering => gathering.Bookings.Where((be) => be.AccountId == attendeeId))
attendeeId == null || gathering.Bookings.Any((be) => be.AttendeeId == attendeeId))
.Include(gathering => gathering.Bookings.Where((be) => be.AttendeeId == attendeeId))
.Include(gathering => gathering.GatheringCategoryDetails)
.ThenInclude(detail => detail.Category);

Expand Down
5 changes: 4 additions & 1 deletion src/evently.client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta
name="viewport"
content="height=device-height, width=device-width, initial-scale=1.0, minimum-scale=1.0"
/>
<title>Evently</title>
</head>
<body>
Expand Down
9 changes: 8 additions & 1 deletion src/evently.client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"type": "module",
"scripts": {
"dev": "vite",
"test": "vitest",
"clean": "pnpm dlx npkill",
"build": "tsc -b && vite build",
"fmt": "prettier --write . && eslint .",
Expand Down Expand Up @@ -36,6 +37,10 @@
"@eslint/js": "^9.32.0",
"@iconify/react": "^6.0.0",
"@tanstack/router-plugin": "^1.131.7",
"@testing-library/dom": "^10.4.1",
"@testing-library/jest-dom": "^6.8.0",
"@testing-library/react": "^16.3.0",
"@testing-library/user-event": "^14.6.1",
"@types/lodash.clonedeep": "^4.5.9",
"@types/lodash.uniqby": "^4.7.9",
"@types/luxon": "^3.7.1",
Expand All @@ -52,6 +57,8 @@
"prettier-plugin-tailwindcss": "^0.6.14",
"typescript": "~5.8.3",
"typescript-eslint": "^8.39.0",
"vite": "^7.1.0"
"vite": "^7.1.0",
"vitest": "^3.2.4",
"vitest-dom": "^0.1.1"
}
}
Loading