viewmodel

Bbinding combobox within dataform to view model property outside dataform's context

為{幸葍}努か 提交于 2019-11-28 13:05:49
I have two properties in my view model: //Relationship has property ReasonForEndingId private Relationship editRelationship; public Relationship EditRelationship { get { return editRelationship; } set { if (editRelationship != value) { editRelationship = value; RaisePropertyChanged(EditRelationshipChangedEventArgs); } } } //ReasonForLeaving has properties Reason & Id private IList<ReasonForLeaving> reasonsComboList { get; set; } public IList<ReasonForLeaving> ReasonsComboList { get { return reasonsComboList; } private set { if (reasonsComboList != value) { reasonsComboList = value;

How to use ViewModels in ASP.NET MVC?

半城伤御伤魂 提交于 2019-11-28 09:20:56
I just started learning about ViewModels in ASP.NET MVC. So, I thought of implementing a sample example as below: Business Entity public class AddModel { public int a { get; set; } public int b { get; set; } public int Add() { return (this.a + this.b); } } Add ViewModel public class AddViewModel { public AddModel addModel; public int Total { get; set; } } Controller public class AddController : Controller { [HttpPost] public JsonResult Add(AddViewModel model) { int iSum = model.addModel.a + model.addModel.b; model.Total = iSum; return Json(model); } public ActionResult Index() { return View();

LiveData is not updating its value after first call

自古美人都是妖i 提交于 2019-11-28 07:37:20
I have been beating my head against the wall and I cannot understand why this is happening. I am working with the new Architectural Components for Android and I am having problems updating a LiveData with a List of Objects. I have two spinners. When i change the option in the first one, The second one must have its content changed. But this last part is not happening. Can anyone help me? State.java @Entity(tableName = "states") public class State{ @PrimaryKey(autoGenerate = false) private int id; private String name; @ColumnInfo(name = "countryId") private String CountryId; @Ignore private

how to design ViewModel

痴心易碎 提交于 2019-11-28 07:03:28
I have EF 4 implemented in the project. Within it, there are tables customer and order. Which has relationship one (customer) to many (order). I'm creating a viewmodel for both (CustomerViewModel and OrderViewModel) to be passed from my domain layer to interface layer (MVC in this case). Now the question is "do I need to reference both viewmodel? for example in customerviewmodel has IEnumerable<OrderViewModel> and in orderviewmodel has CustomerViewModel . If so how do I design it (as a best practice) so that IEnumerable<OrderViewModel> and CustomerViewModel is populated with the correct

WPF Event Binding to ViewModel (for non-Command classes)

可紊 提交于 2019-11-28 06:55:29
I'm working an the second version of an application, and as part of the rewrite I have to move to an MVVM architecture. I'm getting pressure to put absolutely every bit of code in the view model class--having c# in the code behind file is frowned upon. (I know, I know...I understand that code behind isn't a bad thing, but it isn't my call this time). For objects which implement the command interface, it's easy. I've been able to find a ton of information on how to bind the Command of these objects to an ICommand in the view model. The problem is for objects which don't have this interface, e.g

Using Automapper to update an existing Entity POCO

陌路散爱 提交于 2019-11-28 06:55:20
I am using EF4 DbContext to provide the model for an ASP.NET MVC app. I use ViewModels to provide data to the views and Automapper to perform the mapping between the EF POCOs and the ViewModels. Automapper does a great job but I'm not clear the best way to use it after the ViewModel is posted back to the controller to carry out an update. My idea is to get POCO object using a key contained in the ViewModel. I then want to use Automapper to update the POCO with data from the ViewModel: [HttpPost] public ActionResult Edit(PatientView viewModel) { Patient patient = db.Patients.Find(viewModel.Id);

Model binding in controller when form is posted - why to use view model instead of class from domain model?

巧了我就是萌 提交于 2019-11-28 05:53:03
问题 I'm still reasonably new to ASP.NET MVC 3. I have come across view models and their use for passing data from a controller to the view. In my recent question on model binding two experts suggested that I should use view models for model binding as well. This is something I haven't come across before. But both guys have assured me that it is best practise. Could someone maybe shed some light on the reasons why view models are more suitable for model binding? Here is an example situation: I

MVVM Main window control bind from child user control

情到浓时终转凉″ 提交于 2019-11-28 05:45:37
问题 I’m very new to MVVM and getting my first POC done now. However, I have been hitting my head to get one issue resolved for 2 days. Thought of explaining to you guys may help and resolve the issue so quickly. Let me brief my issue now. I have WPF MVVM application with a main View bound to MainViewModel. I have Textblock here to bind some content from the viewmodel while loading the screen which is working awesome. I also have ChildUserControl bound to ChildViewModel. Now, I need to bind

MVC3 - Viewmodel with list of complex types

懵懂的女人 提交于 2019-11-28 05:27:27
Apologies if this has been asked before; there are a million ways to phrase it so searching for an answer has proved difficult. I have a viewmodel with the following properties: public class AssignSoftwareLicenseViewModel { public int LicenseId { get; set; } public ICollection<SelectableDeviceViewModel> Devices { get; set; } } A simplified version of SelectableDeviceViewModel would be this: public class SelectableDeviceViewModel { public int DeviceInstanceId { get; set; } public bool IsSelected { get; set; } public string Name { get; set; } } In my View, I am attempting to display a list of

EF Entities vs. Service Models vs. View Models (MVC)

戏子无情 提交于 2019-11-28 04:59:28
I'm trying to understand and figure good practices for designing your app/domain models (POCOs/DTOs). Let's say I have the following database table, Account: UserID int Email varchar(50) PasswordHash varchar(250) PasswordSalt varchar(250) Of course, EF4 would build the entity like so: public class Account { public int UserID { get; set; } public string Email { get; set; } public string PasswordHash { get; set; } public string PasswordSalt { get; set; } } Now, let's say I have a view model for registering a new user, which may look something like so: public class RegistrationViewModel { public