public void AddLinkLeilaoId()
 {
     Links.Add(new LinkResponse(
                   href: _urlHelper.ActionLink("GetId", "Leilao", new { leilaoId = _leilao.Id }),
                   rel: "self",
                   metodo: "GET"));
 }
Esempio n. 2
0
 public JobResult(Job job, IUrlHelper urlHelper)
 {
     Id            = job.Id;
     RunId         = job.RunId;
     State         = job.State.ToString();
     DetailsUrl    = urlHelper.ActionLink("GetById", "Jobs", new { Id });
     BuildLogsUrl  = urlHelper.ActionLink("BuildLog", "Jobs", new { Id });
     OutputLogsUrl = urlHelper.ActionLink("Output", "Jobs", new { Id });
 }
Esempio n. 3
0
 public void AddLinkTodosLeiloes()
 {
     if (_usuarioAutenticado.IsAuthenticated)
     {
         Links.Add(new LinkResponse(
                       href: _urlHelper.ActionLink("GetPaginacao", "Leilao"),
                       rel: "meus_leiloes",
                       metodo: "GET"));
     }
 }
Esempio n. 4
0
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            IUrlHelper urlHelper = urlHelperFactory.GetUrlHelper(Context);

            output.TagName = "a";
            //output.Attributes.Add("class", "btn btn-primary");
            output.AddClass("btn", HtmlEncoder.Default);
            output.AddClass("btn-primary", HtmlEncoder.Default);
            output.Attributes.Add("title", MovieModel.Title);

            string url = "";

            if (MovieType == MovieDetailsType.Full)
            {
                url = urlHelper.ActionLink("Movie", "Home", new { id = MovieModel.imdbID });

                var icon = new TagBuilder("i");

                if (MovieModel.Type == "game")
                {
                    icon.AddCssClass("fas fa-gamepad");
                }
                else if (MovieModel.Type == "series")
                {
                    icon.AddCssClass("fas fa-tv");
                }
                else
                {
                    icon.AddCssClass("fas fa-film");
                }

                output.Content.AppendHtml(icon);

                output.Content.Append(" Details");
            }
            else
            {
                url = urlHelper.ActionLink("MovieModal", "Home", new { id = MovieModel.imdbID });

                var icon = new TagBuilder("i");
                icon.AddCssClass("fas fa-eye");
                output.Content.AppendHtml(icon);

                output.Attributes.Add("data-open-modal", true);
            }

            output.Attributes.Add("href", url);
        }
 public void AddLinkDelete()
 {
     Links.Add(new LinkResponse(
                   href: _urlHelper.ActionLink("Delete", "LeilaoImagem", new { leilaoId = this.LeilaoId, leilaoImagemId = this.Id }),
                   rel: "delete",
                   metodo: "DELETE"));
 }
