viewmodel

Automapper Mapping IEnumerable<SelectListItem> for Dropdown Menu

谁都会走 提交于 2019-12-21 21:49:11
问题 Problem I am currently adding automapping to my MVC project and I am stuck. Right now I have a User model used to represent data in the database. I have to map that model to a EditUserModel which will be used when the Edit method is called. The EditUserModel has IEnumerable<SelectListItem> (for a dropdown menu) that I can't seem to figure out how to map. Attempted Solution As of right now I haven't tried to implement anything. I am unsure where the best place for the IEnumerable

Passing ViewModel in ASP.Net MVC from a View to a different View using Get

筅森魡賤 提交于 2019-12-21 21:24:31
问题 I have a List View which has a strongly typed ViewModel which includes the entity list I am working with together with some other session-type stuff I am carrying aruound. On clicking an item in the list (an Html.ActionLink) to go to the Details view I can easily pass the entity id. But I also want to pass the rest of the ViewModel from the View. I can build the ActionLink with various QueryString parameters and then a custom ModelBinder can pick them up and hydrate the ViewModel object for

ASP.NET MVC Strongly-Type ViewModel - Combine Create/List Views

℡╲_俬逩灬. 提交于 2019-12-21 21:15:31
问题 I am learning ASP.NET MVC and Entity Framework Code First, LINQ by creating a simple Bug/Feature tracking system. I would like to mimic the Twitter interface by having the user submit a form above and having the submitted content appear below. I am not sure how to structure the strongly-typed view and the said model. I would like to merge my Create and Index views into a single view, the problem is the Create takes a single type Entry ( Pylon.Models.Entry ), while the Index takes IEnumerable

ASP.NET MVC Model/ViewModel Validation

这一生的挚爱 提交于 2019-12-21 16:58:47
问题 I have model classes in Linq-to-Sql with partial classes marked with data annotation attributes and a reference to xVal. When I bind a view directly to a model everything works great, both the JS generated by xVal and server side double check. Many of my views don't take input to one specific model, so I am setting up view model classes. Instead of exposing an entire model instance I expose properties into the model that I allow/need to be set by the view. // foo model public class Foo {

MVC pass JSON ViewModel to View

淺唱寂寞╮ 提交于 2019-12-21 14:33:30
问题 I have an MVC application that I'm using various JsonResult endpoints to populate the javascript ViewModel. I have been using several jQuery Ajax requests to populate the model, but I'd like as much of the inital model to be passed to the view on the server. The ViewModel has 3-5 pieces (depending on where the user is in the application): Basic page links, these don't change very often and could be the exact same throughout the entire user's session User notifications. User data. (optional)

Android ViewModel call Activity methods

余生颓废 提交于 2019-12-21 08:06:04
问题 I'm using android AAC library and Android databinding library in my project. I have AuthActivity and AuthViewModel extends android's ViewModel class. In some cases i need to ask for Activity to call some methods for ViewModel. For example when user click on Google Auth or Facebook Auth button, which initialized in Activity class (because to initialize GoogleApiClient i need Activity context which i can not pass to ViewModel, view model can not store Activity fields). All logic with Google Api

Access properties from one view model in another

♀尐吖头ヾ 提交于 2019-12-21 05:51:37
问题 My WPF application follows the MVVM pattern. There are three views: MainWindow LoginView ProjectsView LoginView and ProjectsView are user controls imported by the MainWindow . Both views have their view model assigned. LoginViewModel defines a property ProjectList which is set by calling a webservice. Now LoginViewModel needs access to the ProjectList property and others. I am aware that one solution might be a redesign so that there is only one view and one view model. I would do that as a

Reload RecyclerView after data change with Room, ViewModel and LiveData

非 Y 不嫁゛ 提交于 2019-12-21 05:11:10
问题 I am trying, without success, to solve a problem for days. I would like to update my recyclerView whenever the records of a particular model change in the Database (DB Room). I use ViewModel to handle the model data and the list of records are stored in LiveData. Database @Database(entities = arrayOf(Additive::class), version = ElementDatabase.DB_VERSION, exportSchema = false) abstract class ElementDatabase() : RoomDatabase() { companion object { const val DB_NAME : String = "element_db"

Reload RecyclerView after data change with Room, ViewModel and LiveData

主宰稳场 提交于 2019-12-21 05:11:06
问题 I am trying, without success, to solve a problem for days. I would like to update my recyclerView whenever the records of a particular model change in the Database (DB Room). I use ViewModel to handle the model data and the list of records are stored in LiveData. Database @Database(entities = arrayOf(Additive::class), version = ElementDatabase.DB_VERSION, exportSchema = false) abstract class ElementDatabase() : RoomDatabase() { companion object { const val DB_NAME : String = "element_db"

Accessing BroadCastReceiver in Viewmodel

不打扰是莪最后的温柔 提交于 2019-12-21 04:48:22
问题 I am struggling in choosing the right way to pass data from broadcastReceiver to ViewModel and from there I pass data to my Repository and update LiveData. I use FCM push notifications and have local broadCastReceiver which uses ActivityLifecycle. I found that it is bad practice to access ViewModel from BroadcastReceiver, but not sure why? If I manage lifecycle of broadcastReceiver it should not cause any problems... So what is the best way to pass received data from FCM to my Repository's