I am building an ASP.NET MVC project and going for the following Architecture:
My approach to this by fast thinking is to do something like that. In business layer create
public class ValidationMessage
{
public ValidationMessage(string message, ValidationMessageType messageType)
{
Message = message;
MessageType = messageType;
}
public string Message { get; private set; }
public ValidationMessageType MessageType { get; private set; }
}
public enum ValidationMessageType
{
Info,
Warning,
Error,
}
Now having a service example
public interface ISomeService
{
List Edit(SomeModel item);
}
Now in the controller you call the service and pass the validation messages to the view. It may be necessary to use ViewBag and pass the whole list. On the view you can highlight Info, Warning, Error. For example you could return some success message with Info type, or nothing at all and in the controller create success message.
Generally this approach is more coding, but more flexibility. Ideally service would validate everything, but for smaller projects to avoid validation duplication, as Henk Mollema stated in his answer, you could do user input validation through ViewModel and in service just validate just critical business rules.
ValidationMessageType may be an overkill as well, so it's possible to return just List from the service as error list and the empty list would mean success.