コード例 #1
0
        public IActionResult GetComments([FromQuery] PagingQuery paging, [FromQuery] CommentLevel deliveryLevel, [FromQuery] CommentLevel orderLevel, [FromQuery] DateTime?startDate, [FromQuery] DateTime?endDate, int businessId, [FromServices] IBusinessRepository businessRepository)
        {
            var start = startDate ?? new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
            var end   = endDate ?? new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);

            int[] businessIds;
            if (businessId == 0)
            {
                if (Business.Category == BusinessCategory.Chain)
                {
                    businessIds = businessRepository.GetStoresOnlyId(Business.ID).Select(a => a.Item1).ToArray();
                }
                else
                {
                    businessIds = new[] { Business.ID };
                }
            }
            else
            {
                businessIds = new[] { businessId };
            }
            var list = Service.GetComments(deliveryLevel, orderLevel, start, end, paging, businessIds);

            return(Json(new
            {
                rows = list,
                count = paging.RecordCount
            }));
        }
コード例 #2
0
        public void TestCommentParse(string input, CommentLevel expectedCommentLevel = CommentLevel.Comment,
                                     string expectedContent = "Comment")
        {
            Resource parsed = new LinguiniParser(input).ParseWithComments();

            Assert.That(parsed.Entries.Count, Is.EqualTo(1));
            if (parsed.Entries[0] is AstComment comment)
            {
                Assert.AreEqual(expectedCommentLevel, comment.CommentLevel);
                Assert.AreEqual(expectedContent, comment.AsStr());
            }
            else
            {
                Assert.Fail("Comment was not found");
            }
        }
コード例 #3
0
ファイル: CommentClose.cs プロジェクト: tmakij/MiniPascal
 public CommentClose(CommentLevel Level)
 {
     level = Level;
 }
コード例 #4
0
 public AstComment(CommentLevel commentLevel, List <ReadOnlyMemory <char> > content)
 {
     CommentLevel = commentLevel;
     _content     = content;
 }
