Migrate Show.Date from DateOnly to DateTime to support time of day
Removes DateOnly/DateTime conversion boilerplate from all Show endpoints and adds the corresponding EF Core migration. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -20,7 +20,7 @@ public class CreateShowEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoin
|
|||||||
Place = req.Place ?? string.Empty,
|
Place = req.Place ?? string.Empty,
|
||||||
Description = req.Description,
|
Description = req.Description,
|
||||||
PyrotechnicImplementationPlan = req.PyrotechnicImplementationPlan ?? string.Empty,
|
PyrotechnicImplementationPlan = req.PyrotechnicImplementationPlan ?? string.Empty,
|
||||||
Date = req.Date.HasValue ? DateOnly.FromDateTime(req.Date.Value) : null,
|
Date = req.Date,
|
||||||
CityId = req.CityId
|
CityId = req.CityId
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ public class CreateShowEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoin
|
|||||||
Place = show.Place,
|
Place = show.Place,
|
||||||
Description = show.Description,
|
Description = show.Description,
|
||||||
PyrotechnicImplementationPlan = show.PyrotechnicImplementationPlan,
|
PyrotechnicImplementationPlan = show.PyrotechnicImplementationPlan,
|
||||||
Date = show.Date.HasValue ? show.Date.Value.ToDateTime(TimeOnly.MinValue) : null,
|
Date = show.Date,
|
||||||
CityId = show.CityId
|
CityId = show.CityId
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ public class GetAllShowsEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoi
|
|||||||
Place = s.Place,
|
Place = s.Place,
|
||||||
Description = s.Description,
|
Description = s.Description,
|
||||||
PyrotechnicImplementationPlan = s.PyrotechnicImplementationPlan,
|
PyrotechnicImplementationPlan = s.PyrotechnicImplementationPlan,
|
||||||
Date = s.Date.HasValue ? s.Date.Value.ToDateTime(TimeOnly.MinValue) : null,
|
Date = s.Date,
|
||||||
CityId = s.CityId
|
CityId = s.CityId
|
||||||
})
|
})
|
||||||
.ToListAsync(ct);
|
.ToListAsync(ct);
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public class GetShowEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoint<I
|
|||||||
Place = s.Place,
|
Place = s.Place,
|
||||||
Description = s.Description,
|
Description = s.Description,
|
||||||
PyrotechnicImplementationPlan = s.PyrotechnicImplementationPlan,
|
PyrotechnicImplementationPlan = s.PyrotechnicImplementationPlan,
|
||||||
Date = s.Date.HasValue ? s.Date.Value.ToDateTime(TimeOnly.MinValue) : null,
|
Date = s.Date,
|
||||||
CityId = s.CityId
|
CityId = s.CityId
|
||||||
})
|
})
|
||||||
.FirstOrDefaultAsync(ct);
|
.FirstOrDefaultAsync(ct);
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class UpdateShowEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoin
|
|||||||
show.Description = req.Description ?? show.Description;
|
show.Description = req.Description ?? show.Description;
|
||||||
show.PyrotechnicImplementationPlan = req.PyrotechnicImplementationPlan ?? show.PyrotechnicImplementationPlan;
|
show.PyrotechnicImplementationPlan = req.PyrotechnicImplementationPlan ?? show.PyrotechnicImplementationPlan;
|
||||||
if (req.CityId.HasValue) show.CityId = req.CityId.Value;
|
if (req.CityId.HasValue) show.CityId = req.CityId.Value;
|
||||||
if (req.Date.HasValue) show.Date = DateOnly.FromDateTime(req.Date.Value);
|
if (req.Date.HasValue) show.Date = req.Date.Value;
|
||||||
|
|
||||||
await pyroFetesDbContext.SaveChangesAsync(ct);
|
await pyroFetesDbContext.SaveChangesAsync(ct);
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ public class UpdateShowEndpoint(PyroFetesDbContext pyroFetesDbContext) : Endpoin
|
|||||||
Place = show.Place,
|
Place = show.Place,
|
||||||
Description = show.Description,
|
Description = show.Description,
|
||||||
PyrotechnicImplementationPlan = show.PyrotechnicImplementationPlan,
|
PyrotechnicImplementationPlan = show.PyrotechnicImplementationPlan,
|
||||||
Date = show.Date.HasValue ? show.Date.Value.ToDateTime(TimeOnly.MinValue) : null,
|
Date = show.Date,
|
||||||
CityId = show.CityId
|
CityId = show.CityId
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,37 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace PyroFetes.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class DateTimeForShow : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AlterColumn<DateTime>(
|
||||||
|
name: "Date",
|
||||||
|
table: "Shows",
|
||||||
|
type: "datetime2",
|
||||||
|
nullable: true,
|
||||||
|
oldClrType: typeof(DateOnly),
|
||||||
|
oldType: "date",
|
||||||
|
oldNullable: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AlterColumn<DateOnly>(
|
||||||
|
name: "Date",
|
||||||
|
table: "Shows",
|
||||||
|
type: "date",
|
||||||
|
nullable: true,
|
||||||
|
oldClrType: typeof(DateTime),
|
||||||
|
oldType: "datetime2",
|
||||||
|
oldNullable: true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -816,8 +816,8 @@ namespace PyroFetes.Migrations
|
|||||||
b.Property<int?>("CityId")
|
b.Property<int?>("CityId")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
b.Property<DateOnly?>("Date")
|
b.Property<DateTime?>("Date")
|
||||||
.HasColumnType("date");
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
b.Property<string>("Description")
|
b.Property<string>("Description")
|
||||||
.HasMaxLength(500)
|
.HasMaxLength(500)
|
||||||
@@ -887,7 +887,7 @@ namespace PyroFetes.Migrations
|
|||||||
|
|
||||||
b.HasIndex("TruckId");
|
b.HasIndex("TruckId");
|
||||||
|
|
||||||
b.ToTable("ShowTruck");
|
b.ToTable("ShowTrucks");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("PyroFetes.Models.Sound", b =>
|
modelBuilder.Entity("PyroFetes.Models.Sound", b =>
|
||||||
@@ -1593,8 +1593,7 @@ namespace PyroFetes.Migrations
|
|||||||
{
|
{
|
||||||
b.HasOne("PyroFetes.Models.City", "City")
|
b.HasOne("PyroFetes.Models.City", "City")
|
||||||
.WithMany("Shows")
|
.WithMany("Shows")
|
||||||
.HasForeignKey("CityId")
|
.HasForeignKey("CityId");
|
||||||
.OnDelete(DeleteBehavior.ClientSetNull);
|
|
||||||
|
|
||||||
b.Navigation("City");
|
b.Navigation("City");
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ public class Show
|
|||||||
[Required, MaxLength(100)] public string? Name { get; set; }
|
[Required, MaxLength(100)] public string? Name { get; set; }
|
||||||
[Required, MaxLength(120)] public string? Place { get; set; }
|
[Required, MaxLength(120)] public string? Place { get; set; }
|
||||||
[MaxLength(500)] public string? Description { get; set; }
|
[MaxLength(500)] public string? Description { get; set; }
|
||||||
public DateOnly? Date { get; set; }
|
public DateTime? Date { get; set; }
|
||||||
|
|
||||||
// Link (path/URL/file name) to the pyrotechnic implementation plan
|
// Link (path/URL/file name) to the pyrotechnic implementation plan
|
||||||
[Required, MaxLength(500)] public string? PyrotechnicImplementationPlan { get; set; }
|
[Required, MaxLength(500)] public string? PyrotechnicImplementationPlan { get; set; }
|
||||||
|
|||||||
Reference in New Issue
Block a user