Interface Controller (ViewModel) For Multiple UI's?

Jul 1, 2010

I am currently designing a new .NET application and would like to keep it UI independant.

Whilst I initally would like to use WPF, I would like to have the option of swapping the UI to ASP or WinForms if necessary.

In a layered design:

View - Interface Controller (ViewModel) - Model - Persistance

is it possible to design the Interface Controller so that it will work with different view technologies, or will I need to replace the interface controller at the same time as the View?

View 2 Replies


Similar Messages:

MVC :: Can Pass The _businessLayer Variable From The Controller To The Viewmodel?

Dec 21, 2010

I am creating an instance of a business layer in the constructor of my Controller and then I am passing this to my view model like this;

[Code]....

The problem is when I make a post from the view with the viewmodel, I get an error that MyViewModel doesn't have a parameterless constructor defined, and I don't want it to have. Is there anyway I can pass the _businessLayer variable from the controller to the viewmodel when it's constructed "on the fly" in a method like this;

[Code]....

Maybe by using a custom model binder?

View 15 Replies

MVC :: Passing ViewModel With Data From View To Controller

Dec 13, 2010

I am trying to pass a view model of mine, which has multiple list in it, to my view. Then in my view i need to edit the different list. Then on my post i need to save the edits. Although, when i pass my viewmodel back to my post, it is empty! Can somebody explain what i am doing wrong? Controller

[Code]....
here is my View

[Code]....

NewsViewModel

[Code]....

View 2 Replies

The Model-Repository-Service-Validator-View-ViewModel-Controller Design Pattern

Jan 19, 2010

When I first heard about ASP.NET MVC, I was thinking that would mean applications with three parts: model, view, and controller.

Then I read NerdDinner and learned the ways of repositories and view-models. Next, I read this tutorial and soon became sold on the virtues of a service layer. Finally, I read the Fluent Validation documentation, and I'll be darned if I didn't end up writing a bunch of validators.

Tonight, I took a step back and thought about what had become of my project. It seems to have become the victim of the design pattern equivalent of "feature creep". Somehow I'd gone from Model-View-Controller to Model-Repository-Service-Validator-View-ViewModel-Controller. You want loosely coupled and DRY? We got your loosely coupled and DRY right here! But I'm wondering if this could be a case of too much of a good thing.

Am I right to be concerned? Or is this actually not as crazy as it sounds? On one hand, it seems crazy to have so many layers. On the other hand, every layer has a clearly defined purpose that makes sense to me. Have your MVC applications turned into MRSVVVMC apps too? If not, what do they look like? Where's that right balance?

View 2 Replies

C# - Is It Possible To Map Multiple DTO Objects To A Single ViewModel Using Automapper

Jan 24, 2010

I was wondering if it is possible to map multiple DTO objects to a single ViewModel object using Automapper?

Essentially, I have multiple DTO objects and would like to display information from each on a single screen in ASP.NET MVC 2.0. To do so I would like to flatten the DTO objects (or parts of them...) into the Viewmodel and pass said viewmodel to the view. If I had one DTO this would be easy, but I've never seen it being done with multiple. Obviously there are a number of roundabout ways to do this (outside of automapper), but this is the approach that I would like to take if possible.

View 1 Replies

MVC :: Show Same Table In Multiple Controller?

Jan 23, 2011

I have like 5-6 controllers that I need to show the same table ( got the datas from DB ).

So I got 2 questions:

- How can I use WebGrid and MVC to show 2 tables with different datas in the same view.

Because now, I use a ViewModel and then the WebGrid takes Model has his data-source.

- Is there a way to include that table in 5-6 pages. I know with PHP, i can do a Include() and the trick is done...

View 4 Replies

C# - Using Grasp Controller With MVC Controller - How To Make An Object Always Visible For A Controller

Dec 28, 2010

UML and Patterns: An Introduction to Object-Oriented Analysis and Design and Iterative Development, that follows the UP(Unified Process). It uses a Grasp Controller pattern to interact with domain classes by some methods like NewSale(), AddNewItemToSale() and CloseSale. In windows form, I can instantiate a object of this class in the UI and then use its methods to perform the actions. This works well in Client apps, but when I use asp.net mvc, I cannot find a way to instantiate an object (one for each user) that was always visible for a Controller (MVC). I cannot insert as an attribute inside Controller because it always create a new one.

View 1 Replies

MVC :: Render Multiple Grid View From Controller?

Feb 7, 2011

I'm rendering a gridview from a controller by adding data logic. On the same page I would like to render another grid by binding it to anoither data source / linq query.

When I do it for one, I do the following

[Code]....