コード例 #5
0
        private string generateCommentTreeHTML(List <PageContent> lstCommnet, CommentLevel commentLevel)
        {
            StringBuilder resBuilder = new StringBuilder();

            foreach (var comment in lstCommnet)
            {
                resBuilder.AppendFormat(htmlRow, comment.ID);
                resBuilder.Append(htmlFormGroup);

                switch (commentLevel)
                {
                case CommentLevel.Root:
                    resBuilder.Append(hrmlColmd12);
                    break;

                case CommentLevel.Reply:
                    resBuilder.Append(hrmlColmd11_colmdoffset1);
                    break;

                case CommentLevel.ReplyToReply:
                    resBuilder.Append(hrmlColmd10_colmdoffset2);
                    break;

                default:
                {
                    resBuilder.Append(commentLevel);
                }
                break;
                }

                string eventId = null;
                string url     = null;
                //linky sa generuju len ked pride na vstup uz list komentarov
                if (!string.IsNullOrEmpty(comment.EventId) && forumType == ForumType.CommentList)
                {
                    string[] eventIdParams = comment.EventId.Split(GlobalConstants.EventIdSeparator, StringSplitOptions.RemoveEmptyEntries);
                    if (comment.IsEvent && eventIdParams.Length == 2)
                    {
                        eventId = $"{eventIdParams[0]} {eventIdParams[1]}";
                        url     = $"AkciaPopis.aspx?{QueryStringHelper.KeyID}={HttpUtility.UrlEncode(comment.EventId)}&{QueryStringHelper.KeyCommentId}=comment_{comment.ID}";
                    }
                    if (comment.IsPhoto && eventIdParams.Length == 2)
                    {
                        eventId = $"{eventIdParams[0]} {eventIdParams[1]} galéria";
                        url     = $"Akcia.aspx?{QueryStringHelper.KeyID}={HttpUtility.UrlEncode(comment.EventId)}&{QueryStringHelper.KeyCommentId}=comment_{comment.ID}";
                    }
                    if (comment.IsVideo && eventIdParams.Length == 4)
                    {
                        eventId = $"{eventIdParams[0]} {eventIdParams[1]} {eventIdParams[3]}";
                        url     = $"Video.aspx?{QueryStringHelper.KeyID}={HttpUtility.UrlEncode(comment.EventId)}&{QueryStringHelper.KeyCommentId}=comment_{comment.ID}";
                    }
                    if (comment.IsFileSystem)
                    {
                        switch (eventIdParams.Length)
                        {
                        case 1:     //rok
                            eventId = $"Rok {eventIdParams[0]}";
                            url     = $"RokAkcie.aspx?{QueryStringHelper.KeyID}={HttpUtility.UrlEncode(comment.EventId)}";
                            break;

                        case 2:     //akcia
                            eventId = $"Rok {eventIdParams[0]}, akcia {eventIdParams[1]}";
                            url     = $"AkciaPopis.aspx?{QueryStringHelper.KeyID}={HttpUtility.UrlEncode(comment.EventId)}";
                            break;

                        case 4:    //video
                            eventId = $"Rok {eventIdParams[0]}, akcia {eventIdParams[1]}, video {eventIdParams[3]}";
                            url     = $"Video.aspx?{QueryStringHelper.KeyID}={HttpUtility.UrlEncode(comment.EventId)}";
                            break;

                        default:
                            break;
                        }
                    }
                }

                string user = string.Format("<strong>{0}</strong> {1} {2}",
                                            (!string.IsNullOrEmpty(comment.ScoutNickName) ? comment.ScoutNickName : comment.NickName),
                                            !comment.IsFileSystem ? CommonLogic.ToSKDateTime(comment.CreatedUTC) : string.Empty,
                                            string.Format("<a href=\"{0}\">{1}</a>", url, eventId));
                string picture = null;

                if (!string.IsNullOrEmpty(comment.ThumbPath))
                {
                    picture = string.Format(image, comment.ThumbPath);
                }

                string replyLink = null;
                if (commentLevel != CommentLevel.ReplyToReply && forumType != ForumType.CommentList)
                {
                    replyLink = string.Format(htmlReplyLink, comment.ID);
                }

                string editLink   = null;
                string deleteLink = null;
                if (comment.UserName == Context.User.Identity.Name && forumType != ForumType.CommentList)
                {
                    editLink   = string.Format(htmlEditLink, comment.ID);
                    deleteLink = string.Format(htmlDeleteLink, comment.ID);
                }

                resBuilder.AppendFormat(htmlComment, comment.ID, user, replyLink, picture, editLink, deleteLink);
                resBuilder.AppendLine(comment.Comment);
                resBuilder.AppendLine(htmlEndP);
                resBuilder.AppendLine(htmlEndDiv);
                resBuilder.AppendLine(htmlEndDiv);
                resBuilder.AppendLine(htmlEndDiv);

                if (forumType != ForumType.CommentList)
                {
                    List <PageContent> lstChild = null;
                    using (var _db = new Kronika106.Models.Kronika106DBContext())
                    {
                        lstChild = (from EventComments childComment in _db.Forum
                                    where childComment.RootID == comment.ID
                                    orderby comment.ID descending
                                    select new PageContent {
                            ID = childComment.ID, CreatedUTC = childComment.CreatedUTC, EventId = childComment.EventId, RootID = childComment.RootID, ThumbPath = childComment.ThumbPath, ScoutNickName = childComment.ApplicationUser.ScoutNickName, NickName = childComment.ApplicationUser.NickName, Comment = childComment.Comment, IsVideo = childComment.IsVideo, IsEvent = comment.IsEvent, IsPhoto = comment.IsPhoto, UserID = childComment.ApplicationUser.Id, UserName = childComment.ApplicationUser.UserName                                 /*, VideoPosition= comment.VideoPosition */
                        }).ToList();
                    }
                    if (lstChild.Count > 0)
                    {
                        resBuilder.AppendLine(generateCommentTreeHTML(lstChild, commentLevel + 1));
                    }
                }
                //else
                //{
                //    resBuilder.AppendLine(htmlHr);
                //}
            }
            return(resBuilder.ToString());
        }
コード例 #6
0
 public CommentOpen(CommentLevel Level)
 {
     level = Level;
 }