shoc-backend/SeaHaven.Services/DTOs/VendorDTOs.cs
Alexandre Brandizzi 8515676f4d feat(vendors): add admin-assigned vendor company Area
Seed an organization-wide Area catalogue (East, Central, West, California)
with stable ids, add a nullable AreaId to VendorCompany, allow only Admins
to change it through the roster endpoints, expose areas facet metadata and
an areas[n] company-directory filter with the __unassigned__ sentinel.
2026-09-16 11:34:45 -03:00

148 lines
5.8 KiB
C#

namespace SeaHaven.Services.DTOs
{
public class VendorDTO
{
public int Id { get; set; }
public string? Name { get; set; }
public int? CompanyId { get; set; }
public string? ContactName { get; set; }
public string? Email { get; set; }
public string? Phone { get; set; }
public string? CompanyPhone { get; set; }
public string? PreferredContact { get; set; }
public string? Address { get; set; }
public string? City { get; set; }
public string? State { get; set; }
public string? Zipcode { get; set; }
public string? TradeSpecialties { get; set; }
public string? GoogleMapsUrl { get; set; }
public string? Notes { get; set; }
public int TotalJobs { get; set; }
public bool IsActive { get; set; }
}
// Shared directory row. On the SH-198 legacy per-technician path (GetVendorList)
// Id is the technician's own vendor id and Technicians stays empty — the legacy
// response shape does not project it. On the SH-281 company-grouped path
// (GetVendorDirectoryList) Id is the primary technician's vendor id (null for
// company-only groups that have zero technicians); CompanyId is populated for
// linked and company-only groups. Technicians carries the full status-eligible
// roster of the company group.
public class VendorDirectoryItemDTO
{
public int? Id { get; set; }
public int? CompanyId { get; set; }
public string? CompanyName { get; set; }
public string? ContactName { get; set; }
public string? Email { get; set; }
public string? Phone { get; set; }
public string? CompanyPhone { get; set; }
public string? PreferredContact { get; set; }
public string? Address { get; set; }
public string? City { get; set; }
public string? State { get; set; }
public string? Zipcode { get; set; }
public string? TradeSpecialties { get; set; }
public string? GoogleMapsUrl { get; set; }
public string? Notes { get; set; }
public int? AreaId { get; set; }
public string? AreaName { get; set; }
public int TotalJobs { get; set; }
public bool IsActive { get; set; }
public List<VendorDirectoryTechnicianDTO> Technicians { get; set; } = new();
}
// SH-281: one technician inside a company group; Email/Phone stay technician-owned.
public class VendorDirectoryTechnicianDTO
{
public int Id { get; set; }
public string? ContactName { get; set; }
public string? Email { get; set; }
public string? Phone { get; set; }
public string? PreferredContact { get; set; }
public string? TradeSpecialties { get; set; }
public bool IsActive { get; set; }
public int TotalJobs { get; set; }
}
public class CreateVendorDTO
{
public required string Name { get; set; }
public int? CompanyId { get; set; }
public string? ContactName { get; set; }
public string? Email { get; set; }
public string? Phone { get; set; }
public string? CompanyPhone { get; set; }
public string? PreferredContact { get; set; }
public string? Address { get; set; }
public string? City { get; set; }
public string? State { get; set; }
public string? Zipcode { get; set; }
public string? TradeSpecialties { get; set; }
public string? GoogleMapsUrl { get; set; }
public string? Notes { get; set; }
public bool IsActive { get; set; } = true;
}
public class UpdateVendorDTO
{
public string? Name { get; set; }
public int? CompanyId { get; set; }
public string? ContactName { get; set; }
public string? Email { get; set; }
public string? Phone { get; set; }
public string? CompanyPhone { get; set; }
public string? PreferredContact { get; set; }
public string? Address { get; set; }
public string? City { get; set; }
public string? State { get; set; }
public string? Zipcode { get; set; }
public string? TradeSpecialties { get; set; }
public string? GoogleMapsUrl { get; set; }
public string? Notes { get; set; }
public bool? IsActive { get; set; }
// SH-254: deactivating a vendor with open work orders is allowed, but only
// when the caller has seen those work orders and said so. Absent this flag
// the open-work-order guard still blocks.
public bool ConfirmOpenWorkOrders { get; set; }
}
public class VendorDeactivationImpactDTO
{
public int VendorId { get; set; }
public bool CanDeactivate { get; set; }
public List<LinkedWorkOrderDTO> OpenWorkOrders { get; set; } = new();
}
public class LinkedWorkOrderDTO
{
public int WorkOrderId { get; set; }
public string? WorkOrderNumber { get; set; }
public string? WorkOrderTitle { get; set; }
public string? Status { get; set; }
public DateTime? ScheduledDate { get; set; }
public int? DispatchId { get; set; }
}
public class WorkOrderVendorUpdateDTO
{
public int WorkOrderId { get; set; }
public string? ContactName { get; set; }
public string? PreferredContact { get; set; }
public string? Phone { get; set; }
public string? Email { get; set; }
public string? Notes { get; set; }
}
public class VendorDeactivationBlockedException : InvalidOperationException
{
public List<LinkedWorkOrderDTO> OpenWorkOrders { get; }
public VendorDeactivationBlockedException(string message, List<LinkedWorkOrderDTO> openWorkOrders)
: base(message)
{
OpenWorkOrders = openWorkOrders;
}
}
}