viewmodel

Storing Model ID in ASP.NET MVC ViewModel, Security issues

情到浓时终转凉″ 提交于 2019-12-06 01:04:18
In my MVC application I have a page for a user editing their account details such as email address, password etc. In my database a User table holds this data and the primary key is UserId. On the ChangeAccountDetails view I have created I pass a ViewModel with the data the user should be able to modify on their account. I also store the UserId in the ViewModel which is rendered into a hidden field on my actual view. I have a concern that this is not safe for the reason that on POST action to save the changed data, my service layer loads the persisted version of the User account details that

MVC3 passing base class to partial View - submitting form only has parent class values

丶灬走出姿态 提交于 2019-12-06 00:08:28
I have a number of child ViewModel classes which inherit from an base ViewModel class. I pass my child ViewModel into my View, which then passes itself into a partial view. The main view takes the child type, but the partial view takes the Parent type. Everything displays correctly when I manually populate the properties. However, when I Submit the form, my controller action only has properties for the Child class - none of the base class properties are completed? e.g. public abstract class BaseDetails { public string Name { get; set; } public BaseDetails() { } public BaseDetails(string name)

ASP.NET MVC - view model, domain model and data model [closed]

天大地大妈咪最大 提交于 2019-12-05 22:51:25
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . I am using entity framework in my latest ASP.NET MVC 3 project. As it is DB first, the entity framework generates Database models . In

How to observe changes in database in order to update LiveData

一世执手 提交于 2019-12-05 22:36:09
I am migrating an app from a LoaderManager with Callbacks to an implementation using ViewModel and LiveData . I would like to keep using the existing SQLiteDatabase . The main implementation works OK. The Activity instantiates the ViewModel and creates an Observer which updates the View if it observes changes in the MutableLiveData that lives in the ViewModel . The ViewModel gets it data (cursor) from the SQLiteDatabase through a query using a ContentProvider . But I have other activities that can make changes to the database, while MainActivity is stopped but not destroyed. There is also a

knockout “if binding” not working

风格不统一 提交于 2019-12-05 22:30:49
问题 When debugging with Chrome, I can see CoverPrices has 9 elements. The foreach loop actually works well and the table looks correct with the first span being bound to Item1 correctly. However, the if binding does not work and both images are displayed. Yet, all the elements in Item2 have the true value, so only the first image should show up. <!-- ko foreach: CoverPrices --> <tr> <td> <span data-bind="text: Item1"></span> </td> <!-- ko foreach: Item2 --> <td> <img src="~/Images/yes.png" alt=

“group by” proxy model

不打扰是莪最后的温柔 提交于 2019-12-05 22:05:08
I have tree model with theoretically infinite depth and some property "Group". In addition to standard view, I need to show this model (and keep it in sync) in such way that each group becomes a virtual parent for all items with the same property value. What is the best way to achieve this with Qt's model/view architecture? I had solved similar problem not a long time ago via inserting additional virtual "groups" on adding/removing items to/from the model, but this method proved not to be very flexible so I'm looking for better solution. Ideally, I see this implemented via QSortProxyFilter

MVVM- Trigger Storyboard in the View Model in Silverlight

元气小坏坏 提交于 2019-12-05 21:59:24
I have a couple of Storyboards in my view that I would like to trigger from the ViewModel if possible. Is there a simple way or elegant way of doing this. Here is what I am trying to do. Person Clicks on a Button-->RelayCommand (In the ViewModel), the Relay Command should then play the storyboard. Also one more thing, I would like to also trigger the storyboard animation by itself in the ViewModel without any interaction. <i:Interaction.Triggers> <i:EventTrigger EventName="MouseLeftButtonDown"> <cmd:EventToCommand Command="{Binding ButtonPress}" CommandParameterValue="RedButtonLight"> </cmd

Should I implement DTOs in repository pattern with EF?

此生再无相见时 提交于 2019-12-05 20:18:46
问题 In my project I'm using EF Code First approach. I have a repository layer, service layer and presentation layer (ASP.NET MVC). I'm using a dedicated viewmodel for each view. What I'm confused about is that should my services return entities to the controller for mapping them to the viewmodels, or should I implements DTOs and return them from services? So the question is when the flow is like "EF -> Repository -> Service -> UI", what will be the data transformation. "Entity -> DTO -> Viewmodel

ASP.NET MVC - Job of Controllers

大憨熊 提交于 2019-12-05 18:54:25
I think I'm beginning to be confused with the job of a controller in MVC. I have a service that exposes five functions: list packages in queue get package delete package accept package deny package My ASP.NET MVC controller depends on this service, and can generally execute a service call on an Action. I'm happy so far. The second part is then building the ViewModel result. If I do this inside of the controller, the controller now has an exploding dependency list -- each action added increases the dependencies in order to build the view model, and these are all inherited by the controller. I

Can you use nested view models in ASP.net MVC3?

孤街醉人 提交于 2019-12-05 18:21:05
Here is a simplified version of what I am doing. I have created a view model that contains data for a Company. The company has 3 addresses. So trying to be clever I created an AddressViewModel and an _address partial. The problem I have is that while I can pass the AddressViewModel to the partial and it renders the address I now have duplicate id's in the HTML... so there are now three "Line1" input fields on the form which of course don't post back properly. How can I resolve this issue. Is the only way to really flatten the ViewModel and have, MainAddressLine1 MailAddressLine1