我很困惑如何从业务层返回结果。有时我需要返回邮件,如果它不通过标准。例如: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