viewmodel

Bind to a Dictionary of Lists of Lists of Bools with a strongly-typed MVC view by using Checkboxes

落爺英雄遲暮 提交于 2019-12-20 11:31:01
问题 I'm using MVC 4, .Net 4, and Visual Studio 2012. I'm trying to use a fairly complex model with one of my views, and I'm having serious trouble getting it to bind properly. The model wraps a Dictionary with integer Keys, and Values that are Lists of Lists of bools. Basically, a search was done on items indicated by the integer, each item had several search terms, and for each of those terms we have a list of results. I display the results on a page, and have a checkbox next to each result. For

Designing an MVC repository using ViewModels

家住魔仙堡 提交于 2019-12-20 10:47:15
问题 I want to create a repository class to separate out my data logic from my controllers. I am using a ViewModel to represent some data that will be filled with data from different tables. Here are some questions I have: For a method like GetAll() , do I return an IQueryable<MyViewModel> or IQueryable<Entity> ? If I return viewmodels, how do I cope with a GetAll() that pulls thousands of records? Do I create a constructor for my custom ViewModel class that takes the Entity as a parameter to do

WPF MVVM Unit Tests for the ViewModel? [closed]

大城市里の小女人 提交于 2019-12-20 09:48:18
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed last year . I keep reading about the benefits of using MVVM, especially for unit testing. So, now I need to write unit tests for my ViewModel. Does anyone have any examples of this? Should I just generate the unit tests using VS2008 and select those tests that appear important? 来源: https://stackoverflow.com/questions/1441534

Validation on ViewModels in ASP.NET MVC

前提是你 提交于 2019-12-20 09:31:33
问题 Most of the tips on how to implement validation in ASP.NET MVC seem to center around the Model (either building service layers between model and controller or decorating properties of the model with validation attributes). In my application I use ViewModels for all communication between the controllers and the views. I have a ViewModel for my login page called 'LoginViewModel' with a property called 'EmailAddress'. When the user enters their email address and clicks submit, this ViewModel is

Usage of MVVM in iOS

两盒软妹~` 提交于 2019-12-20 08:37:56
问题 I'm an iOS developer and I'm guilty of having Massive View Controllers in my projects so I've been searching for a better way to structure my projects and came across the MVVM (Model-View-ViewModel) architecture. I've been reading a lot of MVVM with iOS and I have a couple of questions. I'll explain my issues with an example. I have a view controller called LoginViewController . LoginViewController.swift import UIKit class LoginViewController: UIViewController { @IBOutlet private var

MVVMLight UserControl View Model-Create new Instance of User control for each view

三世轮回 提交于 2019-12-19 11:33:39
问题 I have a user control of list of Patients which I use in other Views. However when I choose one of the Patients, the selection is propagated to all the views containing an instance of the user control. How can I make each view instantiate a new instance of the user control for each view? I am using c# 回答1: Guessing from what you stated, I'd assume that you returning a static instance of you PatientViewModel from you locator. To solve this make sure that when the property is called a new

ASP.NET MVC: Nesting ViewModels within each other, antipattern or no?

本秂侑毒 提交于 2019-12-19 03:25:46
问题 I have a project where ViewModels are nested within each other such that they essentially are a string-typed replication of the domain hierarchy. For example, if our domain has the following relationships: Organization has 1 to many Environments Environment has 1 to many Machines then there will be an OrganizationViewModel that has one to many EnvironmentViewModels in it, and the EnvironmentViewModel will have one to many MachineViewModels themselves. This style of hierarchy is then reused

MVC3 using CheckBox with a complex viewmodel

大憨熊 提交于 2019-12-18 18:23:09
问题 Right guys. I need your brains as I can't find a way to do this properly. I have a view model: public class EditUserViewModel { public User User; public IQueryable<ServiceLicense> ServiceLicenses; } User is unimportant as I know how to deal with it. ServiceLicenses has the following implementation: public class ServiceLicense { public Guid ServiceId { get; set; } public string ServiceName { get; set; } public bool GotLic { get; set; } } Getting a checked list of users is cool. It works like a

How do I use AutoMapper to map multiple subclasses into one class?

本小妞迷上赌 提交于 2019-12-18 15:09:35
问题 Let's assume I have three classes that are subclasses of a base class: public class BaseClass { public string BaseName { get; set; } } public class Subclass1 : BaseClass { public string SubName1 { get; set; } } public class Subclass2 : BaseClass { public string SubName2 { get; set; } } public class Subclass3 : BaseClass { public string SubName3 { get; set; } } I would like to map these to a ViewModel class that looks like this: public class ViewModel { public string BaseName { get; set; }

difference between models and view models

北城余情 提交于 2019-12-18 11:54:12
问题 I have been researching asp.net MVC project structure's for a new project and have a question about something is confusing me. What is the difference between models and view models? Would I be correct in saying that view models encompass models in the form properties? 回答1: I've a blog where I want to display the list of the latest posts , latest comments , post categories in a single view. How I can do that? I can strongly type my view to any one of the model right? There comes view model . I