Reputation: 631
I've written a little MVC3 site that let's certain users review Active Directory Accounts. For audits we are required to keep track off our 'user reviews'. So, once a month I put everything in an SQL database. With the state 'to be checked'.
This looks like this:
I'd like to have a way that people can quickly approve them by just checking a textbox and saving it.
How would I go about this?
The 'ReviewState' is a separate object (StateID, StateText, Description, Active). Possibilities are: Unchecked, Approved, Denied, Silently Approved, ...
Upvotes: 1
Views: 79
Reputation: 3883
Create a ViewModel to be used in your view:
public class AccountViewModel
{
public AccountInfo Account { get; set; }
public ReviewState Review { get; set; }
}
This way you can add a checkbox for Approve
like this:
@Html.CheckboxFor(x => x.Active);
You will get this model back to your post action. The only thing left is extract data and update database.
I might not be accurate with property names here and code is written from my head but I think you get the point
Upvotes: 0
Reputation: 2932
Create a ReviewState model and a strongly typed partial view for it containing StateId, StateText, Description etc).
Your parent model should contain a list of ReviewStateModel's. In the main view, loop through that and render a partial for each model in the list.
You may need to add an Id so that you can identify each review model on the server side.
Upvotes: 1