- IAgentService - Complete with standard CRUD
- IProductService - Complete with standard CRUD
- ISupplierService - Complete with standard CRUD
Current Methods:
GetAllAgencies()UpdateAgency(int agencyId)? Missing DTO parameterGetAgencyById(int agencyId)UpdateAgencyById(int agencyId)?? Duplicate/ConfusingDeleteAgency(int agencyId)
Missing:
CreateAgency(AgencyDTO agency)
Issues to Fix:
UpdateAgencyshould acceptAgencyDTOas second parameter- Remove duplicate
UpdateAgencyById(redundant withUpdateAgency) - Inconsistent return types (should return
boolfor Delete like other services)
Current Methods:
GetAllPackagesAsync()GetPackageByIdAsync(int packageId)GetPackageByName(string packageName)? Good custom methodCreatePackageAsync(PackageDTO package)UpdatePackageAsync(int packageId, PackageDTO package)DeletePackageAsync(int packageId)
Already Has: Custom query method (GetPackageByName)
Current Methods:
AddAsync(ProductSupplierDTO dto)GetAllAsync()GetByProductId(int productId)GetBySupplierId(int supplierId)UpdateAsync(ProductSupplierDTO dto)DeleteAsync(int productSupplierId)LinkExistsAsync(int productId, int supplierId)? Good validation method
Issues:
GetAllAsync()should returnIEnumerable<ProductSupplierDTO>not single DTO- Missing
GetByIdAsync(int productSupplierId)
// Fix existing methods first, then add:
// Business Logic Methods
Task<IEnumerable<AgencyDTO>> GetAgenciesByCity(string city);
Task<IEnumerable<AgencyDTO>> GetAgenciesByProvince(string province);
Task<IEnumerable<AgencyDTO>> SearchAgencies(string searchTerm); // Search by city, province, or address
// Relationship Methods
Task<IEnumerable<AgentDTO>> GetAgentsByAgencyId(int agencyId);
Task<int> GetAgentCountByAgency(int agencyId);
// Validation
Task<bool> AgencyExists(int agencyId);
Task<bool> HasActiveAgents(int agencyId); // Before deletion// Business Logic Methods
Task<IEnumerable<AgentDTO>> GetAgentsByAgencyId(int agencyId);
Task<IEnumerable<AgentDTO>> GetAgentsByPosition(string position);
Task<IEnumerable<AgentDTO>> SearchAgentsByName(string searchTerm);
// Validation
Task<bool> AgentExists(int agentId);
Task<bool> EmailExists(string email);
Task<bool> IsAgentAvailable(int agentId); // For booking assignments// Business Logic Methods
Task<IEnumerable<PackageDTO>> GetActivePackages(); // Based on current date
Task<IEnumerable<PackageDTO>> GetPackagesByDateRange(DateTime startDate, DateTime endDate);
Task<IEnumerable<PackageDTO>> GetPackagesByPriceRange(decimal minPrice, decimal maxPrice);
Task<IEnumerable<PackageDTO>> SearchPackages(string searchTerm); // Name or description
// Relationship Methods
Task<IEnumerable<ProductSupplierDTO>> GetProductSuppliersByPackageId(int packageId);
Task<decimal> GetTotalPackagePrice(int packageId); // BasePrice + ProductSupplier costs
// Validation
Task<bool> PackageExists(int packageId);
Task<bool> IsPackageActive(int packageId);
Task<bool> HasBookings(int packageId); // Before deletion// Business Logic Methods
Task<IEnumerable<ProductDTO>> GetProductsByName(string searchTerm);
Task<IEnumerable<ProductDTO>> GetProductsNotInPackage(int packageId); // For adding to packages
// Relationship Methods
Task<IEnumerable<SupplierDTO>> GetSuppliersByProductId(int productId);
Task<IEnumerable<PackageDTO>> GetPackagesByProductId(int productId);
// Validation
Task<bool> ProductExists(int productId);
Task<bool> IsProductInUse(int productId); // Before deletion// Business Logic Methods
Task<IEnumerable<SupplierDTO>> SearchSuppliersByName(string searchTerm);
Task<IEnumerable<SupplierDTO>> GetSuppliersNotForProduct(int productId); // For linking
// Relationship Methods
Task<IEnumerable<ProductDTO>> GetProductsBySupplierId(int supplierId);
Task<int> GetProductCountBySupplierId(int supplierId);
// Validation
Task<bool> SupplierExists(int supplierId);
Task<bool> HasLinkedProducts(int supplierId); // Before deletion// Fix first: GetAllAsync should return IEnumerable<ProductSupplierDTO>
// Add: GetByIdAsync(int productSupplierId)
// Additional Business Logic
Task<IEnumerable<ProductSupplierDTO>> GetAllProductSuppliers(); // Fixed return type
Task<ProductSupplierDTO?> GetByIdAsync(int productSupplierId);
Task<IEnumerable<ProductSupplierDTO>> GetUnassignedProductSuppliers(); // Not in any package
// Bulk Operations
Task<bool> AddProductSuppliersToPackage(int packageId, IEnumerable<int> productSupplierIds);
Task<bool> RemoveProductSuppliersFromPackage(int packageId, IEnumerable<int> productSupplierIds);-
IAgencyService - Fix method signatures:
Task<AgencyDTO> CreateAgency(AgencyDTO agency); Task<AgencyDTO?> UpdateAgency(int agencyId, AgencyDTO agency); Task<bool> DeleteAgency(int agencyId); // Remove: UpdateAgencyById
-
IProductSupplierService - Fix return types:
Task<IEnumerable<ProductSupplierDTO>> GetAllAsync(); Task<ProductSupplierDTO?> GetByIdAsync(int productSupplierId);
- Add search/filter methods to all services for better UX
- Add relationship navigation methods (Get related entities)
- Add validation methods before delete operations
- Add bulk operation methods where applicable
- Add statistical/reporting methods (counts, totals, etc.)
| Interface | CRUD Complete | Custom Methods | Needs Fixing |
|---|---|---|---|
| IAgencyService | ? No | ? None | ? Yes - Add Create, Fix Update/Delete |
| IAgentService | ? Yes | ? None | ? No |
| IPackageService | ? Yes | ? GetByName | ? No |
| IProductService | ? Yes | ? None | ? No |
| ISupplierService | ? Yes | ? None | ? No |
| IProductSupplierService | ?? Partial | ? LinkExists | ? Yes - Fix GetAll return type |
- Async suffix: Only
IPackageServiceusesAsyncsuffix. Consider standardizing across all services for consistency. - Return types: Most services use
boolfor Delete.IAgencyServiceshould follow this pattern. - Nullable returns: Consider using
Task<DTO?>for Get methods that might not find results.