This is what I've been doing so far in my business layer to return error messages to the user.
public void CreateMerchant(MerchantCreationModel model, out MerchantCreationStatus status)
{
//check if (merchantId exists
MerchantDTO merchant = _merchantRepo.ExistsGetMerchant(model.MerchantId);
if (merchant != null)
{
status = MerchantCreationStatus.MerchantAlreadyExists;
return;
}
// Rest of merchant creation logic has been removed for clarity
status = MerchantCreationStatus.Success;
}
I have a ErrorCodeToString() method in my controller that gets the text to display.
What do you think of this technique?