ServiceStack Application Structure
I have recently started looking at ServiceStack and how we could implement
it in our architecture. We have been using ASP.NET MVC 3/4 with the
Service/Repository/UnitOfWork pattern.
I am looking for resources of how to integrate ServiceStack into the mix.
What we usually have looks something like this:
MVC Controller/Action --> Service --> Repository --> Entity Framework
I want to re-use the domain model we have and expose it through
ServiceStack, so do I just have the operation's on the services return the
domain models?
E.G.
// Request DTO
public class Customer
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string City { get; set; }
public string State { get; set; }
public string ZipCode { get; set; }
}
// Response DTO
public class CustomerResponse
{
public List<Customer> Customers { get; set; }
}
// Customer Service
public class CustomerService : IService
{
public object Any(BrowseCustomers request)
{
var customers = new List<Customer>() {
new Customer {
FirstName = "Joe",
LastName = "Bob",
...
},
new Customer {
FirstName = "Jill",
LastName = "Bob",
...
}
};
return customers.Where(x =>
x.FirstName.ToLower().StartsWith(request.FirstName.ToLower()));
}
}
No comments:
Post a Comment