Esempio n. 1
0
        // ReSharper disable MemberCanBePrivate.Global
        // ReSharper disable MemberCanBeProtected.Global
        // ReSharper disable UnusedMember.Global
        // ReSharper disable UnusedMethodReturnValue.Global
        // ReSharper disable UnusedAutoPropertyAccessor.Global
        // ReSharper disable UnassignedField.Global

        #endregion ReSharper disable

        public static string GenerateHtml(bool isVirtual, string stateCode,
                                          string countyCode, string localCode)
        {
            var placeHolder = new PlaceHolder();

            Generate(placeHolder, stateCode, countyCode, localCode, isVirtual);
            return(placeHolder.RenderToString());
        }
Esempio n. 2
0
        public IHttpActionResult GetNotifications(PagedResults pagedResults)
        {
            var userId     = pagedResults.UserId;
            var pageSize   = pagedResults.PageSize;
            var pageNumber = pagedResults.PageNumber;

            var activities = this.GetRepository <Activity>().GetPaged(
                a => a.UserID == userId && a.FromUserID.HasValue && a.Notification,
                pageNumber,
                pageSize);

            var attachmentItems = new List <AttachmentItem>();

            activities.ForEach(
                activity =>
            {
                var messageHolder = new PlaceHolder();
                var iconLabel     = new Label {
                    CssClass = "fa-stack"
                };

                var message = string.Empty;
                var icon    = string.Empty;

                var topicLink = new HyperLink
                {
                    NavigateUrl =
                        BuildLink.GetLink(
                            ForumPages.Posts,
                            "m={0}#post{0}",
                            activity.MessageID.Value),
                    Text =
                        $"<i class=\"fas fa-comment fa-fw mr-1\"></i>{this.GetRepository<Topic>().GetById(activity.TopicID.Value).TopicName}"
                };

                var name = this.Get <IUserDisplayName>().GetName(activity.FromUserID.Value);

                if (activity.ActivityFlags.ReceivedThanks)
                {
                    icon    = "heart";
                    message = this.Get <ILocalization>().GetTextFormatted(
                        "RECEIVED_THANKS_MSG",
                        name,
                        topicLink.RenderToString());
                }

                if (activity.ActivityFlags.WasMentioned)
                {
                    icon    = "at";
                    message = this.Get <ILocalization>().GetTextFormatted(
                        "WAS_MENTIONED_MSG",
                        name,
                        topicLink.RenderToString());
                }

                if (activity.ActivityFlags.WasQuoted)
                {
                    icon    = "quote-left";
                    message = this.Get <ILocalization>().GetTextFormatted(
                        "WAS_QUOTED_MSG",
                        name,
                        topicLink.RenderToString());
                }

                var notify = activity.Notification ? "text-success" : "text-secondary";

                iconLabel.Text = $@"<i class=""fas fa-circle fa-stack-2x {notify}""></i>
                                            <i class=""fas fa-{icon} fa-stack-1x fa-inverse""></i>";

                messageHolder.Controls.Add(iconLabel);

                messageHolder.Controls.Add(new Literal {
                    Text = message
                });

                var attachment = new AttachmentItem
                {
                    FileName = messageHolder.RenderToString()
                };

                attachmentItems.Add(attachment);
            });

            return(this.Ok(
                       new GridDataSet
            {
                PageNumber = pageNumber,
                TotalRecords =
                    activities.Any()
                                ? this.GetRepository <Activity>().Count(a => a.UserID == userId && a.FromUserID.HasValue && a.Notification)
                    .ToType <int>()
                                : 0,
                PageSize = pageSize,
                AttachmentList = attachmentItems
            }));
        }