I followed a few courses on Pluralsight about Clean Architecture and Domain Driven Design. While I'm waiting for Eric Evan's book about DDD to arrive, I got the following situation and question:
I'm setting up a new project. I've added the following projects:
- MyProject.Application
- MyProject.Common
- MyProject.Domain
- MyProject.Infrastructure
- MyProject.Persistance
- MyProject.WebApi
A business requirement is to let the WebApi return a model with some properties that:
- Don't match my naming convention;
- are ugly.
This model lives inside the MyProject.Application project. For example:
namespace MyProject.Application
{
public class MyModel
{
public string _communityname { set; get; }
public List<string> photolist { set; get; }
public string postedby { set; get; }
}
}
Usually I would apply the JsonPropery attibute on these kind of models to keep it nice:
namespace MyProject.Application
{
public class MyModel
{
[JsonProperty("_communityname")]
public string CommunityName { set; get; }
[JsonProperty("photolist")]
public List<string> PhotoUrls { set; get; }
[JsonProperty("postedby")]
public string PostedBy { set; get; }
}
}
But, then I think about it... and say to myself: the application layer should not concern about how 'things' are presented. This is a task for the presentation layer, in this case WebApi.
Is this correct? Should the Application layer return a normal model and let the WebApi cast/convert this to any (ugly) form of presentation, required by the business.
Many thanks in advance.