service-layer

Should service layer accept a DTO or a custom request object from the controller?

六月ゝ 毕业季﹏ 提交于 2020-03-18 04:24:05
问题 As the title suggests what is the best practice when designing service layers?. I do understand service layer should always return a DTO so that domain (entity) objects are preserved within the service layer. But what should be the input for the service layer from the controllers? I put forward three of my own suggestions below: Method 1: In this method the domain object (Item) is preserved within the service layer. class Controller { @Autowired private ItemService service; public ItemDTO

Service layer design. Reason to put things into a service layer

别来无恙 提交于 2020-01-13 20:35:11
问题 I have a few design-related questions: should service layer interfaces reside in a domain layer ? For example user service ? what are the primary reasons to move a code part to a separate layer? should service layer reside at the same assembly as the application layer ? Thanks! EDIT I use a RavenDB and have quite skinny controller actions but two action are present as [NonAction] actions: [NonAction] public IEnumerable<Article> GetAllArticles() { return this.session.Query<Article>()

How to combine JSR-303 and Spring Validator class in a service layer?

泪湿孤枕 提交于 2019-12-29 05:32:07
问题 I have some model class public class Account { @Email private String email; @NotNull private String rule; } and spring-validator public class AccountValidator implements Validator { @Override public boolean supports(Class aClass) { return Account.class.equals(aClass); } @Override public void validate(Object obj, Errors errors) { Account account = (Account) obj; ValidationUtils.rejectIfEmpty(errors, "email", "email.required"); ValidationUtils.rejectIfEmpty(errors, "rule", "rule.required");

How should EntityManager be used in a nicely decoupled service layer and data access layer?

喜你入骨 提交于 2019-12-28 05:54:44
问题 Somewhat related to my other question Should raw Hibernate annotated POJO's be returned from the Data Access Layer, or Interfaces instead? , I am experienced in creation of nicely decoupled layers, but not using Hibernate or J2EE/JPA. I have been looking at documentation and tutorials, and am puzzled about how to use the EntityManger in an elegant way, as it seems it is responsible for both transactions (which I want to do at my service layer) and persistance methods (which I want to keep in

Breeze: EFContextProvider/Breeze Controller and Service Layer

独自空忆成欢 提交于 2019-12-24 01:27:57
问题 When using Breeze, I was wondering how one would go about integrating it with a service layer which handles things such as email notifications, audit logs, business validations (ie Customer must exist) etc.. For example, given the following scenario: public class SalesAppRepository { private readonly EFContextProvider<SalesAppContext> _contextProvider; public SalesAppRepository(EFContextProvider<SalesAppContext> contextProvider) { _contextProvider = contextProvider; } private SalesAppContext

Proper way to dependency inject authenticated user to my repository class

隐身守侯 提交于 2019-12-23 17:36:04
问题 I am using a service layer with repository pattern. The controller has a dependency on the service layer, and the service layer has a dependency on the repository. I have to pass logged in user information to the repository layer for authorization purposes and am trying to determine the best approach for injecting the user information into the repository considering that I seem to have an extensive injection chain: controller -> service(s) -> repositories -> logged in user info. I guess the

ObservableCollection in the service layer of the WPF MVVM application

给你一囗甜甜゛ 提交于 2019-12-21 04:26:05
问题 Examples of WPF MVVM apps I've seen on the Internet consider VM a layer which interacts with a service layer which either uses "old" events from an external library, or interacts with web using HTTP or whatever. But what if I build all M, V, VM, service and other parts myself? How to properly build interaction between the service layer and the viewmodel layer? Can I just put ObservableCollection<OrderModel> into the service and return it as is from the viewmodel for the view, or is it

Implementing the Repository Pattern in ASP.NET MVC

三世轮回 提交于 2019-12-21 04:25:12
问题 I am still having a hard time wrapping my head around this. I want to separate my layers (dlls) like so: 1) MyProject.Web.dll - MVC Web App (Controllers, Models (Edit/View), Views) 2) MyProject.Services.dll - Service Layer (Business Logic) 3) MyProject.Repositories.dll - Repositories 4) MyProject.Domain.dll - POCO Classes 5) MyProject.Data.dll - EF4 Workflow: 1) Controllers call Services to get objects to populate View/Edit Models. 2) Services call Repositories to get/persist objects. 3)

Domain Model and Service Layer patterns in P of EAA

旧巷老猫 提交于 2019-12-20 10:39:12
问题 In Patterns of Enterprise Application Architecture, Martin Fowler talks about two patterns for organizing Domain Logic: Domain Model and Service Layer. The Domain Model pattern is the "pure OOP" approach, where models (those objects that are probably being looked up from the database using an ORM) contain business logic (albeit, probably only delegating to the logic in another class). The Service Layer pattern is like the Domain Model pattern, but with a thin layer in front of it containing

ASP.NET MVC with service layer and repository layer, where should the interfaces be defined?

坚强是说给别人听的谎言 提交于 2019-12-18 09:56:43
问题 I am in the process of determining a fairly simple layered architecture for a .NET MVC application that has a repository layer and a service layer. I have found some fairly clear and simple examples, notably www.asp.net, and some questions and answers here, but I am looking for something that is a little simpler, suitable for small applications, but that uses different projects, to get the idea across. The example I linked to above has the repository and service as classes in the Models