How do I render another data source to the same page ?? I havent done it before, and would like to know if it can be done and if so how!

View 6 Replies

MVC :: How To Implement Multiple Synchronization Points On Controller Async Action

Feb 28, 2010

What best synchronization feature should I use in my asynccontroller action? [calling while(OutstandingActions > 0) is not an option)],

a. Async fetch 3 items from data service in parallel,

b. synchronize.

c. compute a value using the 3.

d. async save all 3 results to data service in parallel.

e.synchronize.

f. finish

View 9 Replies

MVC :: Data Annotations, View Models & Multiple Controller Actions?

Feb 17, 2010

quick question: I have a view on my HomeController which is used to create a new 'model'. This view posts to a different controller to keep things tidy. The problem I am having is when I enter invalid details into the form, the rules I specified never seem to make it back to the original view and thus my validation messages or summary never get populated. Is there a way around this because I am using a view model with two IEnumerable lists in it.

View 5 Replies

MVC :: Using Data From Multiple Entity Framework4 Model Entity Objects In MVC2 Controller?

Sep 29, 2010

getting data from multiple Entities models into an MVC controller. Most of the examples I have seen for using EF in an MVC2 app only use a single entitiy.

I have just started using MVC2 in C# using the Entity Framework models (CIOps.model) created from an SQL database. I can create the controller and views using single tables of the model in MVC2, but I just cannot get my head around how to get data from multiple entity tables into the controller (similar to joins in T-SQL). I have included an example below of the controller code that works with a single entity table, tbl_tours (tbl_tour in DB).

Could someone please illustrate how this code would be changed to include additional columns from FK tables in addition to tbl_tours columns. E.g. the clients name from the tbl_clients, the coordinators name from the tbl_employees, and costs from tbl_costs entities? Is it possible to do this directly using the EF model entities/classes that are already created and not use LINQ, POCO, Repositories, etc.? The FK relationships are already in the EF models. I have included the whole controller code, but I just need a few examples of how to join the multiple entities, not rewrite every CRUD function function in the controller. I think this will get me over the hump in using EF in an MVC2 App. Also ignore the fact I am using the home controller, this will change in the application.

[Code]....

View 21 Replies

Data Controls :: Share Data Between Multiple Action Methods Inside A Controller

Mar 17, 2014

I have one controller with 4 to 5 action method. In all action method i have to check some feilds from database. So to reduce the database query i want to save this data one time and then want to use that in all action method. I know about tempdata and view bag but none of this can use in different action method, so how to achive this.

View 1 Replies

MVC :: Out Of The Box MVC2 Controller / Delete Controller Is Refusing To Return Any Class Information

Nov 6, 2010

my MVC2 delete and only my delete controller is refusing to return any class information. Its really similar to my edit function and the views are all auto-generated so I don't see the problem.

Function Delete(ByVal id As Integer) As ActionResult

View 4 Replies

MVC :: Pass Parameter From Controller To View And Back To Another Controller?

Aug 16, 2010

I have a simple model where a Person has Gifts. I have a view which is a list of Gifts belonging to one Person.

My problem is with the Create action for a new Gift. I want it to default to the PersonID that we are already viewing the list of Gifts for. I tried simply passing the last PersonID (they are all the same)

Html.ActionLink("Create New", "Create", new { id = Model.Last().PersonID }) which works fine if there is already at least one Gift for that person but if this is the first Gift I don't have a value.

My Gift List controller knows the PersonID I want to pass but the view doesn't.

How do I pass this PersonID from my Gift List controller to my Gift Create controller via the Gift List view? Or is there a better way to do this?

View 2 Replies

MVC :: Session Vs TempData / How To Persist Values From Controller To Controller

May 30, 2010

I have a filter on my MVC web site. I display some records in a few different controller actions but when moving from one action to another I want to apply those filter values.

How can I persist values from controller to controller?

Should I use Session? TempData?

I am using Structure Map for IOC.

Maybe I could have a class that contains a Property for each Session Value that I use in my application and inject it on the controllers that need session?

View 10 Replies

MVC :: Get The Current Action / Controller Name In A Controller Or Class?

Mar 14, 2011

How do you get the current action / controller name in a controller or class?

i can't show it in my view but that's not what i want.

View 1 Replies

Does 1 ViewModel Really Have 1 View

Feb 16, 2010

its said that 1 ViewModel has 1 View. 1 View is for me a UserControl. What if my UserControl has different areas filled with data from different entities, do I have then several Views and need to build several ViewModels? e.g: I display in a UserControl 3 entities: customer(listbox),order(datagrid),product(datagrid). Each of those "data areas" has add+remove buttons and textboxes to enter data.

