Created
May 30, 2012 13:52
-
-
Save Fodsuk/2836457 to your computer and use it in GitHub Desktop.
Application workflow controller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ApplicationController : WorkflowController | |
{ | |
public ApplicationController(IWorkflowKeyStore workflowKeyStore, IWorkflowInvokerFactory workflowInvokerFactory) | |
: base("face2face", "Vanquis.NewBusiness.PL.Models", "Vanquis.NewBusiness.PL.Models", workflowKeyStore, workflowInvokerFactory) { } | |
[NoCache] | |
[Authorize] | |
public ActionResult Index() | |
{ | |
LogSystem.log.Debug("ApplicationController/Index"); | |
if (CurrentWorkflowKey.HasValue == false) | |
{ | |
var initialApplicationData = ApplicationData.Create(WebConfigurationManager.AppSettings["Marketingcode"], | |
WebConfigurationManager.AppSettings["Channel"], | |
WebConfigurationManager.AppSettings["Nationality"], | |
WebConfigurationManager.AppSettings["Country"]); | |
var userId = (Guid)Membership.GetUser().ProviderUserKey; | |
var workflowKey = Invoker.StartWorkflow(WorkflowReference, new Dictionary<string, object> { | |
{ "InitialApplicationData", initialApplicationData }, | |
{"UID",userId } | |
}); | |
SetWorkflowKey(workflowKey); | |
} | |
string step = Invoker.GetCurrentBookmark(CurrentWorkflowKey.Value, WorkflowReference); | |
var applicationData = Invoker.GetApplicationData<ApplicationData>(CurrentWorkflowKey.Value); | |
return RedirectToStep(step, applicationData); | |
} | |
[NoCache] | |
[Authorize] | |
public ActionResult Next(string modelName, string viewName) | |
{ | |
var applicationData = Invoker.GetApplicationData<ApplicationData>(CurrentWorkflowKey.Value); | |
string step = Invoker.GetCurrentBookmark(CurrentWorkflowKey.Value, WorkflowReference); | |
return RedirectToStep(step, applicationData); | |
} | |
[NoCache] | |
[HttpPost] | |
[Authorize] | |
public ActionResult Next(string modelName, string viewName, FormCollection formCollection) | |
{ | |
LogSystem.log.Debug(String.Format("{0} button: {1}, {2}, {3}", "ApplicationController/Next", "Next", modelName, viewName)); | |
ApplicationData applicationData = Invoker.GetApplicationData<ApplicationData>(CurrentWorkflowKey.Value); | |
FormCollectionBinder.ConvertValues(applicationData, formCollection); | |
if (!ValidateModel(modelName, formCollection)) | |
return RedirectToStep(viewName, applicationData); | |
string step = Invoker.Next(CurrentWorkflowKey.Value, WorkflowReference, new Dictionary<string, object>() { { "ApplicationData", applicationData } }); | |
if (Invoker.IsFinalStep(step)) | |
WorkflowKeyStore.ClearWorkflowKey(WorkflowReference); | |
return RedirectToStep(step, applicationData); | |
} | |
[NoCache] | |
[Authorize] | |
public ActionResult Back(string modelName, string viewName) | |
{ | |
LogSystem.log.Debug(String.Format("{0} button: {1}, {2}, {3}", "ApplicationController/Back", "Back", modelName, viewName)); | |
var applicationData = Invoker.GetApplicationData<ApplicationData>(CurrentWorkflowKey.Value); | |
string step = Invoker.Back(CurrentWorkflowKey.Value, WorkflowReference, new Dictionary<string, object>() { { "ApplicationData", applicationData } }); | |
return RedirectToStep(step, applicationData); | |
} | |
[NoCache] | |
[Authorize] | |
public ActionResult Cancel(string modelName, string viewName) | |
{ | |
LogSystem.log.Debug(String.Format("{0} button: {1}, {2}, {3}", "ApplicationController/Cancel", "Cancel", modelName, viewName)); | |
var applicationData = Invoker.GetApplicationData<ApplicationData>(CurrentWorkflowKey.Value); | |
Invoker.Cancel(CurrentWorkflowKey.Value, WorkflowReference, new Dictionary<string, object>() { { "ApplicationData", applicationData } }); | |
WorkflowKeyStore.ClearWorkflowKey(WorkflowReference); | |
return RedirectToAction("index", "home"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment