Editing a content type from website

Topics: Writing modules
Feb 4, 2015 at 7:05 AM
Edited Feb 4, 2015 at 7:18 AM
I am creating a Content type with a part, some info shown in this content type comes from third party services and the updates need to be posted to third party services. So we cannot use the part in the display method but a viewmodel with all the consolidated info.

The display template is to be used not just to display but to edit the information for this content part. So we are rendering an editor template from the driver display method with a view model. The values get posted to the controller and the model state is updated with updated values from the view. This works fine.

There are two problems as of now:
1) Although the modelstate is updated and we can rebuild the view model from these values, isnt there a direct way to get the viewmodel?
The view model is updated using:
var product = _contentManager.New<ProductPart>("Product");
var editorShape = _orchardServices.ContentManager.UpdateEditor(product, this);

2) If there are any validations on the view model, it works fine. But how to we render the same view that is shown from display method, from controller action with the validation errors from model state.

Has someone faced a similar issue? Thanks for the help.
Any alternate suggestions that will help are welcome.