Actually each of those "data areas" are put in its own GRID having so the posibility to set a individual datacontext.

1.) Should I now create 3 ViewModels CustomerVM,OrderVM and ProductVM?
2.) Are those 3 "data areas" seen as an own sort of separated View, although I have not put them in 3 UserControls.xaml files ???
3.) When this one UserControl is inside a TabControl`s tabpage where do I load the 3 entities related data? Inside the MainViewModel? I want to show/load that data only when the user clicks the tabheader.

View 1 Replies

C# - MVC ViewModel And DropDownList

Jan 30, 2010

I have 2 properties in my ViewModel

class ViewModel1
{
Dictonary<int, string> PossibleValues {get;set;}//key/value
int SelectedKey {get;set}
}

I want to edit this using a Html.DropDownListFor I want to get MVC to auto serialize the data into/from the ViewModel so I can the following

public ActionResult Edit(ViewModel1 model) ...

View 3 Replies

MVC :: C# Controller Works, VB Controller Doesn't ?

Jul 22, 2010

C#: HomeController.vb: works fine HttpPost RsvpForm gets the object filled with user input.

using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.Mvc;using RsvpInC.Models; namespace RsvpInC.Controllers{ public class HomeController : Controller { //
[code]...

View 5 Replies

MVC :: Calling Action Of A Controller From Another Controller?

Jan 24, 2011

I have a User entity and a department entity. I have a UserViewModel and DepartmentListModel which has List of departments.

UserViewModel has a property of type DepartmentListModel .

Now on user/create action I need to populate DepartmentListModel by calling DepartmentController's list action. List action returns populated DepartmentListViewModel.

From UserController how do I set DepartmentListModel ?

I tried doing so

[Code]....

But RedirectToAction returns RediretToRouteResult

View 7 Replies

C# - Difference Between ViewData And ViewModel

Mar 3, 2011

I'm new to .Net development, and now are following NerdDinner tutorial. Just wondering if any of you would be able to tell me What is the differences between ViewData and ViewModel(all I know is they are used to pass some form of data from controller to view) and perhaps tell me on what situation should I use ViewData instead of ViewModel and vice versa

View 1 Replies

Update A ViewModel In MVC2?

Mar 2, 2010

[HttpPost]
public ActionResult Edit(int id, FormCollection fc)
{
Movie movie =
(
from m in _ctx.Movie.Include("MovieActors")
where m.MovieID == id select m
).First();
MovieActorViewModel movieActor = new MovieActorViewModel(movie);
if (TryUpdateModel(movieActor))
{
_ctx.ApplyPropertyChanges(movieActor.Movie.EntityKey.EntitySetName,
movieActor.Movie);
_ctx.SaveChanges();
}
return View(movieActor);
}

However, I am not sure how to test this, and in general would much rather have the method take a typed model like:[HttpPost] public ActionResult Edit(MovieActorViewModel movieActor) Is this possible? What changes to my MovieActorViewModel class do I need to make in order to enable this? That class looks like this:

public class MovieActorViewModel
{
public Movie Movie { get; set; }
public Actor Actor { get; set; }
public PublisherDealViewModel(Movie movie)
{
this.Movie = movie;
this.Actor =
(
from a in this.Movie.Actors
where a.ActorID == 1 select a
).First();
}
}

The view is typed (inherits ViewPage) simple:

<% using (Html.BeginForm()) {%>
Movie Title: <%= Html.TextBoxFor(model=>model.Movie.Title) %><br/>
Actor Name: <%= Html.TextBoxFor(model=>model.Actor.Name) %>
<% } %>

View 3 Replies

Mvc IDataErrorInfo Validation When Using ViewModel?

Jun 20, 2010

I have used IDataErrorInfo Validation for my Model.

But when I use these model classes inside a view model, the validation does not happen.

sample viewmodel below

[code]....

Now, if Category or Subcategory classes are directly used as models for view, the validation works fine. But, if CategoryViewModel is used, no validation occurs.

View 1 Replies

C# - MVC - Getting ViewModel Object From ListBoxFor

Jan 9, 2011

I'm trying to get my own viewmodel after submit my form and I got the following error:

"Unable to cast object of type 'System.String[]' to type 'System.String'"

This is my code:

ViewMode:

public class SoftwarePackages
{
public string[] PermissionsList { get; set; }[code].....

View 3 Replies

MVC :: When More Than One Table Associated With - ViewModel How To Write It

Jan 19, 2010

A table can be used to automatically sense Model. But when I get more than one table after the SQL query is a DataTable. When this DataTable to return View (DataTable) later. In the aspx file, can automatically perceive it as the Model, as the self-paragraphs?

[Code]....

View 4 Replies







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