private static IHtmlContent GenerateLink <T>(T model, IUrlHelper?url, String action, String iconClass) { TagBuilder link = new TagBuilder("a"); link.Attributes["href"] = url?.Action(action, RouteFor(model)); link.Attributes["title"] = Resource.ForAction(action); link.AddCssClass(iconClass); return(link); }
/// <summary> /// Constructor. /// </summary> public QuestionListItem(Model.Questions.Question question, IEnumerable<string> actions, IUrlHelper urlHelper) { Name = question.Name; ActionLinks = string.Join ( "|", actions.Select ( action => $"<a href=\"{urlHelper.Action(action, new { id = question.Id })}\" target=\"_blank\"></a>" ) ); }
public string Action(UrlActionContext actionContext) { return(_urlHelper.Action(actionContext)); }
public async Task <AccountDto> RegisterAsync(RegisterUserViewModel model, IUrlHelper url) { var profileImage = DefaultPictureNameHelper.GetDefaultPictureName(model.Gender); var newUser = new AppUser { UserName = model.Email, Email = model.Email, FirstName = model.Firstname, LastName = model.LastName, BirthDate = new DateTime(model.Year, model.Day, int.Parse(model.Month)), Gender = model.Gender, RegistrationDate = DateTime.Now, ProfileImage = profileImage, TransactionPercent = 3, ShopsAllowed = 10, UsingTariff = false }; var creationResult = await _userManager.CreateAsync(newUser, model.Password); if (creationResult.Succeeded) { await _userManager.AddToRoleAsync(newUser, DefaultIdentity.RoleUser); var userForLog = await _userManager.FindByEmailAsync(newUser.Email); _logger.LogInformation("UserName: {0} | UserId: {1} | Request: {2} | Message: {3}", userForLog.UserName, userForLog.Id, _httpContextAccessor.HttpContext.Request.GetRawTarget(), "Successfully registered in system."); var code = await _userManager.GenerateEmailConfirmationTokenAsync(newUser); var callbackUrl = url.Action( "ConfirmEmail", "Account", new { userId = newUser.Id, token = code }, protocol: _httpContextAccessor.HttpContext.Request.Scheme); var sendEmailConfirmationResponse = await SendMailAsync(newUser, "Email confirmation", "EmailConfirmationLink", "txt", "Interpolation", "callbackUrl", callbackUrl); if (sendEmailConfirmationResponse) { await _signInManager.SignInAsync(newUser, false); return(new AccountDto { RedirectToAction = RedirectToAction("EmailConfirmation", "UserProfile") }); } await _userManager.DeleteAsync(newUser); return(new AccountDto { ReturnToView = View("SomethingWentWrong", "link sending") }); } _logger.LogWarning("UserName: {0} | UserId: {1} | Request: {2} | Message: {3}", "Null", "Null", _httpContextAccessor.HttpContext.Request.GetRawTarget(), string.Join("", creationResult.Errors.Select(x => "\n" + x.Description))); foreach (var error in creationResult.Errors) { ModelState.AddModelError("", error.Description); } return(new AccountDto { ReturnToView = View(model) }); }
public static string Action(this IUrlHelper urlHelper, Task <IActionResult> taskResult, string protocol = null, string hostName = null, string fragment = null) { return(urlHelper.Action(taskResult.Result, protocol, hostName, fragment)); }
/// <summary> /// finds the first child node whose Url property contains the urlToMatch /// </summary> /// <param name="currentNode"></param> /// <param name="urlToMatch"></param> /// <returns></returns> public static TreeNode <NavigationNode> FindByUrl( this TreeNode <NavigationNode> currentNode, IUrlHelper urlHelper, string urlToMatch, string urlPrefix = "") { Func <TreeNode <NavigationNode>, bool> match = delegate(TreeNode <NavigationNode> n) { if (n == null) { return(false); } if (string.IsNullOrEmpty(urlToMatch)) { return(false); } if (!string.IsNullOrEmpty(n.Value.Url)) { if (n.Value.Url.IndexOf(urlToMatch, StringComparison.OrdinalIgnoreCase) >= 0) { return(true); } } if ((urlToMatch.EndsWith("Index")) && (n.Value.Action == "Index")) { if (!n.Value.Url.EndsWith("/") && (!n.Value.Url.Contains("Index"))) { var u = n.Value.Url + "/Index"; if (u.IndexOf(urlToMatch, StringComparison.OrdinalIgnoreCase) >= 0) { return(true); } } } string targetUrl = string.Empty; if (!string.IsNullOrEmpty(n.Value.NamedRoute)) { targetUrl = urlHelper.RouteUrl(n.Value.NamedRoute); if (targetUrl.IndexOf(urlToMatch, StringComparison.OrdinalIgnoreCase) >= 0) { return(true); } } if ((!string.IsNullOrEmpty(n.Value.Action)) && (!string.IsNullOrEmpty(n.Value.Controller))) { targetUrl = urlHelper.Action(n.Value.Action, n.Value.Controller, new { area = n.Value.Area }); if (targetUrl.IndexOf(urlToMatch, StringComparison.OrdinalIgnoreCase) >= 0) { return(true); } } if ((urlPrefix.Length > 0) && (n.Value.Url.Length > 0)) { targetUrl = n.Value.Url.Replace("~/", "~/" + urlPrefix + "/"); if (targetUrl.IndexOf(urlToMatch, StringComparison.OrdinalIgnoreCase) >= 0) { return(true); } } return(false); }; return(currentNode.Find(match)); }
public static string DisplayMessage(this IUrlHelper url, int topicId, int messageId) => url.Action(nameof(Topics.Display), nameof(Topics), new { id = topicId, page = 1, target = messageId }) + $"#message{messageId}";
public override string GetUrl(IUrlHelper urlHelper, Dictionary <string, object> overriddenRouteValues) => urlHelper.Action(Action, Controller, overriddenRouteValues);
public string Build() { var url = _parameters != null?_urlHelper.Action(_action, _controller, _parameters) : _urlHelper.Action(_action, _controller); return(MakeLink(url)); }
public static string GetLocalUrl(this IUrlHelper urlHelper, string localUrl) { return(!urlHelper.IsLocalUrl(localUrl) ? urlHelper.Action("Index", "Home") : localUrl); }
public override string GetUrl(IUrlHelper urlHelper) => urlHelper.Action(new UrlActionContext() { Action = BreadcrumbManager.Options.DefaultAction, Controller = Controller, Values = RouteValues });
public override string GetUrl(IUrlHelper urlHelper, Dictionary <string, object> overriddenRouteValues) => urlHelper.Action(new UrlActionContext() { Action = BreadcrumbManager.Options.DefaultAction, Controller = Controller, Values = overriddenRouteValues });
public string GetSettingsUrl(IUrlHelper urlHelper) { return(urlHelper.Action(nameof(JiraController.Settings), "Jira")); }
public string GetContentUrl(IUrlHelper urlHelper) { return(urlHelper.Action(nameof(JiraController.Content), "Jira")); }
public virtual Tree <T> Source(string action, string controller) { _sourceUrl = _urlHelper.Action(action, controller); return(this); }
public IEnumerable <DemoTreeNode> ToHierarchicalDataSource(IUrlHelper urlHelper, string currentController, string currentAction) { var nodeStack = new Stack <DemoTreeNode>(); nodeStack.Push(new DemoTreeNode { Items = new List <DemoTreeNode>() }); void OnGroupStart(DemoGroup g) { nodeStack.Push(new DemoTreeNode { Text = g.Name, Items = new List <DemoTreeNode>() }); } void OnGroupEnd() { var current = nodeStack.Pop(); var parent = nodeStack.Peek(); if (current.Items.Count == 1 && nodeStack.Count > 1) { current.Items = null; } if (!String.IsNullOrEmpty(current.Url)) { parent.Items.Add(current); } } void OnDemo(Demo d) { var req = urlHelper.ActionContext.HttpContext.Request; var url = urlHelper.Action(d.Action, d.Controller); var active = Equals(d.Controller, currentController) && Equals(d.Action, currentAction); url = DemoUtils.KeepQueryString(url, req, "theme"); nodeStack.Peek().Items.Add(new DemoTreeNode { Text = d.Title, Url = url, Active = active, }); foreach (var n in nodeStack) { if (active) { n.Active = true; } if (String.IsNullOrEmpty(n.Url)) { n.Url = url; } } } Walk(OnGroupStart, OnGroupEnd, OnDemo); return(nodeStack.Peek().Items); }
private string GetRouteTarget([NotNull] ILinkable link, IUrlHelper urlHelper) { if (link == null) { throw new ArgumentNullException(nameof(link)); } var urlScheme = urlHelper.ActionContext.HttpContext.Request.Scheme ?? "http"; switch (link.LinkType) { case LinkType.ResultUser: return(urlHelper.Action("Details", "User", new { UserId = link.Identification }, urlScheme)); case LinkType.ResultCharacterGroup: return(urlHelper.Action("Details", "GameGroups", new { CharacterGroupId = link.Identification, link.ProjectId }, urlScheme)); case LinkType.ResultCharacter: return(urlHelper.Action("Details", "Character", new { CharacterId = link.Identification, link.ProjectId }, urlScheme)); case LinkType.Claim: return(urlHelper.Action("Edit", "Claim", new { link.ProjectId, ClaimId = link.Identification }, urlScheme)); case LinkType.Plot: return(urlHelper.Action("Edit", "Plot", new { PlotFolderId = link.Identification, link.ProjectId }, urlScheme)); case LinkType.Comment: return(urlHelper.Action("ToComment", "DiscussionRedirect", new { link.ProjectId, CommentId = link.Identification }, urlScheme)); case LinkType.CommentDiscussion: return(urlHelper.Action("ToDiscussion", "DiscussionRedirect", new { link.ProjectId, CommentDiscussionId = link.Identification }, urlScheme)); case LinkType.Project: return(urlHelper.Action("Details", "Game", new { link.ProjectId }, urlScheme)); case LinkType.PaymentSuccess: return(urlHelper.Action( "ClaimPaymentSuccess", "Payments", new { projectId = link.ProjectId, claimId = link.Identification }, urlScheme)); case LinkType.PaymentFail: return(urlHelper.Action( "ClaimPaymentFail", "Payments", new { projectId = link.ProjectId, claimId = link.Identification }, urlScheme)); default: throw new ArgumentOutOfRangeException(); } }
public string AdjustUrl(TreeNode <NavigationNode> node) { string urlToUse = string.Empty; try { if ((node.Value.Action.Length > 0) && (node.Value.Controller.Length > 0)) { if (node.Value.PreservedRouteParameters.Length > 0) { List <string> preservedParams = node.Value.PreservedRouteParameters.SplitOnChar(','); //var queryBuilder = new QueryBuilder(); //var routeParams = new { }; var queryStrings = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase); foreach (string p in preservedParams) { if (context.Request.Query.ContainsKey(p)) { queryStrings.Add(p, context.Request.Query[p]); } } urlToUse = urlHelper.Action(node.Value.Action, node.Value.Controller, new { area = node.Value.Area }); if ((urlToUse != null) && (queryStrings.Count > 0)) { urlToUse = QueryHelpers.AddQueryString(urlToUse, queryStrings); } } else { urlToUse = urlHelper.Action(node.Value.Action, node.Value.Controller, new { area = node.Value.Area }); } } else if (node.Value.NamedRoute.Length > 0) { urlToUse = urlHelper.RouteUrl(node.Value.NamedRoute); } string key = NavigationNodeAdjuster.KeyPrefix + node.Value.Key; if (context.Items[key] != null) { NavigationNodeAdjuster adjuster = (NavigationNodeAdjuster)context.Items[key]; if (adjuster.ViewFilterName == navigationFilterName) { if (adjuster.AdjustedUrl.Length > 0) { return(adjuster.AdjustedUrl); } } } if (string.IsNullOrEmpty(urlToUse)) { return(node.Value.Url); } } catch (ArgumentOutOfRangeException ex) { log.LogError("error handled for " + node.Value.Key, ex); } //if(urlToUse.Length > 0) { return urlToUse; } return(urlToUse); }
public static string Url <T>(this IUrlHelper urlHelper, Func <T, string> action, object values = null) where T : Controller { return(urlHelper.Action(action(null), NameOf <T> .Controller, values)); }
/// <summary> /// Returns a serializable array for the given series. /// </summary> public object GetDataSeriesArray(IUrlHelper urlHelper, bool passed) { var dayBoundaries = GetDayBoundaries(); var lastBuild = AllBuildTestCounts.Last(); var totalTests = lastBuild.PassedCount + lastBuild.FailedCount; return AllBuildTestCounts.Select ( (value, index) => new { Index = index, TestCount = passed ? value.PassedCount : totalTests - value.PassedCount, ShortCommitDate = dayBoundaries[index] ? value.PushDate.ToLocalTime().ToString("MM/dd") : "--", LongCommitDate = value.PushDate.ToLocalTime().ToString("MM/dd/yyyy h:mm tt"), BuildUrl = urlHelper.Action ( "BuildResult", "Build", new { buildId = value.BuildId } ) } ); }
public override void Process(TagHelperContext context, TagHelperOutput output) { if (Model == null) { return; } if (Model.PageCount == 0) { return; } var PAGES_TO_SHOW = 5; var action = ViewContext.RouteData.Values["action"].ToString(); var urlTemplate = WebUtility.UrlDecode(_urlHelper.Action(action, new { page = "{0}" })); var request = _httpContext.Request; foreach (var key in request.Query.Keys) { if (key == "page") { continue; } urlTemplate += "&" + key + "=" + request.Query[key]; } var startIndex = Math.Max((Model.CurrentPage - PAGES_TO_SHOW) - Math.Max(PAGES_TO_SHOW - (Model.PageCount - Model.CurrentPage), 0), 1); var finishIndex = Math.Min(Model.CurrentPage + PAGES_TO_SHOW + Math.Max(PAGES_TO_SHOW - Model.CurrentPage + 1, 0), Model.PageCount); output.TagName = ""; output.Content.AppendHtml("<div class=\"sfpagination Mt-2x float-right\">"); output.Content.AppendHtml("<ul class=\"pagination\">"); output.Content.AppendHtml("<li class=\"item\" ><a href=\""); output.Content.AppendHtml(string.Format(urlTemplate, 1)); if (Model.CurrentPage == startIndex) { output.Content.AppendHtml("\" class=\"item-link disabled\">"); } else { output.Content.AppendHtml("\" class=\"item-link primary-link\">"); } output.Content.AppendHtml("<i class=\"fa fa-angle-double-left\"></i>"); output.Content.AppendHtml("</a>"); output.Content.AppendHtml("</li>"); output.Content.AppendHtml("<li class=\"item\" ><a href=\""); output.Content.AppendHtml(string.Format(urlTemplate, Model.CurrentPage - 1)); if (Model.CurrentPage == startIndex) { output.Content.AppendHtml("\" class=\"item-link primary disabled\">"); } else { output.Content.AppendHtml("\" class=\"item-link primary-link\">"); } output.Content.AppendHtml("<i class=\"fa fa-chevron-left\"></i>"); output.Content.AppendHtml("</a>"); output.Content.AppendHtml("</li>"); for (var i = startIndex; i <= finishIndex; i++) { if (i == Model.CurrentPage) { output.Content.AppendHtml("<li class=\"item\"><a class=\"item-link primary active\">"); output.Content.AppendHtml(i.ToString()); output.Content.AppendHtml("</li>"); } else { output.Content.AppendHtml("<li class=\"item\" ><a href=\""); output.Content.AppendHtml(string.Format(urlTemplate, i)); output.Content.AppendHtml("\" class=\"item-link primary-link\">"); output.Content.AppendHtml(i.ToString()); output.Content.AppendHtml("</a>"); output.Content.AppendHtml("</li>"); } } output.Content.AppendHtml("<li class=\"item\" ><a href=\""); output.Content.AppendHtml(string.Format(urlTemplate, Model.CurrentPage + 1)); if (Model.CurrentPage == finishIndex) { output.Content.AppendHtml("\" class=\"item-link primary disabled\">"); } else { output.Content.AppendHtml("\" class=\"item-link primary-link\">"); } output.Content.AppendHtml("<i class=\"fa fa-chevron-right\"></i>"); output.Content.AppendHtml("</a>"); output.Content.AppendHtml("</li>"); output.Content.AppendHtml("<li class=\"item\" ><a href=\""); output.Content.AppendHtml(string.Format(urlTemplate, Model.PageCount)); if (Model.CurrentPage == finishIndex) { output.Content.AppendHtml("\" class=\"item-link primary disabled\">"); } else { output.Content.AppendHtml("\" class=\"item-link primary-link\">"); } output.Content.AppendHtml("<i class=\"fa fa-angle-double-right\"></i>"); output.Content.AppendHtml("</a>"); output.Content.AppendHtml("</li>"); output.Content.AppendHtml("</ul>"); output.Content.AppendHtml("</div>"); }
public override string GetUrl(IUrlHelper urlHelper) => urlHelper.Action(Action, Controller, RouteValues);
/// <summary> /// Извличане на данни за местоположение за начален екран /// </summary> /// <returns></returns> public IEnumerable <CaseMovementVM> Select_ToDo() { var courtLawUnit = repo.AllReadonly <CourtLawUnit>() .Where(x => x.CourtId == userContext.CourtId && x.LawUnitId == userContext.LawUnitId && (x.DateFrom <= DateTime.Now && (x.DateTo ?? DateTime.Now.AddDays(1)) >= DateTime.Now)) .FirstOrDefault(); var courtOrganizationId = (courtLawUnit != null) ? (courtLawUnit.CourtOrganizationId ?? 0) : 0; var caseMovementVMs = repo.AllReadonly <CaseMovement>() .Include(x => x.Case) .Include(x => x.MovementType) .Include(x => x.ToUser) .ThenInclude(x => x.LawUnit) .Include(x => x.CourtOrganization) .Include(x => x.AcceptUser) .ThenInclude(x => x.LawUnit) .Include(x => x.User) .ThenInclude(x => x.LawUnit) .Where(x => ((courtOrganizationId > 0) ? ((x.ToUserId == userContext.UserId) || (x.CourtOrganizationId == courtOrganizationId)) : (x.ToUserId == userContext.UserId)) && (x.Case.CourtId == userContext.CourtId) && (x.DateAccept == null)) .Select(x => new CaseMovementVM() { Id = x.Id, CaseId = x.CaseId, CourtId = x.CourtId, CaseName = x.Case.RegNumber + "/" + x.Case.RegDate.ToString("dd.MM.yyyy"), MovementTypeId = x.MovementTypeId, MovementTypeLabel = (x.MovementType != null) ? x.MovementType.Label : string.Empty, NameFor = ((x.MovementTypeId == NomenclatureConstants.CaseMovementType.ToPerson) ? ((x.ToUser.LawUnit != null) ? x.ToUser.LawUnit.FullName : string.Empty) : ((x.MovementTypeId == NomenclatureConstants.CaseMovementType.ToOtdel) ? ((x.CourtOrganization != null) ? x.CourtOrganization.Label : string.Empty) : x.OtherInstitution)), ToUserId = x.ToUserId, CourtOrganizationId = x.CourtOrganizationId, OtherInstitution = x.OtherInstitution, DateSend = x.DateSend, DateAccept = x.DateAccept, Description = x.Description, DisableDescription = x.DisableDescription, AcceptDescription = x.AcceptDescription, IsActive = x.IsActive, IsActiveText = ((x.IsActive) ? "Активен" : "Неактивен"), IsEdit = false, IsAccept = false, AcceptUserId = x.AcceptUserId, AcceptLawUnitName = (x.AcceptUser != null) ? x.AcceptUser.LawUnit.FullName : string.Empty, UserId = x.UserId, UserLawUnitId = x.User.LawUnitId, UserLawUnitName = x.User.LawUnit.FullName }).ToList(); List <CaseMovementVM> _result = new List <CaseMovementVM>(); foreach (var movementVM in caseMovementVMs) { var movementVMs = Select(movementVM.CaseId); var maxIdElement = movementVMs.Where(x => x.IsActive).OrderByDescending(x => x.Id).FirstOrDefault(); if (movementVM.Id == maxIdElement?.Id) { movementVM.ViewUrl = urlHelper.Action("Index", "CaseMovement", new { CaseId = movementVM.CaseId }); _result.Add(movementVM); } } return(_result); }
public AircraftMainMenu(IUrlHelper url, int aircraftId) { Items.AddRange(new[] { new AircraftMainMenu(1, "General Information", "#!", "feather icon-clipboard", subMenu: new List <AircraftMainMenu>() { new AircraftMainMenu(1, "Aircraft Summary", "#!"), new AircraftMainMenu(2, "Documents", "#!") }), new AircraftMainMenu(2, "Components", "#!", "feather icon-clipboard", subMenu: new List <AircraftMainMenu>() { new AircraftMainMenu(1, "Avionics Inventory", "#!"), new AircraftMainMenu(2, "Component Status All", url.Action("Index", "Component", new { aircraftId })), new AircraftMainMenu(3, "Component Tracking", "#!"), new AircraftMainMenu(4, "Component Change Status", "#!"), new AircraftMainMenu(5, "Landing Gear Status", "#!") }), new AircraftMainMenu(3, "Directives", "#!", "feather icon-clipboard", subMenu: new List <AircraftMainMenu>() { new AircraftMainMenu(1, "AD Status All", url.Action("All", "Directive", new { aircraftId, directiveType = DirectiveType.AirworthenessDirectives.ItemId })), new AircraftMainMenu(2, "AD Status AF", url.Action("All", "Directive", new { aircraftId, directiveType = DirectiveType.AirworthenessDirectives.ItemId, adType = ADType.Airframe })), new AircraftMainMenu(3, "AD Status AP", url.Action("All", "Directive", new { aircraftId, directiveType = DirectiveType.AirworthenessDirectives.ItemId, adType = ADType.Apliance })), new AircraftMainMenu(5, "EO Status", url.Action("Eo", "Directive", new { aircraftId, directiveType = DirectiveType.EngineeringOrders.ItemId })), new AircraftMainMenu(6, "SB Status", url.Action("Sb", "Directive", new { aircraftId, directiveType = DirectiveType.SB.ItemId })) }), new AircraftMainMenu(4, "Discrepancies", "#!", "feather icon-clipboard", subMenu: new List <AircraftMainMenu>() { new AircraftMainMenu(1, "Discrepancies Status", "#!"), new AircraftMainMenu(2, "Damages", "#!"), new AircraftMainMenu(2, "Deferred Items", "#!") }), new AircraftMainMenu(5, "Maintenance Program", "#!", "feather icon-clipboard", subMenu: new List <AircraftMainMenu>() { new AircraftMainMenu(1, "MTOP", "#!"), new AircraftMainMenu(2, "Routine Tasks", url.Action("Index", "MaintenanceDirective", new { aircraftId })), new AircraftMainMenu(3, "Non-Routine Tasks", "#!"), new AircraftMainMenu(4, "Non-Routine Status", "#!") }), new AircraftMainMenu(6, "Planning", "#!", "feather icon-clipboard", subMenu: new List <AircraftMainMenu>() { new AircraftMainMenu(1, "ATLB Event", url.Action("AtlbEvent", "ATLB", new { aircraftId })), new AircraftMainMenu(1, "ATLBs", url.Action("Index", "ATLB", new { aircraftId })), new AircraftMainMenu(2, "Forecast MTOP Report", "#!"), new AircraftMainMenu(3, "Forecast Report Kits", "#!"), new AircraftMainMenu(4, "Monthly Utilization", "#!"), new AircraftMainMenu(5, "Work Packages", url.Action("Index", "WorkPackage", new { aircraftId })) }), new AircraftMainMenu(7, "Purchase", "#!", "feather icon-clipboard", subMenu: new List <AircraftMainMenu>() { new AircraftMainMenu(1, "Equipment and Materials", "#!"), new AircraftMainMenu(2, "Initial Orders", "#!"), new AircraftMainMenu(3, "Purchase Orders", "#!"), new AircraftMainMenu(4, "Quotation Orders", "#!") }), new AircraftMainMenu(7, "SMS", "#!", "feather icon-clipboard", subMenu: new List <AircraftMainMenu>() { new AircraftMainMenu(1, "Events", "#!") }) }); }
public override SitemapIndexNode CreateSitemapIndexNode(int currentPage) { return(new SitemapIndexNode(urlHelper.Action("Index", "Product", new { id = currentPage }))); }
public string Action(UrlActionContext urlActionContext) { return(_originalUrlHelper.Action(urlActionContext)); }
private string ResolveUrl(NavigationNode node, IUrlHelper urlHelper) { if (node.HideFromAnonymous) return string.Empty; // if url is already fully resolved just return it if (node.Url.StartsWith("http")) return node.Url; string urlToUse = string.Empty; if ((node.Action.Length > 0) && (node.Controller.Length > 0)) { urlToUse = urlHelper.Action(node.Action, node.Controller); } else if (node.NamedRoute.Length > 0) { urlToUse = urlHelper.RouteUrl(node.NamedRoute); } if (string.IsNullOrEmpty(urlToUse)) urlToUse = node.Url; if (urlToUse.StartsWith("http")) return urlToUse; return BaseUrl + urlToUse; }
public static string AbsoluteAction(this IUrlHelper url, string actionName, string controllerName, object routeValues = null) { string scheme = url.ActionContext.HttpContext.Request.Scheme; return(url.Action(actionName, controllerName, routeValues, scheme)); }
public static string GetAbsoluteAction(IUrlHelper url, string controller, string action, object param) { return(url.Action(action, controller, param, url.ActionContext.HttpContext.Request.Scheme)); }
/// <summary> /// Generates a fully qualified or absolute URL for an action method by /// using <see cref="Expression{TDelegate}"/> for an action method, /// from which action name, controller name and route values are resolved , /// and the specified additional route values. /// </summary> /// <typeparam name="TController">Controller, from which the action is specified.</typeparam> /// <param name="action"> /// The <see cref="Expression{TDelegate}"/>, from which action name, /// controller name and route values are resolved. /// </param> /// <param name="values">An object that contains additional route values.</param> /// <returns>The fully qualified or absolute URL to an action method.</returns> public static string Action <TController>(this IUrlHelper helper, Expression <Action <TController> > action, object values) { return(helper.Action(action, values, protocol: null, host: null, fragment: null)); }
public override void Process(TagHelperContext context, TagHelperOutput output) { _urlHelper = _urlHelperFactory.GetUrlHelper(ViewContext); var isRaised = output.Attributes.SingleOrDefault(a => a.Name == "raised") != null; var isFlat = output.Attributes.SingleOrDefault(a => a.Name == "flat") != null; var isOutline = output.Attributes.SingleOrDefault(a => a.Name == "outline") != null; var isFloating = output.Attributes.SingleOrDefault(a => a.Name == "floating") != null; var isLg = output.Attributes.SingleOrDefault(a => a.Name == "lg") != null; var isSm = output.Attributes.SingleOrDefault(a => a.Name == "sm") != null; var isBlock = output.Attributes.SingleOrDefault(a => a.Name == "block") != null; // Colors var isDefault = output.Attributes.SingleOrDefault(a => a.Name == "default") != null; var isPrimary = output.Attributes.SingleOrDefault(a => a.Name == "primary") != null; var isSuccess = output.Attributes.SingleOrDefault(a => a.Name == "success") != null; var isInfo = output.Attributes.SingleOrDefault(a => a.Name == "info") != null; var isWarning = output.Attributes.SingleOrDefault(a => a.Name == "warning") != null; var isDanger = output.Attributes.SingleOrDefault(a => a.Name == "danger") != null; var isLink = output.Attributes.SingleOrDefault(a => a.Name == "link") != null; var icon = output.Attributes.SingleOrDefault(a => a.Name == "icon"); var text = output.Attributes.SingleOrDefault(a => a.Name == "text"); var action = output.Attributes.SingleOrDefault(a => a.Name == "asp-action"); var controller = output.Attributes.SingleOrDefault(a => a.Name == "asp-controller"); var buttonClassAttr = output.Attributes.SingleOrDefault(a => a.Name == "class"); output.Attributes.RemoveAll("raised"); output.Attributes.RemoveAll("flat"); output.Attributes.RemoveAll("outline"); output.Attributes.RemoveAll("floating"); output.Attributes.RemoveAll("lg"); output.Attributes.RemoveAll("sm"); output.Attributes.RemoveAll("block"); output.Attributes.RemoveAll("default"); output.Attributes.RemoveAll("primary"); output.Attributes.RemoveAll("success"); output.Attributes.RemoveAll("info"); output.Attributes.RemoveAll("warning"); output.Attributes.RemoveAll("danger"); output.Attributes.RemoveAll("link"); output.Attributes.RemoveAll("icon"); output.Attributes.RemoveAll("text"); var buttonClass = "btn"; if (buttonClassAttr != null) { buttonClass += " " + buttonClassAttr.Value; } var labelAttributes = new Dictionary <string, object>(); if (isRaised) { buttonClass = $"{buttonClass} pmd-btn-raised"; } if (isFlat) { buttonClass = $"{buttonClass} pmd-btn-flat"; } if (isOutline) { buttonClass = $"{buttonClass} pmd-btn-outline"; } if (isFloating) { buttonClass = $"{buttonClass} pmd-btn-fab"; } if (isLg) { buttonClass = $"{buttonClass} btn-lg"; } if (isSm) { buttonClass = $"{buttonClass} btn-sm"; } if (isBlock) { buttonClass = $"{buttonClass} btn-block"; } if (isDefault) { buttonClass = $"{buttonClass} btn-default"; } if (isPrimary) { buttonClass = $"{buttonClass} btn-primary"; } if (isSuccess) { buttonClass = $"{buttonClass} btn-success"; } if (isInfo) { buttonClass = $"{buttonClass} btn-info"; } if (isWarning) { buttonClass = $"{buttonClass} btn-warning"; } if (isDanger) { buttonClass = $"{buttonClass} btn-danger"; } if (isLink) { buttonClass = $"{buttonClass} btn-link"; } if (!isDefault && !isPrimary && !isSuccess && !isInfo && !isWarning && !isDanger && !isLink) { buttonClass = $"{buttonClass} btn-primary"; } var inputPre = ""; var inputPost = ""; var labelClass = "control-label"; if (icon != null) { inputPre = $"{inputPre}<div class=\"input-group\"><div class=\"input-group-addon\"><i class=\"material-icons md-dark pmd-sm\">{icon.Value}</i></div>"; inputPost = $"{inputPost}</div>"; labelClass = $"{labelClass} pmd-input-group-label"; } labelAttributes.Add("class", labelClass); string buttonOutput = ""; if (Action != null || Controller != null) { var url = _urlHelper.Action(Action, Controller, _routeValues); output.Attributes.SetAttribute("href", url); output.TagName = "a"; } else { output.Attributes.SetAttribute("type", "submit"); output.TagName = "button"; } buttonOutput = text.Value.ToString(); output.TagMode = TagMode.StartTagAndEndTag; output.Attributes.SetAttribute("class", buttonClass); output.Content.SetHtmlContent(buttonOutput); }
private string GetStepUrl(string actionName, string returnUrl) { return(_urlHelper.Action(actionName, new { returnUrl })); }
/// <summary> /// Generates a fully qualified URL to an action method by using the specified action name, controller name and /// route values. /// </summary> /// <param name="url">The URL helper.</param> /// <param name="actionName">The name of the action method.</param> /// <param name="controllerName">The name of the controller.</param> /// <param name="routeValues">The route values.</param> /// <returns>The absolute URL.</returns> public static string GenerateActionUrl( this IUrlHelper url, string actionName, string controllerName, object routeValues = null) => url.Action(actionName, controllerName, routeValues, url.ActionContext.HttpContext.Request.Scheme);