I have the following controller action:
public ActionResult SaveEdits(MagHeader viewModel) {
AppRepository.SaveData(viewModel);
return PartialView("DisplayForModel", viewModel);
}
The ViewModel is very simple and just holds a few properties.
public class MagHeader {
public string MagDate { get; set; }
public string MagTitle { get; set; }
}
This all works just fine. However, the issue is that I have about 40 of these different viewmodels and a controller action for each. All it's doing is saving the data properties of each which I can do through reflection.
Is there a way to have one controller handle all of them? They are all string properties so really they are just key/value pairs. Is there some way to make the controller action generic?