Refactor/main flow #38
@@ -13,6 +13,8 @@ public record RideResponse(
|
||||
int Meterend,
|
||||
DateTime? StartedAt,
|
||||
DateTime? ClosedAt,
|
||||
CancelRequestType? CancelTypeCode,
|
||||
string? CancelReason,
|
||||
DateTime CreatedAt);
|
||||
|
||||
public record CreateRideRequest(
|
||||
|
||||
@@ -109,6 +109,8 @@ public class RideService(
|
||||
throw new InvalidOperationException($"Cannot cancel a ride in {ride.Status} status");
|
||||
|
||||
ride.Status = RideStatus.Cancelled;
|
||||
ride.CancelTypeCode = request.TypeCode;
|
||||
ride.CancelReason = request.Reason;
|
||||
|
||||
await uow.BeginAsync(ct);
|
||||
try { rideRepo.Update(ride); await uow.CommitAsync(ct); }
|
||||
@@ -149,5 +151,5 @@ public class RideService(
|
||||
r.FK_VehicleId, r.Vehicle?.NumberPlate ?? string.Empty,
|
||||
r.FK_DriverProfileId, r.DriverProfile?.User?.FullName ?? string.Empty,
|
||||
r.Meterstart, r.Meterend,
|
||||
r.StartedAt, r.ClosedAt, r.CreatedAt);
|
||||
r.StartedAt, r.ClosedAt, r.CancelTypeCode, r.CancelReason, r.CreatedAt);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Distribution.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddRideCancelReason : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "CancelReason",
|
||||
table: "DeliveryRuns",
|
||||
type: "longtext",
|
||||
nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "CancelTypeCode",
|
||||
table: "DeliveryRuns",
|
||||
type: "int",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "DeliveryRuns",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("31000000-0000-0000-0000-000000000001"),
|
||||
columns: new[] { "CancelReason", "CancelTypeCode" },
|
||||
values: new object[] { null, null });
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "DeliveryRuns",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("31000000-0000-0000-0000-000000000002"),
|
||||
columns: new[] { "CancelReason", "CancelTypeCode" },
|
||||
values: new object[] { null, null });
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CancelReason",
|
||||
table: "DeliveryRuns");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CancelTypeCode",
|
||||
table: "DeliveryRuns");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -206,6 +206,12 @@ namespace Distribution.Migrations
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("CancelReason")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int?>("CancelTypeCode")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime?>("ClosedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
|
||||
@@ -19,5 +19,8 @@ namespace Distribution.Models
|
||||
|
||||
public DateTime? StartedAt { get; set; }
|
||||
public DateTime? ClosedAt { get; set; }
|
||||
|
||||
public CancelRequestType? CancelTypeCode { get; set; }
|
||||
public string? CancelReason { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user