Doubt in the construction of WS REST (Contract)

-1

Gentlemen, I took an example in the book of John Sharp (Microsoft Press) to build a REST and came up with a simple question but a question of good practice.

It uses the Northwind BD. It creates a Class Library project and points this project to the Products entity. The question is:

Should I create a new Class Library project for each entity in my WS, or can I use the same Project for multiple entities?

P.S. In my WS I will use 5 DB Entities (POS, Establishment, User, UserPDV and Location (This in another Context)).

A question: When I have a URI in this format in my Interface:

[OperationContract]
[WebGet(UriTemplate = "/")]

Does it mean a URL without parameters? That is, I can have a URI like this and a method with parameter, like this:

[ServiceContract]
    public interface ISuporteContract
    {
        [OperationContract]
        [WebGet(UriTemplate = "/")]
        public List<string> getCnpjParceiro(string _cnpj);
    }
    
asked by anonymous 12.05.2014 / 14:28

1 answer

1

The Entity classes you can maintain in a single Class Library project (Example: MyApp.Domain). Optionally in this same project you can maintain the interfaces (Contracts) of your services, however the .SVCs must be in another project (Web, Console, etC) to allow a better reuse of the domain classes and avoid a coupling (dependency / reference) between the web exhibition of services and your business logic.

    
27.05.2014 / 12:42