172 lines
8.2 KiB
C#
172 lines
8.2 KiB
C#
namespace NTP.Application.Registrar;
|
|
|
|
/// <summary>The three registrations a company registers from the mobile app and the registrar reviews (legacy entities DRIVERINFO, TRUCKINFO, TRAILERINFO).</summary>
|
|
public enum RegistrarKind
|
|
{
|
|
Driver,
|
|
Truck,
|
|
Trailer,
|
|
}
|
|
|
|
/// <summary>Row of DRIVERS_INFO / TRUCKS_INFO / TRAILERS_INFO. One class for the three tables (columns a table does not have stay null). Settable properties: Dapper + Oracle NUMBER.</summary>
|
|
public class RegistrarRecord
|
|
{
|
|
public long Id { get; set; }
|
|
public string? StatusCode { get; set; }
|
|
|
|
/// <summary>TN (truck) / TRN (trailer); empty for a driver.</summary>
|
|
public string? PlateNo { get; set; }
|
|
/// <summary>TN_CODE / TRN_CODE: the code of a foreign plate.</summary>
|
|
public string? PlateCode { get; set; }
|
|
public string? Nationality { get; set; }
|
|
|
|
// driver
|
|
public string? Nnpn { get; set; }
|
|
public string? NameAr { get; set; }
|
|
public string? NameEn { get; set; }
|
|
public DateTime? DateOfBirth { get; set; }
|
|
public string? BloodGroup { get; set; }
|
|
public string? Address { get; set; }
|
|
public string? LicenseType { get; set; }
|
|
public DateTime? LicenseIssueDate { get; set; }
|
|
public string? Mobile { get; set; }
|
|
|
|
// licence (all three)
|
|
public string? LicenseNo { get; set; }
|
|
public DateTime? LicenseExpiryDate { get; set; }
|
|
|
|
// truck / trailer
|
|
public string? LicenseRegistrationNo { get; set; }
|
|
public string? Manufacturer { get; set; }
|
|
public long? ManufactureYear { get; set; }
|
|
/// <summary>TRUCK_TYPE / TRAILER_TYPE.</summary>
|
|
public string? VehicleType { get; set; }
|
|
/// <summary>TRUCK_CATEGORY / TRAILER_CATEGORY (صفة الاستعمال).</summary>
|
|
public string? Category { get; set; }
|
|
public string? Color { get; set; }
|
|
public string? SecondaryColor { get; set; }
|
|
public string? Model { get; set; }
|
|
public string? VinNumber { get; set; }
|
|
public string? EngineNumber { get; set; }
|
|
public decimal? LoadingWeight { get; set; }
|
|
public decimal? GrossWeight { get; set; }
|
|
/// <summary>GROSS_WEIGHT - LOADING_WEIGHT (the view column EMPTY_WEIGHT of TRUCK_INFO_VIEW); trucks only.</summary>
|
|
public decimal? EmptyWeight { get; set; }
|
|
public string? OwnerName { get; set; }
|
|
public string? OwnerNnpn { get; set; }
|
|
public long? OwnerPhoneNumber { get; set; }
|
|
public string? OwnerAddress { get; set; }
|
|
public string? Governate { get; set; }
|
|
|
|
public string? Notes { get; set; }
|
|
public string? RevokeReason { get; set; }
|
|
public string? CreatedBy { get; set; }
|
|
public DateTime? CreationDate { get; set; }
|
|
public string? UpdatedBy { get; set; }
|
|
public DateTime? LastUpdateDate { get; set; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Grid filters. <see cref="Number"/> is the NNPN (drivers), TN (trucks) or TRN (trailers); equal, case-insensitive. <see cref="Name"/> (drivers, Arabic name) and
|
|
/// <see cref="OwnerName"/> (trucks / trailers) are "contains". <see cref="StatusCodes"/> empty = every status.
|
|
/// </summary>
|
|
public sealed record RegistrarQuery(
|
|
string? Number, string? LicenseNo, string? Name, string? OwnerName, string? VinNumber,
|
|
DateTime? DateFrom, DateTime? DateTo, IReadOnlyList<string> StatusCodes);
|
|
|
|
/// <summary>The update form (legacy *InfoForm). Fields a kind does not have are ignored. Year and weights come as text, like the legacy digits-only check.</summary>
|
|
public sealed class RegistrarUpdateRequest
|
|
{
|
|
public string? Nationality { get; set; }
|
|
public string? PlateNo { get; set; }
|
|
public string? PlateCode { get; set; }
|
|
public string? Nnpn { get; set; }
|
|
public string? NameAr { get; set; }
|
|
public string? NameEn { get; set; }
|
|
public string? Mobile { get; set; }
|
|
public DateTime? DateOfBirth { get; set; }
|
|
public string? BloodGroup { get; set; }
|
|
public string? Governate { get; set; }
|
|
public string? Address { get; set; }
|
|
public string? LicenseNo { get; set; }
|
|
public string? LicenseType { get; set; }
|
|
public DateTime? LicenseIssueDate { get; set; }
|
|
public DateTime? LicenseExpiryDate { get; set; }
|
|
public string? LicenseRegistrationNo { get; set; }
|
|
public string? OwnerName { get; set; }
|
|
public string? OwnerAddress { get; set; }
|
|
public string? Manufacturer { get; set; }
|
|
public string? Model { get; set; }
|
|
public string? Color { get; set; }
|
|
public string? SecondaryColor { get; set; }
|
|
public string? VehicleType { get; set; }
|
|
public string? ManufactureYear { get; set; }
|
|
public string? Category { get; set; }
|
|
public string? VinNumber { get; set; }
|
|
public string? EngineNumber { get; set; }
|
|
public string? LoadingWeight { get; set; }
|
|
public string? GrossWeight { get; set; }
|
|
public string? Notes { get; set; }
|
|
}
|
|
|
|
public sealed record RegistrarRevokeRequest(string? Reason);
|
|
|
|
/// <summary>What the caller may do with one record in its current status (the legacy PORTLET buttons, decided by STATUS_ACTION_MATRIX).</summary>
|
|
public sealed record RegistrarActions(bool Update, bool Complete, bool Revoke, bool Reopen);
|
|
|
|
/// <summary>An image or file of the registration (table ATTACHMENTS, entity DRIVERINFO / TRUCKINFO / TRAILERINFO). The content is served by the API (GET {id}/attachments/{attachmentId}).</summary>
|
|
public sealed record RegistrarAttachment(long Id, string FileName);
|
|
|
|
/// <summary>The bytes of one attachment, fetched from the host where the mobile app stored it.</summary>
|
|
public sealed record RegistrarFile(byte[] Content, string ContentType, string FileName);
|
|
|
|
public sealed record RegistrarDetail(RegistrarRecord Record, IReadOnlyList<RegistrarAttachment> Attachments, RegistrarActions Actions);
|
|
|
|
public sealed record RegistrarResult(string Message);
|
|
|
|
public sealed record LookupItem(string Code, string Ar, string En);
|
|
|
|
/// <summary>The drop-down lists of the three forms, by list name (legacy LT_PUBLIC lookups and NATIONALITY).</summary>
|
|
public sealed record RegistrarLookups(IReadOnlyDictionary<string, IReadOnlyList<LookupItem>> Lists);
|
|
|
|
public static class RegistrarStatus
|
|
{
|
|
public const string Pending = "PENDING";
|
|
public const string Completed = "COMPLETED";
|
|
public const string Revoke = "REVOKE";
|
|
public const string Incomplete = "INCOMPLETE";
|
|
}
|
|
|
|
/// <summary>Per kind: URL slug, table, entity name of the attachments and the permission keys.</summary>
|
|
public sealed record RegistrarKindInfo(
|
|
RegistrarKind Kind, string Slug, string Table, string Entity, string NotificationType, string NotificationNumber,
|
|
string Screen, string Update, string? UpdateCompleted, string Complete, string Revoke, string Reopen, string Report);
|
|
|
|
public static class RegistrarKinds
|
|
{
|
|
private static readonly RegistrarKindInfo[] All =
|
|
[
|
|
new(RegistrarKind.Driver, "drivers", "DRIVERS_INFO", "DRIVERINFO", "سائق", "NNPN",
|
|
Access.PermissionKeys.RegistrarDrivers, Access.PermissionKeys.RegistrarDriversUpdate, Access.PermissionKeys.RegistrarDriversUpdateCompleted,
|
|
Access.PermissionKeys.RegistrarDriversComplete, Access.PermissionKeys.RegistrarDriversRevoke, Access.PermissionKeys.RegistrarDriversReopen,
|
|
Access.PermissionKeys.RegistrarDriversReport),
|
|
new(RegistrarKind.Truck, "trucks", "TRUCKS_INFO", "TRUCKINFO", "شاحنة", "TN",
|
|
Access.PermissionKeys.RegistrarTrucks, Access.PermissionKeys.RegistrarTrucksUpdate, null,
|
|
Access.PermissionKeys.RegistrarTrucksComplete, Access.PermissionKeys.RegistrarTrucksRevoke, Access.PermissionKeys.RegistrarTrucksReopen,
|
|
Access.PermissionKeys.RegistrarTrucksReport),
|
|
new(RegistrarKind.Trailer, "trailers", "TRAILERS_INFO", "TRAILERINFO", "مقطوره", "TRN",
|
|
Access.PermissionKeys.RegistrarTrailers, Access.PermissionKeys.RegistrarTrailersUpdate, null,
|
|
Access.PermissionKeys.RegistrarTrailersComplete, Access.PermissionKeys.RegistrarTrailersRevoke, Access.PermissionKeys.RegistrarTrailersReopen,
|
|
Access.PermissionKeys.RegistrarTrailersReport),
|
|
];
|
|
|
|
public static RegistrarKindInfo Of(RegistrarKind kind) => All[(int)kind];
|
|
|
|
public static bool TryParse(string? slug, out RegistrarKind kind)
|
|
{
|
|
var hit = All.FirstOrDefault(k => string.Equals(k.Slug, slug, StringComparison.OrdinalIgnoreCase));
|
|
kind = hit?.Kind ?? default;
|
|
return hit is not null;
|
|
}
|
|
}
|