Questions tagged [view-model-pattern]

25 questions
21
votes
2 answers

Does ViewModel survive Activity save and restore?

Instances of the new ViewModel class can survive configuration changes if used in the following fashion: mViewModel = ViewModelProviders.of(this).get(MyViewModel.class); However, in addition to configuration changes, there is also a save-restore…
5
votes
3 answers

Does ViewModel decrease web apps performace

As far as I can understand using view models can make web dev. life much easier, in sense that we can use this approach for display only needed properties in localized strings. Also I use in mvc3 view models jquery validation, etc. Right now I'm in…
BobRock
  • 3,477
  • 3
  • 31
  • 48
4
votes
2 answers

Couple of questions about asp.net MVC view model patterns

I'm new to MVC. I have read this short bit detailing three ways of dealing with the view model in MVC: http://geekswithblogs.net/michelotti/archive/2009/10/25/asp.net-mvc-view-model-patterns.aspx The gist of it seems to me that: Method 1, pull an…
NibblyPig
  • 51,118
  • 72
  • 200
  • 356
3
votes
3 answers

MVC: Repository and Viewmodels both pattern together for better structure?

If I want to combine using repositorys per entity and Viewmodels per view how does it work out? Any website tips I could look up? Maby someone could give an easy example? Thanks Best Regards!
3
votes
3 answers

ASP.NET MVC - View Model pattern

I have only been working with the MVC framework (ASP.NET MVC2/3/Razor) for a few months now and I am really enjoying it, however I am having a hard time figuring out a standard for View Models. In my projects, I have a Models folder (Contains my…
Keith
  • 5,311
  • 3
  • 34
  • 50
2
votes
2 answers

ViewModel vs Domain Entities

Before I start, I want to say that I know what a ViewModel is, and what its purpose is, but this scenario makes it redundant .. please read on :) I am working on an ASP.NET MVC4 application, and have come across some headache with regards to…
J86
  • 14,345
  • 47
  • 130
  • 228
2
votes
2 answers

Possible bad practice in Web API ViewModel pattern?

I'm currently implementing ViewModels within my WebApi by injecting a Model object into the constructor of my 'ViewModelProduct' Object, as shown: public class ViewModelProduct { private IProduct _product; private int _ID; private…
user1352057
  • 3,162
  • 9
  • 51
  • 117
2
votes
1 answer

MVVM: Should a ViewModel have a member to another ViewModel?

The dependent ViewModel gets injected via the constructor (IoC container). Example: ProductSelectionViewModel uses ShoppingBasketViewModel. Is this a common practice or is this THE recommended way? I don´t think so... How should it be done…
timmkrause
  • 3,367
  • 4
  • 32
  • 59
1
vote
1 answer

Flutter access method of ViewModel into another ViewModel

i've a problem related to view models. I need to access the method of this viewModel: class TheacerViewModel{ Teacher _teacherX; TeacherViewModel(Teacher teacherX): _teacherX = teacherX; String get name{ return _teacherX.name; } …
user13295460
1
vote
1 answer

How does ViewModel locator work in a modularized System

when I do MVVM Applications I usually have a central ViewModel locator which works with the service locator pattern. This allows me to inject ViewModel with Services via Ninject My ViewModel locator usually looks like this: public class…
silverfighter
  • 6,762
  • 10
  • 46
  • 73
1
vote
1 answer

should we Log in same Database or separate database

So far I was using a file system for the logging, now planning to move for the Database system. I am planning to the same database and different collection ( NoSQL term) /table for the logs. Is it safe to use the same database or better to use a…
1
vote
1 answer

Displaying all data in MVC view

This is my first MVC project from scratch and I'm trying to display multiple repeating record data in the view when it first loads and then allow the user to edit the fields on the same page when the edit button is clicked and save the data for that…
iambdot
  • 887
  • 2
  • 10
  • 28
1
vote
2 answers

Should I unit test the methods or commands on a view model?

I just finished watching Jason Dolinger's video on MVVM, and I'd like some clarification on how to properly setup and unit test the ICommand properties of my view models. Consider the following ViewModel class with a FooBarCommand…
Eric Anastas
  • 21,675
  • 38
  • 142
  • 236
1
vote
3 answers

Multiple viewmodel interacting with each other

I'm working on a Surface WPF project where we try to implement the MVVM pattern. Within this project we are building a few custom controls which we bind to different viewmodels. For example we have a settings control which has a settings viewmodel…
ChristiaanV
  • 5,401
  • 3
  • 32
  • 42
1
vote
1 answer

MVC3 best practices to save view with multiple entities

Given an MVC3 app using the ViewModel pattern and the Repository pattern with Entity Framework. If I have a create and update view each composed of multiple entities,  what is the best practice for saving the data? Should I save the date using an…
1
2