service-layer

Fat model / thin controller vs. Service layer [closed]

醉酒当歌 提交于 2019-12-17 07:58:07
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 6 years ago . I have been developing enterprise applications for many years using .Net My apps usually have a domain model containing entities mapping to SQL DB tables. I use a Repository pattern, Dependency injection and a service layer. Recently we started working on MVC 3 projects and

Validating data in the service layer against DTOs, Entity Models, or something else?

落花浮王杯 提交于 2019-12-13 12:37:32
问题 I'm working on an ASP.NET MVC project. In the project I have a service layer that accepts DTOs for CRUD operations. When I need to validate business logic, should the validator accept DTOs, Entity Models, or something else entirely? For example: public class ProductService: IProductService { public ValidationResult CreateProduct(ProductDTO productDto) { //call productValidator.Validate(productDto) on the DTO here? Product productEntityModel = mapper.Map<Product>(productDto); //or, call

Question about Interfaces and DI?

折月煮酒 提交于 2019-12-13 04:52:10
问题 I am using the Service/Repository/EF/POCO pattern in a MVC app, and had a couple questions about the Interfaces. 1) Should I make an Interface per Service? 2) Should I make an Interface per Repository? Or, should I have a generic interface per layer (IService(Of T), IRepository(Of T)). What I dont understand is how in the controller say, it takes a IService(Of Category) interface in it's constructor, how do I implements the methods in the concrete class? Public Class HomeController Inherits

MVP - Presenter and the Service Layer - Where to declare Service Layer

旧城冷巷雨未停 提交于 2019-12-12 09:55:09
问题 I'm reading through Architecting Microsoft .Net Solutions for the Enterprise and I try to figure a couple of things out concerning the Presenter and the Service Layer. First off, my Presenter needs to call methods that reside in the Service Layer, like initialize(), save() etc. But where do I place a reference to the service layer? Should it be at class level in the Presenter, or should I define a new service in the presenter methods itself? Second - this isn't really clear in the book either

How to solve Cyclic Dependency

一笑奈何 提交于 2019-12-12 00:05:53
问题 public class NotificationService: INotificationService{ private ILogService _logService; public NotificationService(ILogService logService){ _logService = logService; } } public class LogService: ILogService{ private INotificationService _notificationService; public LogService(INotificationService notificationService){ _notificationService = notificationService; } } I came into a situation where two classes depends on each other. I am using Ninject. Bind<INotificationService>().To

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

时光怂恿深爱的人放手 提交于 2019-12-06 10:17:27
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>() .Customize((x => x.WaitForNonStaleResults())) .AsQueryable() .OrderBy(d => d.CreatedOn); } [NonAction] public

Validating data in the service layer against DTOs, Entity Models, or something else?

核能气质少年 提交于 2019-12-06 09:24:41
I'm working on an ASP.NET MVC project. In the project I have a service layer that accepts DTOs for CRUD operations. When I need to validate business logic, should the validator accept DTOs, Entity Models, or something else entirely? For example: public class ProductService: IProductService { public ValidationResult CreateProduct(ProductDTO productDto) { //call productValidator.Validate(productDto) on the DTO here? Product productEntityModel = mapper.Map<Product>(productDto); //or, call productValidator.Validate(productEntityModel) on the Entity model here? if(validationResult.Valid) {

Entity Framework Service Layer Update POCO

自古美人都是妖i 提交于 2019-12-06 07:49:57
问题 I am using the Service Layer --> Repository --> Entity Framework (Code-First) w/POCO objects approach, and I am having a hard time with updating entities. I am using AutoMapper to map my Domain Objects to my View Models and that works good for getting the data, no how do I get that changes back into the database? Using pure POCO objects, I would assume that there is no sort of change tracking, so I see my only option is to handle it myself. Do you just make sure that your View Models have the

MVP - Presenter and the Service Layer - Where to declare Service Layer

亡梦爱人 提交于 2019-12-05 23:18:44
I'm reading through Architecting Microsoft .Net Solutions for the Enterprise and I try to figure a couple of things out concerning the Presenter and the Service Layer. First off, my Presenter needs to call methods that reside in the Service Layer, like initialize(), save() etc. But where do I place a reference to the service layer? Should it be at class level in the Presenter, or should I define a new service in the presenter methods itself? Second - this isn't really clear in the book either - is this how the processing from the Presenter to the Service Layer works?: public void

Entity Framework Service Layer Update POCO

南楼画角 提交于 2019-12-04 16:38:51
I am using the Service Layer --> Repository --> Entity Framework (Code-First) w/POCO objects approach, and I am having a hard time with updating entities. I am using AutoMapper to map my Domain Objects to my View Models and that works good for getting the data, no how do I get that changes back into the database? Using pure POCO objects, I would assume that there is no sort of change tracking, so I see my only option is to handle it myself. Do you just make sure that your View Models have the EXACT same properties as your Domain Objects? What if I just change a field or two on the View Model?