Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Service Layer & Web API Service Layer?

I have an application that has layers for data access, business, and wcf service. I need to convert this WCF layer to Web API and am stuck on whether I should:

1) Create two service layers/projects: - Services (class library) - Services.Api (WebAPI to expose and wrap calls to the services class library)

2) Or, just create a single WebAPI project.

I guess the issue I see with #2 is it limits how I'm able to reuse the library - I can only use the services using REST. With #1, I have the ability to use the class library when needed inside of my web controllers and WebAPI on the client/ajax as needed. The issue I see with #1 is all the extra code needed to repeat calls to the service layer class library.

Hope that make sense. Please let me know your thoughts on what might be a good approach and practice for me to follow, or scream at me for my lack of understanding. Thanks

like image 956
user3199179 Avatar asked Oct 01 '22 19:10

user3199179


1 Answers

If you have a good business layer that itself should be your Services(class library) layer. On top your Business/Services layer, should be your front end layers which could be the Wcf, Api or Mvc.

ProjectName
 -ProjectName.Core (All poco classes and interfaces)
 -ProjectName.Data (All entity framework stuff)
 -ProjectName.Service (All business logic)
 -ProjectName.Web (All font end logic)
like image 81
sunil Avatar answered Oct 13 '22 11:10

sunil