MVP - Presenter And The Service Layer - Where To Declare Service Layer

Mar 27, 2011

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?:

[code]....

View 1 Replies


Similar Messages:

Business Layer Errors And Service Layer Handling?

Mar 7, 2011

We're building a large web app that has numerous layers. In order to communicate to the business layer we're using a service layer that the web layer calls when data is needed. Unfortunately, it seems that if exceptions are thrown in the business layer, it seems that the services on the web side are wrapping the exceptions and re-throwing them. We're looking for a clear way to encapsulate the error and log it, without WCF wrapping a new exception around the original.

View 2 Replies

C# - N-layer Business/service Layer Design?

Jan 26, 2011

I'm trying to reevaluate our n-layer architecture and would love to get some based on your experiences. Here is our typical .NET n-layer (sometimes n-tier) design.

Project.UI
Project.Services
Project.Business
Project.Model
Project.DataAccess

DataAccess typically consists of Entity Framework 4 and Repository classes. I attempt to follow the Aggregate Root concept in order to avoid having a repository for table, easier said than done in my experience. I tend to have ~70% match between Repositories and Tables.

Model usually consists of my Entity Framework 4 entities, I've been using Self-Tracking EF entities with success.

Business is what I struggle with the most. I typically have a Manager class for every Repository. This class will contain methods like .Add() which will perform business validation before forwarding down to repository.Add().

Services, typically I will only implement this if in fact I am looking to create a web service based solution. This layer will be tasked with marshaling requests/responses between DTOs and entities. And most importantly provide the more coarse grained interface. For example a TradingService.SubmitTrade(), which is really a facade for a business transaction which might include AccountManager.ValidateCash(), OrderManager.SubmitOrder(), etc.

My business layer is very entity centric, really it's just the glue between the entities and the repository, with validation in between. I've seen many designs where the Service Layer is what holds a reference to the repositories (in essence skipping the "business layer"). In essence it serves the same purpose as my Business layer, it does the validation, however its' responsibility (and naming) is a higher level, more coarse grained business transaction. Using the example above the TradingService.submitTrade() will not delegate to any business manager classes, it would itself query the necessary repositories, perform all the validation etc.

I like my design in a sense that I can reuse a business layer method in multiple service calls, however I hate the fact that for every repository I have a matching business layer manager, creating tons of extra work. Maybe the solution is a different type of grouping at the Business Layer level? For example combine individual Manager classes like PhoneManager and EmailManager (note I have Phone entities and Email entities) into a logical Manager class such as ContactsManager (note I don't have a "Contact" entity type). With methods such as ContactManager.GetPhones() and ContactManager.GetEmail(), etc.

View 1 Replies

Architecture :: Should The Unit Of Work Point To The Service Layer Or The Repository And Then The Repository Point To The Service Layer

Jan 26, 2011

Just wondering, in an ASP.NET MVC3 environnement with entity framework. Should the Unit of Work point to the service layer or the repository (and then the repository point to the service layer) ?

Ive saw two example:

* One where the unit of work and repository both have an instance to the service layer..

Link: Entity Framework 4 CTP 4 / CTP 5 Generic Repository Pattern and Unit Testable

Doesn't use a service layer but its obvious that one could be use in that case.

* Second where the unit of work have an instance to the repository which have an instance to the service layer..

[URL]

What would be better ?

View 11 Replies

Use MVP Pattern And Add A Presenter Layer In Web App?

May 12, 2010

I would like to use MVP pattern and add a presenter layer in my web app. EX;- for filling the data in page I am doing like this.

[Code]....

If I add a presenter class, Do I need to move this code in presenter layer?

View 2 Replies

MVC :: Service Layer Validation

Feb 24, 2010

I was going through the MVC samples regarding validation at the service layer and I have a question and probably a dumb question at that.
If you have the item below, the data is already in the product object and this is fine if you are expecting mappings with the correct data types, however presuming UnitsInStock is an Int, then if the user had typed in "banana," and considering that nothing has been validated on the server side at this point, then the app would have failed as soon as you tried to insert "banana" into UnitsInStock when the form returned from wherever at the controller layer.

protected bool ValidateProduct(Product productToValidate)
{
if (productToValidate.Name.Trim().Length == 0)[code]....

So my question is...is there a tricksy way (or best practice way) of dealing with this or do you have to use a "dirtyProduct" all strings object that you validate at the service layer and which returns a clean "Product" object if is "isValid" that can be passed into the repository?

View 4 Replies

Injecting Lower Layer Dependency In Presenter In MVP Application?

Jan 27, 2010

I recently read Phil Haack's post where he gives an example of implementing Model View Presenter for ASP.NET. One of the code snippets shows how the code for the view class.

public partial class _Default : System.Web.UI.Page, IPostEditView
{
PostEditController controller;
public _Default()
{
this.controller = new PostEditController(this, new BlogDataService());
}
}

However, here the view constructs the instance of the BlogDataService and passes it along to the presenter. Ideally the view should not know about BlogDataService or any of the presenter's lower layer dependencies. But i also prefer to keep the BlogDataService as a constructor injected dependency of the presenter as it makes the dependencies of the presenter explicit.

This same question has been asked on stackoverflow here.

One of the answers suggests using a service locator to get the instance of the BlogDataService and passing it along to the presenter's constructor.This solution however does not solve the problem of the view knowing about the BlogDataService and needing to explicitly get a reference to it.

Is there a way to automatically construct the presenter object using an IoC or DI container tool such that the view does not have to deal with explicitly creating the BlogDataService object and also injecting the view and service instances into the presenter's constructor. I prefer to use the constructor injection pattern as far as possible.

Or is there a better design available to solve the problem?. Can there be a better way to implement this If i am building a WinForms application instead of a ASP.NET WebForms application?

View 2 Replies

.net - Data Access Layer As A Web Service?

Aug 18, 2010

I have been researching for a while and have actually created a prototype ASP.NET web service as a DAL for a few ASP.NET 2.0 web sites. Just would like to ask for some insight/advice from more experienced developers out there who had successfully rolled out DAL as a web service. What are the drawbacks/risks to deploying DAL as a web service? What is the best way to secure or authenticate consumption of this web service? WCF is out of the question, I'll be coding in VS 2005.

View 4 Replies

Should The Unit Of Work By Used By The Service Layer Or The Repository

Jan 26, 2011

In an ASP.NET MVC3 environnement with entity framework. Should the Unit of Work point to the service layer or the repository (and then the repository point to the service layer) ?

Ive saw two example:

* One where the unit of work and repository both have an instance to the service layer..

Link: Entity Framework 4 CTP 4 / CTP 5 Generic Repository Pattern and Unit Testable

Doesn't use a service layer but its obvious that one could be use in that case.

* Second where the unit of work have an instance to the repository which have an instance to the service layer..

[URL]

View 16 Replies

MVC :: Data Annotations Or Service Layer Validation?

Feb 10, 2010

I'm creating a Asp.Net MVC application and I need help on whether I should chose Data Annotations or Service Layer Validation (e.g. if(Model.Name.Trim().Length == 0)?

View 5 Replies

MVC :: Passing Values From Controller To Service Layer?

Mar 24, 2011

I am working on Tenant module that has to display following fileds, Tenant Id, Tenant Desc, Contact Person, Contact Phone. In the DB, these are designed as two separate tables - Tenant and Contact. Tenant table has Tenant Id, tenant Desc and Contact Id . Contact table has all the contact related properties. I am using EF as DAL.

To make my system loosely coupled, I have created a repository pattern to talk to EF entities. Also, for validation I am using service layer.

My repository layer has two interfaces and classes corresponding to Tenant and Contact.

public interface ITenantRepository : IRepository<Tenant> // IRepository<T> is a generic interface for CRUD operations
{
Tenant Get(int id);
IEnumerable<Tenanr> List() ;

[Code]....

View 4 Replies

Designing System With Presentation Layer And Web Service Based API

Oct 19, 2010

We are designing a system that has functionality that is essentially the same at the presentation layer and the exposed API layer. My question is what technique / strategy to use so we can get the most reuse out of our code with performance in mind? Here's a simplified example: A user can add a Customer via a web form. This will fire the Customer.Create() method. An API consumer / user can add a Customer via a SOAP / HTTP-POST to a web service which will call the Customer.Create() method.

Imagine these layers:
PRESENTATION
|
|
WEB SERVICE API (Customer.Create() is available here
|
|
FACADE Business Object Interface - Customer.Create() signature is here
|
|
BUSINESS Business object - Customer.Create method() is fleshed out here
|
|
DATA ACCESS - Writes data

The presentation layer SOAP calls the Create() web method, which calls the facade's Create() method which calls the business object's Create() method which wires via the data access layer.

Questions:

Is there a concern about performance in using the API's web services in our presentation layer, or are there alternatives to connect the presentation layer directly to the facade? If so, what technology to use (WCF, Remoting, Web Services, etc)?

View 2 Replies

WCF / ASMX :: Design A Web Service Layer On Top Of Db For Data Integration?

Dec 22, 2010

We're doing a data integration project between a MS Sql Server database and a Microsoft CRM system (through its web services).

We're trying to build a "service" layer on top of the database. The design of our current solution is to use web services for CRUD, with xml being the format of data.

Views are created to consolidate related tables into one entity, and we query these views, using the "SELECT * FROM someview " + "For XML" to generated xml that will be returned from our web services.

For update we're trying to use the same approach - using SQL XML to map updates views, we have "instead of" triggers defined on top of these views, and in these "instead of" triggers we update the underlying tables.

The views/triggers are generated by tools so don't be too concerned with coding efficiency here...

what do you think if we use WCF data Provider to publish a enterprise data model (essentially DTOs) ? p.s., we don't have a BL layer for now, it's all in the stored procedures!!!

What's your opinion on this / any better design?

View 4 Replies

Calling Cached Data (in Service Layer) From A MVC View?

Jul 22, 2010

We are adding tooltips to our ASP.NET MVC product, and we are getting the text from our database (technically, from a cached copy of the data). To do so, we created an Html Helper method:

<%=Html.Tooltip(Model.GetTooltipText(Tooltips.ClientPage.StartDateId))%>

The GetTooltipText method is in our BaseViewModel, and simply uses the passed in Id to fetch the tooltip from cache. Would this be considered a bad design? What other alternatives would we have?

View 1 Replies

Architecture :: How To Pass The Values From Presentation Layer To Business Logic Layer

Oct 26, 2010

I am new to this .NET what is the difference between N-Tier and 3- Tier Architecture. If they are same. How to pass the values from presentation layer to business logic layer.

For Example

I have 10 controls in presentation layer. I passing values to these controls. How the architecture works.

View 3 Replies

Architecture :: Data Access Layer And Business Logic Layer?

Jun 24, 2010

I am building a web site following the tutorials on asp.net. I am using dataset as data access lay, and writing classes to access the dataset. But the example is just basic ideas, how do I retrieve individual table column value in the business layer?For example, if I have a table called Product, I only want to find out what is the product name by product id. I did this in my ProductBLL:

public ProductBLL
{
public int GetProductName(string productId)
{
ProductDataSet.ProductDataTable prodData = Adapter.GetProductById(productId);
[code]...

Is there a better way, or am I doing this correctly? Can anybody give me a reference to a more complicated business logic model?

View 16 Replies

Architecture :: How The Data Pass From One Layer To Another Layer In Mvc Design Pattern

Apr 1, 2010

how the data pass from one layer to another layer in mvc design pattern...

View 2 Replies

MVC :: How To Make Business Layer Seperate From Presentation Layer

Feb 23, 2011

I've even got my JQuery Ajax submission going on now but I've encountered another problem. I *think* it's something to do with the structure I'm using but like I say, I'm fairly newo this.I have my AJAX form submission which builds my "PersonViewModel" (model for the presentation layer) in JSON and sends it to "@Url.Action("RegisterSubmit")" in my Person Controller. Now, I seperate my business layer from my View/presentation layer so in "RegisterSubmit"I'm verifying the model is valid then instantiating a new instance of my business model "Person", adding the values from "PersonViewModel" and then calling my "Save" function.

View 7 Replies

MVC :: Custom Ex Class Be In The Repository Layer Or The Domain Layer?

May 6, 2010

My repositories throw exceptions (System.Exception) when some things go bad and I know this is bad practice.. so i will create a custom exception (DataException). My question is should this custom ex class be in the repository layer or the domain layer? Im thinking it should be in Domain layer where all business objects and repository interfaces live but just want to make sure.

View 3 Replies

Architecture :: How To Pass The Data Between Data Access Layer And Business Acces Layer

Jun 3, 2010

here i have in 3-tier architecture , how to pass the data between DAL and BAL. i am using grid view to edit the data,when ever i click on the edit button all the corresponding fields should come to textboxes. i tried for delete ,it works fine bt not working to EDIT.

View 7 Replies

ADO.NET :: Which Database Layer To Use?

Feb 18, 2011

It's a little bit late for me to be asking this, being already 7 months into development on a large MVC2 web application project for learning languages, but I wanted to get some opinion about what the recommended path for doing database stuff is.Having had no prior experience with commercial databases, I'm pretty confused with all the different options out there.

Because the ASP.NET MVC books use Linq to SQL in the examples, it looked pretty easy, so I just went ahead and used it.My first mistake was that for the models I created abstract interfaces, and then a stand-alone concrete implementation that I could load and save using XML, so I could develop the rest of the application while building up the data model, thinking I could easily provide an alternate implementation of the model classes using Linq to SQL to back it, not using the database design page, just letting the table objects and context do the work. Not being experienced with databases, however, my models were not so easy to reimplement for the database. I'm just about to the point where it is working, albeit there are a few performance problem areas.

So, is Linq to SQL generally the way to go for database stuff? Or is there a more recommended path? I love the simple mapping Linq to Sql provides, but discovered I had to spend a lot of time trying to work around some of its quirks and missing functionality. I found that SQL itself has it's own quirks too, such as problems mixing and matching different languages in strings.

Ideally, I would want something that lets me have a data model that's like an arbitrary heterogenious object tree, using normal collections, and still be able to deal with lots of items with good performance.

View 1 Replies

Looking For Data Layer To Use For Performance?

Jul 29, 2010

I did not post this in database forum because the data will run on an asp.net site.I have 3 solution in my mind and i would like some opinions.What i want to do is create a parent-child relationship on 2 controls.A listbox and a textbox.I will populate the listbox with data(this is taken care of so ignore) and what i want to do is when i click on an item in the listbox then the textbox to show it's joined related item(one item only).This is not a problem in windows forms app but in asp, since i'm new i don't know what would be better for a faster retrieval on the page.So the 3 options i have in mind are:

1)DAL.The standard create a query and let one @parameter wait for the id.

2)ADO.NET with possibly an sqldatasource.In standard forms i would have chosen simple ado.net but in asp?So either constantly open,close the db and retrieve the item or use an sqldatasource and chance the parameter.

3)Asynchronous handler page.Bind the textbox to an asynchronous page that contains the connection and expect the @id parameter.

I admit that i'm not fond of DAL but if it will boost speed then i will use it.But i have a though that says that simple ADO will be faster.

View 16 Replies

Using LINQ In Business Layer?

Sep 28, 2010

I'm wondering how can I use LINQ in here?

Code:
public Northwind.ProductsDataTable GetProducts()
{
[Can I use Linq here?]
return Adapter.GetProducts();
}
I followed the way of using Business Layer through this tutorial and I'm wondering how I can use LINQ there:

View 1 Replies

How To Create A Layer On An Image

Jun 12, 2010

How can I create a Layer on an Image, or Image on another Image?

because it doesn't let me do that, only layer near the image.

View 2 Replies

C# - Static Methods For Biz Layer?

Nov 18, 2010

Actually I have done all my Biz(business layer) and DAL CRUD Opprations using static methodes
and I just send my error messages to my log table a sample of biz layer

public static bool Delete(Guid LogGroupID)
{
using (DAL.ChroXEntities db = new ChroX.DAL.ChroXEntities())
{
var q = (from lg in db.LogGroupSet

[code]...

so what should i do to propagate an user friendly error to my users?

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved