MVC :: Edit Models In Different Project Layer?

Mar 15, 2011

I have a MVC3 solution named "SampleProject". I have 4 projects in the solution.

The project names of the solution are

SampleProject.Data (holds entity classes, DAL classes, and filter classes)
SampleProject.Service (something like BLL in standard ERP)
SampleProject.Tests (test project)
SampleProject.Web (holds controllers and views)

I am calling the Service classes from my controllers. The service classes are calling Data classes and performing the database operations.

I have done create, list and details part. Now I stucked in Edit part. None of the examples (NerdDinner,MVCMusicStore etc) using my architecture. In the provided examples, they are just using built in UpdateModel method which I don't want to use. I want to manually get the model object from my view and send it to my Data layer for update.

View 1 Replies


Similar Messages:

MVC :: Managing Add Vs Edit Models?

Apr 22, 2010

I've half written an app which has just one model for adding and editing a particular entity.I am trying to embrace modelmetadata and where possible reduce my form code to just calls for EditorForModel. One of the key issues I am having it managing the
differences between a add and update scenario.

Take "User" editing for example, in an Add scenario I want "Password" to be a required field, in an update scenario I dont' want it to be a required field. The model-centric approach would have me create two models, one for adding and one for editing. My
edit model wouldn't have the Required attribute on the Password field. My feeling is this is going to create a bit too much plumbing.


Besides having a rather massive amount of automapping going on there is another more irrititating issue. Strongly typed views. I could... maybe see my way to having a different model for create and edit, using inheritance i could.. maybe mitigate the amount of code required. What I can't abide is having to have two seperate views, as I have already coding myself into a wall with strongly typed views I couldn't share add and edit (based on my understanding) scenarios with one view.

So anyway I was wondering what other peoplle are doing to manage this? Working with an outsourced (Indian) developers it would be great to make use of EditorForModel as I want them writing as little code as possible.

View 14 Replies

MVC :: Move Controllers/Models Into A New Project/Assembly?

Oct 6, 2010

I have to admit first, that for the last few years, I've been mostly an MVP guy versus MVC. However, how I used to implement MVP is very similar to how MVC 2 is now implemented. I only have one issue with it...When I used to create MVP apps, I could put all my logic (presenters, models) into separate assemblies/projects in the solution and my views into the main web app. This allows me to change the UI (i.e. the web based UI) to something else like a smart client or Silverlight or whatever and still have everything just work. With MVC 2, everything is all in the same project: controllers, views, models. Areas looked like a good start, but ultimately, not what I was looking for.So, here's my question... How do I move the controllers and models out of the web project and into their own projects and still have everything work? A good, simple example would be the default MVC 2 web application template. When you open a new (non-empty) MVC web application, it creates a basic site for you. From there, how could I move the controllers and models in separate projects and still have everything just work? I can't seem to find anything on this anywhere else which has brought me here

View 13 Replies

C# - MVC, EF Layer, And Automapper Setup For A Project

Jan 17, 2011

I'm trying to figure out the best approach to architecting this project. Basically, it's a "band" profile site. I'm using ASP.NET 4, EF, and Automapper (structuremap too, but that's not important). I'm running into performance issues I have a EntityFramework repository class that interacts directly onto the EF objects using LINQ:

[Pluggable("Repository")]
public class EntityDataRepository : IRepository
static EntityDataRepository()
// other mappings removed
// Data. objects are EF objects, mapping to my DTO classes
[code]...

View 1 Replies

ADO.NET ::change LINQ To SQL Code In Data Access Layer Project?

Sep 2, 2010

I am working on a project in which I have made changes to LINQ to SQL code in data access layer project.Initially the code was using Single() extension method, I have changed it to SingleOrDefault() was earlier method was throwing exception if no records found in db.

After making changes I ran the project but during debugging VS 2008 was showing that file is changed and do you want to reload the file box. When selected the file, the debugger was still executing the commented code (Single() method).I tried cleaning the entire solution and rebuilding it but it did not help. All the projects (Presentation, BL, DAL) are under single solution.

View 1 Replies

MVC :: Making Base Models With View Models

