service-layer

Service Layer/Repository Pattern

南楼画角 提交于 2019-12-04 13:58:14
问题 I am building an MVC app using the Service Layer/Repository/Unit of Work pattern with EF4. I am a bit confused on the logic. I know the point is to decouple the system, but I am a little confused. So the MVC Controllers call on the Services to fill the View Models. So is it safe to say the MVC App is coupled to the Service Layer? Then the Service Layer calls on the Repository to get and persist objects. Is then safe to say the Service Layer is dependent to the Repository? The Repository the

Help creating a flexible base 'find' method in a service class using the DRY principle

孤街醉人 提交于 2019-12-04 13:14:20
问题 For years now I've been reimplementing the same code over and over (with evolution) without finding some method of cleanly, and efficiently, abstracting it out. The pattern is a base 'find[Type]s' method in my service layers which abstracts select query creation to a single point in the service, but supports the ability to quickly create easier to use proxy methods (see the example PostServivce::getPostById() method way below). Unfortunately, so far, I've been unable to satisfy these goals:

Responsibilities of Service and Repository layers

a 夏天 提交于 2019-12-04 11:23:39
问题 Just trying to get my head round the responsibilities of the service layer and repository layer when saving an object to my persistence store. My current under standing is this: In my controller I have created a "Note" object from the data submitted by the user (from the form). The user then calls "Save" on the "NoteService" (which is there via dependency injection). Within the "Save" method on the "NoteService" I carry out my business logic validation and then pass the "Note" object to the

How to pass complex ViewModel to Service Layer in ASP.NET MVC?

雨燕双飞 提交于 2019-12-03 18:53:19
问题 Say I have RegisterModel for user registration and some UserService that implementing IUserService public interface IUserService { User CreateUser(User newUser); } [HttpPost] public ActionResult Register(RegisterModel model) { if (ModelState.IsValid) { // ... logic for newuser User user = _userService.CreateUser(newuser); _authenticationService.SetAuthenticatedUser(user); return RedirectToRoute("Homepage"); } return View(model); } Given that RegisterModel might be very complex, where is the

ObservableCollection in the service layer of the WPF MVVM application

青春壹個敷衍的年華 提交于 2019-12-03 14:01:15
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 considered a bad approach and there're better alternatives? You can do this - of course you can. The primary

Service Layer/Repository Pattern

烈酒焚心 提交于 2019-12-03 08:46:30
I am building an MVC app using the Service Layer/Repository/Unit of Work pattern with EF4. I am a bit confused on the logic. I know the point is to decouple the system, but I am a little confused. So the MVC Controllers call on the Services to fill the View Models. So is it safe to say the MVC App is coupled to the Service Layer? Then the Service Layer calls on the Repository to get and persist objects. Is then safe to say the Service Layer is dependent to the Repository? The Repository the utilizes EF4 to get and persist data to SQL server, so I would assume the Repository depends on EF4

ZF + Doctrine 2 : Heavy model classes or Lightweight model + Service layer?

大城市里の小女人 提交于 2019-12-03 07:54:49
问题 I am integrating Zend Framework and Doctrine 2 , and I am discovering the Service layer . Now I understand (am I wrong ?) that I have 2 architectures possible : A model , where classes contain domain logic, i.e. properties + getters/setters + complex methods A lightweight model , where classes contain properties + getters/setters and a Service layer, containing domain logic, and modifying the model classes What are the pros/cons of each ? It seems weird to me to lose OOP by putting domain

Responsibilities of Service and Repository layers

笑着哭i 提交于 2019-12-03 07:17:28
Just trying to get my head round the responsibilities of the service layer and repository layer when saving an object to my persistence store. My current under standing is this: In my controller I have created a "Note" object from the data submitted by the user (from the form). The user then calls "Save" on the "NoteService" (which is there via dependency injection). Within the "Save" method on the "NoteService" I carry out my business logic validation and then pass the "Note" object to the "Save" method of the "NoteRepository". The "Save" method of the "NoteRepository" then checks to see if

Purpose of the service layer

匆匆过客 提交于 2019-12-03 03:54:36
问题 Am I correct in thinking that the purpose of a service layer includes the following? thinning out of domain models (i.e. movement of certain functions like in caching, instantiation) reduction in dependencies from domain models API minimisation 回答1: In terms of domain-driven design for example the domain service layer is used for operations that cannot be defined in the context of you Domain objects. For example if you have an object CreditCard, a suitable operation in your service layer

Are Doctrine2 repositories a good place to save my entities?

落爺英雄遲暮 提交于 2019-12-03 01:43:37
问题 When I read docs about repositories, it is often to work with entities & collection but in a "read-only" manner. There are never examples where repositories have methods like insertUser(User $user) or updateUser(User $user) . However, when using SOA, Service should not be working with Entity Manager (that's right, isn't it?) so: Should my service be aware of the global EntityManager? Should my service know only about the used Repositories (let's say, UserRepository & ArticleRepository) From