c# - Create Restful Service Using Repository -
i have mvc application. using repository pattern , dependecy injection patterns. here simple interface :
[servicecontract] public interface icategoryservice { [operationcontract] list<category> getall(); category add(category category); }
and concrete class implements interface:
public class categorymanager : icategoryservice { private readonly icategorydal _categorydal; public categorymanager(icategorydal categorydal) { _categorydal = categorydal; } public list<category> getall() { return _categorydal.getwithsp(); } public list<category> getall(int a) { return _categorydal.getlist(); } public category add(category category) { return _categorydal.add(category); } }
i inject concrete class interface in global.asax. need create web service expose methods in interface (this interface example. not one). how can few effort? because of methods works on web application, maybe few methods needs added.
can use interaface contract, instead of creating new one? or should when need use interface?
you can use it! enterprise level application architecture web api's using entity framework, generic repository pattern , unit of work.
Comments
Post a Comment