Skip to main content

Hello All,


I have a query regarding calling of K2 custom code(like trggering K2 process from code, calling smartobject from code) from MVC architecture supports or not?


If yes then please explain with sample.


Please let me know.


Regards,


Sushama

Hi Sushama,


I spoke to one of the K2 consultants about this and he recommended creating the custom code in a repository which is called by your Controller, View and is used to populate your models. I will only discuss the workflow part but SmartObjects are much the same.


Create a WorklistItem model with the properties of a Worklist Item. In your repository use the WorklistItem as a return type for the methods. In the actual method call the K2 API and then set the properties of the WorklistItem model to the returned properties from the API.


Consume this from your Controller and View.


This is very high-level, but I think it will get you started.


Regards,


thanks for your reply..


It will be great if i get more detail level answer.


Hi Sushama,

There is nothing special with regards to K2 and the MVC framework. You will use the K2 API(WorkflowClient/WorkflowManagement ect.) in your Reporsitry to populate the required model objects. When this is done you pass the populated objects to your controller and then from there your View.

For more info how to use the repositry pattern you can visit the site below:
http://www.asp.net/entity-framework/tutorials/implementing-the-repository-and-unit-of-work-patterns-in-an-asp-net-mvc-application

Regards,


Reply