public ActionResult Yes(ConfirmationActionViewModel model) { if (!model.HttpPost) { return(Redirect(model.YesUrl)); } ConfirmationData data = ConfirmationService.GetData(model.Id); RouteData route = RoutesHelper.GetRouteDataByUrl("/" + model.YesUrl); //var controllerDescriptor = new ReflectedControllerDescriptor(GetType()); string controllerName = (String)route.Values["controller"]; string actionName = (String)route.Values["action"]; //string values = RouteData.GetRequiredString("id"); //IControllerActivator DefaultControllerFactory d = new DefaultControllerFactory(); IController controller = d.CreateController(HttpContext.Request.RequestContext, controllerName); ControllerDescriptor controllerDescriptor = new ReflectedControllerDescriptor(controller.GetType()); //d.ReleaseController(controller); ActionDescriptor actionDescriptor = controllerDescriptor.FindAction(ControllerContext, actionName); RequestContext requestContext = new RequestContext(new RoutesHelper.RewritedHttpContextBase("/" + model.YesUrl), route); requestContext.HttpContext.Request.Form.Add((NameValueCollection)data.PostData); ControllerContext ctx = new ControllerContext(requestContext, (ControllerBase)controller); IDictionary <string, object> parameters2 = GetParameterValues(ctx, actionDescriptor); IDictionary <string, object> parameters = new Dictionary <string, object>(); ControllerContext.HttpContext.Response.Clear(); NameValueCollection nameValueCollection = data.PostData as NameValueCollection; //nameValueCollection. actionDescriptor.Execute(ControllerContext, (IDictionary <string, object>)data.PostData); //var viewResult = new ViewResult //{ // ViewName = "", // MasterName = "", // ViewData = new ViewDataDictionary(data.PostData), // TempData = null //}; //return viewResult; return(new EmptyResult()); }
/// <summary> /// Creates route and initializes route's fields by default values if possible. /// </summary> /// <returns>Created route.</returns> private Route _CreateRouteWithDefaultValues() { Route route = App.Current.Project.CreateRoute(); // set default driver Collection <ESRI.ArcLogistics.Data.DataObject> usedDrivers = RoutesHelper.CreateUsedDriversCollection(); Collection <Driver> freeDrivers = new Collection <Driver>(); foreach (Driver driver in App.Current.Project.Drivers) { if (!usedDrivers.Contains(driver)) { freeDrivers.Add(driver); } } if (freeDrivers.Count == 1) { route.Driver = freeDrivers[0]; } // set default vehicle Collection <ESRI.ArcLogistics.Data.DataObject> usedVehicles = RoutesHelper.CreateUsedVehiclesCollection(); Collection <Vehicle> freeVehicles = new Collection <Vehicle>(); foreach (Vehicle vehicle in App.Current.Project.Vehicles) { if (!usedVehicles.Contains(vehicle)) { freeVehicles.Add(vehicle); } } if (freeVehicles.Count == 1) { route.Vehicle = freeVehicles[0]; } // set default locations if (App.Current.Project.Locations.Count == 1) { route.StartLocation = App.Current.Project.Locations[0]; route.EndLocation = App.Current.Project.Locations[0]; } // set default color route.Color = RouteColorManager.Instance.NextRouteColor(_routes); return(route); }
public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapMaestroRoute( name: "CustomerDefault", url: "{controller}/{action}/{id}", defaults: new { controller = "Customers", action = "Index", id = UrlParameter.Optional }, namespaces: new[] { "Maestro.Web.Controllers" } ); RoutesHelper.RegisterPublicController("Error"); RoutesHelper.RegisterPublicController("Account"); }
public async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Function, HttpVerbs.Post, Route = PathSegments.Feedback + "/{sessionId:Guid?}")] HttpRequest req, Guid?sessionId, ILogger logger) { try { var requestBody = await new StreamReader(req.Body).ReadToEndAsync(); var model = _modelFactory.Create(requestBody, req.Headers, sessionId); var result = _validator.Validate(model); if (!result.IsValid) { return(ErrorsBuilder.BuildBadArgumentError("Feedback Create Request Data contains invalid/missing arguments", result.Errors)); } var feedbackDto = await _handler.HandleAsync(model); var location = RoutesHelper.BuildFeedbackGetUrl(feedbackDto.Id, req.Host.Value ?? string.Empty, req.IsHttps); return(new CreatedResult(location, feedbackDto)); } catch (SessionNotFoundException snfEx) { return(ErrorsBuilder.BuildNotFoundError(snfEx.Message)); } catch (FeedbackCreateRequestNotAllowedException snfEx) { return(ErrorsBuilder.BuildNotAllowedError(snfEx.Message)); } catch (Exception ex) { //TODO : configure app to log to Azure AppInsights if (ex is AggregateException agx) { logger.WriteAggregateException(agx); } else { logger.WriteException(ex); } return(ErrorsBuilder.BuildInternalServerError()); } }
protected override void _BuildAvailableCollection() { base._BuildAvailableCollection(); Collection <ESRI.ArcLogistics.Data.DataObject> usedItems = new Collection <ESRI.ArcLogistics.Data.DataObject>(); if (ItemType != null && ItemType.Equals(typeof(ArcLogistics.DomainObjects.Vehicle))) { usedItems = RoutesHelper.CreateUsedVehiclesCollection(); } else if (ItemType != null && ItemType.Equals(typeof(ArcLogistics.DomainObjects.Driver))) { usedItems = RoutesHelper.CreateUsedDriversCollection(); } foreach (ESRI.ArcLogistics.Data.DataObject obj in usedItems) { if (obj != SelectedItem) { AvailableCollection.Remove(obj); } } }