Nov 3, 2010

i have a base controller that looks like this:

[Code]....

and a contact model that inherits from the base model.

the master page inherits form the base model,

nad the contact page inherits from the contact nodel,

but then i get an error while loading the contact page that it expects the contact model but gets the base model?

View 9 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

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

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

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

Sample Project For Select, Edit, Delete And Insert In New Page?

Jan 29, 2010

Lot of times I did edit, delete, insert in my webproject in different pages but I am very surprised that why I am not remembering the technique to do these task. Actualy I never take any course on asp.net/vb.net, what I did in my project just to take help from forum or asp.net website etc. I get a task again to make a web interface having functionality to view data and provide Edit functionality also. The other task is to click a link in the same page to open a new page with the fields of the same table to insert new record.

Q1: Is it necessary to take a dataset or I simply do it using sqlDatasource?

Q2: Could anyone give me a very basic and simple vb.net/asp.net project with all above tasks so that I will do a practice project and never miss it?

View 2 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

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

How To Get Code Coverage Working On A VS 2010 Project/Cannot Initialize The Project 'Project Name'

May 23, 2010

When I turn on Code Coverage in my test settings, on a project that references the Unity DI container I get the following error:

Cannot initialize the ASP.NET project'{Project Name}'.

The event log specifies the following reason:

Could not load file or assembly 'Microsoft.Practices.Unity, Version=2.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. Strong name signature could not be verified.

View 2 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

MVC :: Getting 2 Models From A Form?

Mar 17, 2011

I am doing a registration form where the user enters his account information, and some other misc. information.

The misc. information are stored in another table and hence has its own model.

How do I have the model binder creates 2 model, or should I have one combined model?

View 1 Replies

C# - EF4 Two Models One Database?

Jan 21, 2011

I have been searching for this answer and can't seem to find anything, but with EF4 I want to create a base model and put in our 'foundation' and any new project we create if we need to add custom tables to that sites db is it possible to add a model with just those specific tables and link it to the model in our 'foundation' I can't seem to find a good resource on something like this and this seems to be like it would be a normal thing to have a reusable base model and a separate one for any one off's

View 1 Replies

MVC :: How To Have Multiple Models Per View

Apr 14, 2010

<%@ Page
Title=""
Language="C#"
MasterPageFile="~/Views/Shared/Site.Master"
Inherits="System.Web.Mvc.ViewPage<JCIOrange.Models.UserProfile>" %>

How do I display more than one model per view? The above line limits me to only display UserProfiles. I want to also display other models, like UserJob and etc....how would I go about doing so?

View 1 Replies

MVC :: Annotating ADO.Net EDM-generated Models?

Jan 24, 2011

I created a model via adding an ADO.Net Entity Data Model (.edmx file), which brought in all my tables from my database. Is it possible to add validation attributes like [Required] or [Display] to a model created like this? Otherwise, the only alternative I can see is to hand-create a model class with public properties where I can annonate them with the attributes I need.

View 2 Replies

Use RenderPartial Twice In View With Different Models Associated?

Mar 18, 2010

I want to use RenderPartial twice in my view with different models associated. The problem is that some properties are present in both models (nickname, password). They have no prefix, so even the id's or names are equal in the output. Now, if I have model errors for nickname or password, both fields get highlighted.

Main View:

[code]...

How can I change this?

View 4 Replies

MVC :: Two Models Passed To A One View?

Sep 6, 2010

I'm trying to develop my application and I've got a master page where I'm planning to create a div container, where my "news" will be loaded from my database and will be shown always on a main site. Then inside of the main placeholder I'm planning to load some extra data too from my database... and there's the question: how to solve that ? is there any possibility to pass a model to a master page ? or two viemodels to a view page inside the main placeholder on my page ? (one with news, and other containing some other data).

View 4 Replies

MVC :: Use Multiple Models In A Page?

Mar 8, 2011

Is it possible to do something like this?

Inherits="System.Web.Mvc.ViewPage<List<SectionAdmin.Models.ADirectory>>, <List<SectionAdmin.Models.BDirectory>>"

I am trying to use both models in my page.

View 8 Replies







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