Esempio n. 6
0
 /// <summary>Convert data url to true url with post id.</summary>
 public string Process(string text, IUrlHelper url, string timeline, long post)
 {
     return(Process(
                text,
                dataIndex => url.ActionLink(
                    nameof(TimelinePostController.DataGet),
                    nameof(TimelinePostController)[0..^ nameof(Controller).Length],
        public static string CacheUiActionLink(this IUrlHelper helper, string action = null, Type controller = null, string fragment = null)
        {
            var    values         = new { cacheToken = CacheToken };
            string controllerName = GetControllerName(controller);

            return(helper.ActionLink(action, controllerName, values, "https", helper.ActionContext.HttpContext.Request.Host.Value, fragment));
        }
Esempio n. 8
0
        public PaginatedLinkBuilder(IUrlHelper urlHelper, string actionName, object routeValues, long pageNo, long pageSize, long recordCount)
        {
            if (urlHelper is null)
            {
                throw new ArgumentNullException(nameof(urlHelper));
            }

            if (string.IsNullOrWhiteSpace(actionName))
            {
                throw new ArgumentNullException(nameof(actionName));
            }

            if (pageNo <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(pageNo));
            }

            if (pageSize <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(pageSize));
            }

            if (recordCount < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(recordCount));
            }

            const string keyPageNumber = "pageNumber";
            const string keyPageSize   = "pageSize";

            var pageCount = recordCount == 0 ? 1 : (long)Math.Ceiling(recordCount / (double)pageSize);

            var dict = new RouteValueDictionary(routeValues)
            {
                [keyPageSize] = pageSize
            };

            Uri Create(long thisPage)
            {
                dict[keyPageNumber] = thisPage;
                var link = urlHelper.ActionLink(actionName, values: dict);

                return(new Uri(link));
            }

            FirstPage = Create(1);
            LastPage  = Create(pageCount);

            if (pageNo > 1)
            {
                PreviousPage = Create(pageNo - 1);
            }

            if (pageNo < pageCount)
            {
                NextPage = Create(pageNo + 1);
            }
        }
Esempio n. 9
0
        public static string ActionLink(this IUrlHelper helper, ReferenceValues referenceValues)
        {
            if (referenceValues.OrderId != null)
            {
                return(helper.ActionLink("Index", "Order", new { id = referenceValues.OrderId.Value }));
            }

            return(null);
        }
Esempio n. 10
0
 public async Task <HttpUser> MapAsync(UserEntity entity, IUrlHelper urlHelper, ClaimsPrincipal?user)
 {
     return(new HttpUser(
                uniqueId: entity.UniqueId,
                username: entity.Username,
                nickname: string.IsNullOrEmpty(entity.Nickname) ? entity.Username : entity.Nickname,
                permissions: (await _userPermissionService.GetPermissionsOfUserAsync(entity.Id, false)).ToStringList(),
                links: new HttpUserLinks(
                    self: urlHelper.ActionLink(nameof(UserController.Get), nameof(UserController)[0..^ nameof(Controller).Length], new { entity.Username }),
Esempio n. 11
0
        internal static LegalCaseDTO MapToDTO(this LegalCase legalCase, IUrlHelper helper)
        {
            var dto = new LegalCaseDTO {
                CaseId  = legalCase.CaseId.ToString(),
                CaseUrl = helper.ActionLink("DeleteLegalCase", "Cases", new { folderId = legalCase.FolderId, caseId = legalCase.CaseId })
            };

            return(dto);
        }
Esempio n. 12
0
        public virtual string BuildUrl(IUrlHelper urlHelper = null)
        {
            if (urlHelper == null || Controller == null)
            {
                return(Url);
            }

            return(urlHelper.ActionLink(ActionName, ControllerName));
        }
Esempio n. 13
0
        internal static FolderDTO MapToDTO(this Folder folder, IUrlHelper helper)
        {
            var dto = new FolderDTO {
                FolderId     = folder.Id,
                FolderUrl    = helper.ActionLink("GetFolder", "Folders", new { folderId = folder.Id }),
                FolderName   = folder.FolderName,
                FolderStatus = folder.FolderStatus,
                OwnerId      = folder.OwnerId,
                Cases        = folder.Cases.Select(c => c.MapToDTO(helper)).ToList()
            };

            return(dto);
        }
Esempio n. 14
0
        public async Task <string> LoginLink(User user, string returnUrl)
        {
            var token = await _userManager.GenerateUserTokenAsync(user, "LongToken", "passwordless-auth");

            return(_urlHelper.ActionLink(
                       "Index",
                       "LoginCallback",
                       new
            {
                userId = user.Id,
                token,
                returnUrl
            }));
        }
Esempio n. 15
0
        /// <summary>
        /// Send confirm new device mail
        /// </summary>
        /// <param name="user"></param>
        /// <param name="userDevice"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public virtual async Task <ResultModel> SendConfirmNewDeviceMailAsync(GearUser user, UserDevice userDevice, HttpContext context = null)
        {
            var result = new ResultModel();

            if (userDevice.IsConfirmed)
            {
                result.AddError("The device has already been confirmed");
                return(result);
            }

            const string subject     = "Confirm new device";
            var          templateReq = TemplateManager.GetTemplateBody("confirm_new_device");

            if (!templateReq.IsSuccess)
            {
                return(result);
            }

            var code = await _userManager.UserManager.GenerateUserTokenAsync(user, AccountActivityResources.TrackActivityTokenProvider, AccountActivityResources.ConfirmDevicePurpose);

            var url = _urlHelper.ActionLink("ConfirmDevice", "AccountActivity",
                                            new
            {
                deviceId = userDevice.Id,
                code
            }, context);

            var location = $"({userDevice.IpAddress}) {userDevice.Location}";
            var body     = templateReq.Result.Inject(new Dictionary <string, string>
            {
                { "Link", url },
                { "Location", location },
                { "Device", userDevice.Platform }
            });

            GearApplication.BackgroundTaskQueue.PushBackgroundWorkItemInQueue(async x =>
            {
                var emailSender = x.InjectService <IEmailSender>();
                await emailSender.SendEmailAsync(user.Email, subject, body);
            });

            result.IsSuccess = true;
            return(result);
        }
        private TagBuilder GetInputTag()
        {
            var input1 = new TagBuilder("input")
            {
                TagRenderMode = TagRenderMode.SelfClosing
            };

            input1.AddCssClassIf(IsValidation, "validation");
            input1.Attributes.Add("id", For.Name);
            input1.Attributes.Add("name", For.Name);
            input1.Attributes.Add("value", $"{For.Model}");
            input1.Attributes.AddIf(IsReadOnlyResult, "readonly");
            input1.Attributes.AddIf(IsRequired, "required");
            input1.Attributes.AddIf(IsBool, "type", "checkbox");
            input1.AddCssClassIf(IsBool, "checkbox");

            input1.Attributes.AddIf(!IsDisplay, "placeholder", For.Name.Humanize().Titleize());

            // Need to account for radio and textarea
            input1.AddCssClassIf(!IsBool, "input");

            if (IsDate && !IsReadOnlyResult)
            {
                input1.Attributes.Add("type", "date");
                input1.Attributes.Add("data-show-header", false);
                input1.Attributes.Add("data-color", "dark");
                input1.Attributes.Add("date-date-format", "YYYY-MM-DD");
                input1.MergeAttribute("value", $"{For.Model:yyyy-MM-dd}");
            }

            if (IsDateTime && !IsReadOnlyResult)
            {
                input1.Attributes.Add("type", "date");
                input1.Attributes.Add("data-show-header", false);
                input1.Attributes.Add("data-color", "dark");
                input1.Attributes.Add("date-date-format", "YYYY-MM-DD HH:mm");
                input1.MergeAttribute("value", $"{For.Model:yyyy-MM-dd HH:mm}");
            }

            if (IsRegularExpression)
            {
                input1.Attributes.Add("pattern", GetModelAttributes().GetModelAttribute <RegularExpressionAttribute>().Pattern);
            }

            if (IsCompare)
            {
                input1.Attributes.Add("data-nw-compare", GetModelAttributes().GetModelAttribute <CompareAttribute>().OtherProperty);
            }

            if (IsEditable)
            {
                input1.Attributes.AddIf(!GetModelAttributes().GetModelAttribute <EditableAttribute>().AllowEdit, "readonly");
            }

            if (IsDisplay)
            {
                input1.Attributes.AddIf(!IsDate && !IsDateTime, "placeholder", GetModelAttributes().GetModelAttribute <DisplayAttribute>().Prompt);
                input1.Attributes.AddIf(IsDate, "placeholder", DateTime.Today.ToShortTimeString());
                input1.Attributes.AddIf(IsDateTime, "placeholder", DateTime.Today.ToShortTimeString());
            }

            if (IsStringLength)
            {
                var attribute = GetModelAttributes().GetModelAttribute <StringLengthAttribute>();

                input1.Attributes.Add("minlength", attribute.MinimumLength);
                input1.Attributes.Add("maxlength", attribute.MaximumLength);
            }

            if (IsMinLength)
            {
                input1.Attributes.AddIfMissing("minlength", GetModelAttributes().GetModelAttribute <MinLengthAttribute>().Length);
            }

            if (IsMaxLength)
            {
                input1.Attributes.AddIfMissing("maxlength", GetModelAttributes().GetModelAttribute <MaxLengthAttribute>().Length);
            }

            if (IsRemote)
            {
                var attribute = GetModelAttributes().GetModelAttribute <RemoteAttribute>();

                input1.Attributes.Add("data-nw-action", _urlHelper.ActionLink(attribute.Action, attribute.Controller));
                input1.Attributes.AddIf(!string.IsNullOrWhiteSpace(attribute.AdditionalFields), "data-nw-additional-fields", attribute.AdditionalFields);
            }

            input1.Attributes.Add("data-nw-validation");

            input1.Attributes.AddIfMissing("type", "text");

            return(input1);
        }
        public static string ActionLink(this IUrlHelper helper, string action = null, Type controller = null, string fragment = null)
        {
            string controllerName = GetControllerName(controller);

            return(helper.ActionLink(action, controllerName, null, "https", helper.ActionContext.HttpContext.Request.Host.Value, fragment));
        }
Esempio n. 18
0
 public static string GetOpenApiConfigUrl(IUrlHelper urlHelper, object values = null)
 {
     return(urlHelper.ActionLink(nameof(OpenApiConfigController.Get),
                                 TypeHelpers.GetControllerName(typeof(OpenApiConfigController)), values));
 }
 public string GetActionLink(IUrlHelper helper, string action, ApplicationUser user, string code)
 {
     return(helper.ActionLink(action,
                              values: new { userId = user.Id, code = code }));
 }