Dev #27
@@ -37,7 +37,6 @@ public class AppDBContext(DbContextOptions<AppDBContext> options) : DbContext(op
|
||||
public DbSet<Supplier> Suppliers { get; set; }
|
||||
public DbSet<DriverProfile> DriverProfiles { get; set; }
|
||||
public DbSet<DriverComplianceConfig> DriverComplianceConfigs { get; set; }
|
||||
public DbSet<RideCancelRequest> RideCancelRequests { get; set; }
|
||||
public DbSet<Scheme> Schemes { get; set; }
|
||||
public DbSet<SchemeRedemption> SchemeRedemptions { get; set; }
|
||||
public DbSet<SchemeBundleComponent> SchemeBundleComponents { get; set; }
|
||||
|
||||
@@ -32,8 +32,6 @@ public static class OperationsExtrasSeed
|
||||
|
||||
private static readonly Guid DriverComplianceConfig1Id = new("64000000-0000-0000-0000-000000000001");
|
||||
|
||||
private static readonly Guid RideCancelRequest1Id = new("65000000-0000-0000-0000-000000000001");
|
||||
|
||||
private static readonly Guid RouteVisitLog1Id = new("66000000-0000-0000-0000-000000000001");
|
||||
private static readonly Guid RouteVisitLog2Id = new("66000000-0000-0000-0000-000000000002");
|
||||
|
||||
@@ -95,21 +93,6 @@ public static class OperationsExtrasSeed
|
||||
new DriverComplianceConfig { Id = DriverComplianceConfig1Id, EnforceLicenseExpiry = true, EnforceMedicalClearance = true, UpdatedAt = new DateTime(2026, 8, 20), UpdatedBy = MasterDataSeed.Supervisor1UserId }
|
||||
);
|
||||
|
||||
modelBuilder.Entity<RideCancelRequest>().HasData(
|
||||
new RideCancelRequest
|
||||
{
|
||||
Id = RideCancelRequest1Id,
|
||||
FK_RideId = OperationsDataSeed.ActiveDeliveryRunId,
|
||||
TypeCode = CancelRequestType.VehicleBreakdown,
|
||||
Reason = "Reported minor engine issue, resolved after inspection",
|
||||
RequestedBy = MasterDataSeed.Driver2UserId,
|
||||
RequestedAt = new DateTime(2026, 8, 30, 9, 10, 0),
|
||||
Status = CancelRequestStatus.Rejected,
|
||||
ApprovedBy = MasterDataSeed.Supervisor1UserId,
|
||||
ApprovedAt = new DateTime(2026, 8, 30, 9, 15, 0)
|
||||
}
|
||||
);
|
||||
|
||||
modelBuilder.Entity<RouteVisitLog>().HasData(
|
||||
new RouteVisitLog { Id = RouteVisitLog1Id, FK_RouteId = MasterDataSeed.ColomboRouteId, FK_StoreId = MasterDataSeed.FortStoreId, FK_UserId = MasterDataSeed.SalesRep1UserId, CheckInAt = new DateTime(2026, 8, 25, 9, 0, 0), CheckInLatitude = 6.9344m, CheckInLongitude = 79.8428m, IsDeviationFlagged = false, CheckOutAt = new DateTime(2026, 8, 25, 9, 25, 0), CreatedAt = new DateTime(2026, 8, 25, 9, 0, 0), IsActive = true },
|
||||
new RouteVisitLog { Id = RouteVisitLog2Id, FK_RouteId = MasterDataSeed.ColomboRouteId, FK_StoreId = MasterDataSeed.DehiwalaStoreId, FK_UserId = MasterDataSeed.SalesRep1UserId, CheckInAt = new DateTime(2026, 8, 25, 10, 0, 0), CheckInLatitude = 6.9000m, CheckInLongitude = 79.8654m, IsDeviationFlagged = true, CheckOutAt = null, CreatedAt = new DateTime(2026, 8, 25, 10, 0, 0), IsActive = true }
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
using Distribution.Models;
|
||||
|
||||
namespace Distribution.Features.Ride;
|
||||
|
||||
public interface IRideCancelRequestRepository
|
||||
{
|
||||
Task<RideCancelRequest?> GetByIdAsync(Guid id);
|
||||
Task<RideCancelRequest?> GetByRideIdAsync(Guid rideId);
|
||||
Task<RideCancelRequest?> GetPendingByRideIdAsync(Guid rideId);
|
||||
Task<List<RideCancelRequest>> GetAllAsync(CancelRequestStatus? status, int page, int pageSize);
|
||||
Task<int> GetCountAsync(CancelRequestStatus? status);
|
||||
Task AddAsync(RideCancelRequest request);
|
||||
void Update(RideCancelRequest request);
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
using Distribution.Data;
|
||||
using Distribution.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Distribution.Features.Ride;
|
||||
|
||||
public class RideCancelRequestRepository(AppDBContext context) : IRideCancelRequestRepository
|
||||
{
|
||||
public async Task<RideCancelRequest?> GetByIdAsync(Guid id) =>
|
||||
await context.RideCancelRequests.FirstOrDefaultAsync(r => r.Id == id);
|
||||
|
||||
public async Task<RideCancelRequest?> GetByRideIdAsync(Guid rideId) =>
|
||||
await context.RideCancelRequests
|
||||
.Where(r => r.FK_RideId == rideId)
|
||||
.OrderByDescending(r => r.RequestedAt)
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
public async Task<RideCancelRequest?> GetPendingByRideIdAsync(Guid rideId) =>
|
||||
await context.RideCancelRequests
|
||||
.FirstOrDefaultAsync(r => r.FK_RideId == rideId && r.Status == CancelRequestStatus.Pending);
|
||||
|
||||
public async Task<List<RideCancelRequest>> GetAllAsync(CancelRequestStatus? status, int page, int pageSize) =>
|
||||
await context.RideCancelRequests
|
||||
.Where(r => status == null || r.Status == status)
|
||||
.OrderByDescending(r => r.RequestedAt)
|
||||
.Skip((page - 1) * pageSize)
|
||||
.Take(pageSize)
|
||||
.ToListAsync();
|
||||
|
||||
public async Task<int> GetCountAsync(CancelRequestStatus? status) =>
|
||||
await context.RideCancelRequests
|
||||
.CountAsync(r => status == null || r.Status == status);
|
||||
|
||||
public async Task AddAsync(RideCancelRequest request) =>
|
||||
await context.RideCancelRequests.AddAsync(request);
|
||||
|
||||
public void Update(RideCancelRequest request) =>
|
||||
context.RideCancelRequests.Update(request);
|
||||
}
|
||||
+3992
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Distribution.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class RemoveRideCancelRequest : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "RideCancelRequests");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "RideCancelRequests",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
FK_RideId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
ApprovedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true),
|
||||
ApprovedBy = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
||||
Reason = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
RequestedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
RequestedBy = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
Status = table.Column<int>(type: "int", nullable: false),
|
||||
TypeCode = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_RideCancelRequests", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_RideCancelRequests_DeliveryRuns_FK_RideId",
|
||||
column: x => x.FK_RideId,
|
||||
principalTable: "DeliveryRuns",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.InsertData(
|
||||
table: "RideCancelRequests",
|
||||
columns: new[] { "Id", "ApprovedAt", "ApprovedBy", "FK_RideId", "Reason", "RequestedAt", "RequestedBy", "Status", "TypeCode" },
|
||||
values: new object[] { new Guid("65000000-0000-0000-0000-000000000001"), new DateTime(2026, 8, 30, 9, 15, 0, 0, DateTimeKind.Unspecified), new Guid("29000000-0000-0000-0000-000000000001"), new Guid("31000000-0000-0000-0000-000000000002"), "Reported minor engine issue, resolved after inspection", new DateTime(2026, 8, 30, 9, 10, 0, 0, DateTimeKind.Unspecified), new Guid("29000000-0000-0000-0000-000000000005"), 2, 0 });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_RideCancelRequests_FK_RideId",
|
||||
table: "RideCancelRequests",
|
||||
column: "FK_RideId");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1407,58 +1407,6 @@ namespace Distribution.Migrations
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Distribution.Models.RideCancelRequest", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<DateTime?>("ApprovedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<Guid?>("ApprovedBy")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("FK_RideId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("Reason")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<DateTime>("RequestedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<Guid>("RequestedBy")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("TypeCode")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("FK_RideId");
|
||||
|
||||
b.ToTable("RideCancelRequests");
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
{
|
||||
Id = new Guid("65000000-0000-0000-0000-000000000001"),
|
||||
ApprovedAt = new DateTime(2026, 8, 30, 9, 15, 0, 0, DateTimeKind.Unspecified),
|
||||
ApprovedBy = new Guid("29000000-0000-0000-0000-000000000001"),
|
||||
FK_RideId = new Guid("31000000-0000-0000-0000-000000000002"),
|
||||
Reason = "Reported minor engine issue, resolved after inspection",
|
||||
RequestedAt = new DateTime(2026, 8, 30, 9, 10, 0, 0, DateTimeKind.Unspecified),
|
||||
RequestedBy = new Guid("29000000-0000-0000-0000-000000000005"),
|
||||
Status = 2,
|
||||
TypeCode = 0
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Distribution.Models.Role", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
@@ -3553,17 +3501,6 @@ namespace Distribution.Migrations
|
||||
b.Navigation("Region");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Distribution.Models.RideCancelRequest", b =>
|
||||
{
|
||||
b.HasOne("Distribution.Models.DeliveryRun", "Ride")
|
||||
.WithMany()
|
||||
.HasForeignKey("FK_RideId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Ride");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Distribution.Models.RolePermission", b =>
|
||||
{
|
||||
b.HasOne("Distribution.Models.Permission", "Permission")
|
||||
|
||||
@@ -14,8 +14,6 @@ namespace Distribution.Models
|
||||
|
||||
public enum CancelRequestType { VehicleBreakdown, DriverUnavailable, RouteIssue, Other }
|
||||
|
||||
public enum CancelRequestStatus { Pending, Approved, Rejected }
|
||||
|
||||
public enum PurchaseOrderStatus { Issued, PartiallyReceived, Received, Closed, Cancelled }
|
||||
|
||||
public enum ShopPOStatus { Pending, PartiallyFulfilled, Fulfilled, Cancelled }
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Distribution.Models
|
||||
{
|
||||
public class RideCancelRequest
|
||||
{
|
||||
public Guid Id { get; set; } = Guid.NewGuid();
|
||||
|
||||
public Guid FK_RideId { get; set; }
|
||||
[ForeignKey("FK_RideId")]
|
||||
public DeliveryRun Ride { get; set; }
|
||||
|
||||
public CancelRequestType TypeCode { get; set; }
|
||||
public string Reason { get; set; }
|
||||
|
||||
public Guid RequestedBy { get; set; }
|
||||
public DateTime RequestedAt { get; set; } = DateTime.Now;
|
||||
|
||||
public CancelRequestStatus Status { get; set; } = CancelRequestStatus.Pending;
|
||||
public Guid? ApprovedBy { get; set; }
|
||||
public DateTime? ApprovedAt { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user