Last active
April 3, 2016 18:07
-
-
Save casper-rasmussen/26b45a7329eef50bf8516fe0baa56e66 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class FormViewModelBuilder : IFormViewModelBuilder | |
{ | |
public FormViewModel Build(XForm form, CultureInfo culture) | |
{ | |
FormViewModel viewModel = new FormViewModel(); | |
viewModel.Form = form; | |
viewModel.Show = form != null; | |
if (form != null) | |
{ | |
RouteValueDictionary values = new RouteValueDictionary(new { controller = "Form", action = "Index", language = culture.Name, area = "MyArea" }); | |
RequestContext context = new RequestContext(new HttpContextWrapper(HttpContext.Current), HttpContext.Current.Request.RequestContext.RouteData); | |
VirtualPathData url = RouteTable.Routes.GetVirtualPathForArea(context, "Default_MyArea", values); | |
//Force our area and culture | |
string actionUrl = url.VirtualPath; | |
actionUrl = UriSupport.AddQueryString(actionUrl, "XFormId", form.Id.ToString()); | |
actionUrl = UriSupport.AddQueryString(actionUrl, "failedAction", "Failed"); | |
actionUrl = UriSupport.AddQueryString(actionUrl, "successAction", "Success"); | |
viewModel.ActionUrl = actionUrl; | |
} | |
return viewModel; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment