我很困惑如何從業務層返回結果。有時我需要返回郵件,如果它不通過標準。例如:BLL返回字符串或DTO
public SalesDTO GetSalesByPrescriptionNo(string prescriptionNo)
{
int count = unitOfWork.SalesRepository.GetNumberOfPrescriptionUsed(prescriptionNo);
if (count > 5)
// I cannot return string/error information
// since the function is return SalesDTO type
return "Cannot used anymore";
var sales = unitOfWork.SalesRepository.GetSalesByPrescriptionNo(prescriptionNo);
var salesDTO = Mapper.MapToDTO(sales);
return salesDTO;
}
基於良好的OOP/OOD實現,我應該如何處理BLL的多重結果?
在先進的感謝。
拋出異常。 –
@IlyaChumakov這不是一個錯誤,爲什麼它應該被視爲例外?這是一個很好的方法? – Willy