diff --git a/GanjooRazor/Pages/_HashiehaPage.cshtml.cs b/GanjooRazor/Pages/_HashiehaPage.cshtml.cs index 922300ff..3b91a6ba 100644 --- a/GanjooRazor/Pages/_HashiehaPage.cshtml.cs +++ b/GanjooRazor/Pages/_HashiehaPage.cshtml.cs @@ -111,7 +111,7 @@ namespace GanjooRazor.Pages foreach (var comment in comments) { string commentAuthorLink = comment.UserId == null ? comment.AuthorName : $"{comment.AuthorName}"; - string inReplyTo = comment.InReplayTo == null ? "" : $" در پاسخ به {comment.InReplayTo.AuthorName} "; + string inReplyTo = comment.InReplyTo == null ? "" : $" در پاسخ به {comment.InReplyTo.AuthorName} "; htmlText += $"

{commentAuthorLink} در {comment.CommentDate.ToFriendlyPersianDateTextify()}{inReplyTo} دربارهٔ {comment.Poem.Title}:

" + $"
{comment.HtmlComment}{Environment.NewLine}" + $"
{Environment.NewLine}
 

{Environment.NewLine}"; diff --git a/RMuseum/Models/Ganjoor/ViewModels/GanjoorCommentFullViewModel.cs b/RMuseum/Models/Ganjoor/ViewModels/GanjoorCommentFullViewModel.cs index 8032ba77..6977caf1 100644 --- a/RMuseum/Models/Ganjoor/ViewModels/GanjoorCommentFullViewModel.cs +++ b/RMuseum/Models/Ganjoor/ViewModels/GanjoorCommentFullViewModel.cs @@ -43,7 +43,7 @@ namespace RMuseum.Models.Ganjoor.ViewModels /// in reply to /// - public GanjoorCommentSummaryViewModel InReplayTo { get; set; } + public GanjoorCommentSummaryViewModel InReplyTo { get; set; } /// /// poem diff --git a/RMuseum/Models/Ganjoor/ViewModels/GanjoorCommentSummaryViewModel.cs b/RMuseum/Models/Ganjoor/ViewModels/GanjoorCommentSummaryViewModel.cs index d8f89cea..bad73d84 100644 --- a/RMuseum/Models/Ganjoor/ViewModels/GanjoorCommentSummaryViewModel.cs +++ b/RMuseum/Models/Ganjoor/ViewModels/GanjoorCommentSummaryViewModel.cs @@ -59,6 +59,27 @@ namespace RMuseum.Models.Ganjoor.ViewModels /// public bool MyComment { get; set; } + /// + /// verse1 id + /// + public int Verse1Id { get; set; } + + /// + /// verse2 id + /// + public int Verse2Id { get; set; } + + + /// + /// couplet index + /// + public int CoupletIndex { get; set; } + + /// + /// couplet summary + /// + public string CoupletSummary { get; set; } + } } diff --git a/RMuseum/RMuseum.xml b/RMuseum/RMuseum.xml index a4b1ed5f..9acef378 100644 --- a/RMuseum/RMuseum.xml +++ b/RMuseum/RMuseum.xml @@ -5447,7 +5447,7 @@ User Id - + in reply to @@ -5542,6 +5542,26 @@ this can be used by clients + + + verse1 id + + + + + verse2 id + + + + + couplet index + + + + + couplet summary + + Rhyme Analysis Result diff --git a/RMuseum/Services/Implementation/GanjoorService.cs b/RMuseum/Services/Implementation/GanjoorService.cs index 4661ebe0..328a766b 100644 --- a/RMuseum/Services/Implementation/GanjoorService.cs +++ b/RMuseum/Services/Implementation/GanjoorService.cs @@ -566,7 +566,10 @@ namespace RMuseum.Services.Implementation HtmlComment = comment.HtmlComment, PublishStatus = comment.Status == PublishStatus.Awaiting ? "در انتظار تأیید" : "", InReplyToId = comment.InReplyToId, - UserId = comment.UserId + UserId = comment.UserId, + CoupletIndex = comment.CoupletIndex == null ? -1 : (int)comment.CoupletIndex, + Verse1Id = comment.Verse1Id == null ? -1 : (int)comment.Verse1Id, + Verse2Id = comment.Verse12d == null ? -1 : (int)comment.Verse12d }; GanjoorCommentSummaryViewModel[] allComments = await source.AsNoTracking().ToArrayAsync(); @@ -574,6 +577,12 @@ namespace RMuseum.Services.Implementation foreach (GanjoorCommentSummaryViewModel comment in allComments) { comment.AuthorName = comment.AuthorName.ToPersianNumbers().ApplyCorrectYeKe(); + string coupleText = comment.Verse1Id == -1 ? "" : (await _context.GanjoorVerses.Where(v => v.Id == comment.Verse1Id).FirstAsync()).Text; + if (comment.Verse2Id != -1) + { + coupleText += $" {(await _context.GanjoorVerses.Where(v => v.Id == comment.Verse2Id).FirstAsync()).Text}"; + } + comment.CoupletSummary = coupleText; } GanjoorCommentSummaryViewModel[] rootComments = allComments.Where(c => c.InReplyToId == null).ToArray(); @@ -618,6 +627,7 @@ namespace RMuseum.Services.Implementation return new RServiceResult(null, "لطفاً با مراجعه به پیشخان کاربری (دکمهٔ گوشهٔ پایین سمت چپ) «نام مستعار» خود را مشخص کنید و سپس اقدام به ارسال حاشیه بفرمایید."); } + string coupletSummary = ""; int? Verse1Id = null; int? Verse2Id = null; if (coupletIndex != null) @@ -631,17 +641,24 @@ namespace RMuseum.Services.Implementation if (cIndex == coupletIndex) { Verse1Id = verses[i].Id; + coupletSummary = verses[i].Text; if (verses[i].VersePosition == VersePosition.Right) { if (i < verses.Count - 2) + { Verse2Id = verses[i + 1].Id; + coupletSummary += $" {verses[i + 1].Text}"; + } } if (verses[i].VersePosition == VersePosition.CenteredVerse1) { if (i < verses.Count - 2) { if (verses[i + 1].VersePosition == VersePosition.CenteredVerse2) + { Verse2Id = verses[i + 1].Id; + coupletSummary += $" {verses[i + 1].Text}"; + } } } break; @@ -671,7 +688,7 @@ namespace RMuseum.Services.Implementation Status = PublishStatus.Published, Verse1Id = Verse1Id, Verse12d = Verse2Id, - CoupletIndex = coupletIndex + CoupletIndex = coupletIndex, }; _context.GanjoorComments.Add(comment); await _context.SaveChangesAsync(); @@ -709,9 +726,13 @@ namespace RMuseum.Services.Implementation PublishStatus = comment.Status == PublishStatus.Awaiting ? "در انتظار تأیید" : "", InReplyToId = comment.InReplyToId, UserId = comment.UserId, - Replies = new GanjoorCommentSummaryViewModel[] { } + Replies = new GanjoorCommentSummaryViewModel[] { }, + CoupletIndex = coupletIndex == null ? -1 : (int)coupletIndex, + MyComment = true, + Verse1Id = Verse1Id == null ? -1 : (int)Verse1Id, + CoupletSummary = coupletSummary } - ); + ); ; } /// @@ -915,7 +936,7 @@ namespace RMuseum.Services.Implementation HtmlComment = comment.HtmlComment, PublishStatus = "",//invalid! UserId = comment.UserId, - InReplayTo = comment.InReplyTo == null ? null : + InReplyTo = comment.InReplyTo == null ? null : new GanjoorCommentSummaryViewModel() { Id = comment.InReplyTo.Id, @@ -924,7 +945,10 @@ namespace RMuseum.Services.Implementation CommentDate = comment.InReplyTo.CommentDate, HtmlComment = comment.InReplyTo.HtmlComment, PublishStatus = "", - UserId = comment.InReplyTo.UserId + UserId = comment.InReplyTo.UserId, + CoupletIndex = comment.InReplyTo.CoupletIndex == null ? -1 : (int)comment.InReplyTo.CoupletIndex, + Verse1Id = comment.InReplyTo.Verse1Id == null ? -1 : (int)comment.InReplyTo.Verse1Id, + Verse2Id = comment.InReplyTo.Verse12d == null ? -1 : (int)comment.InReplyTo.Verse12d }, Poem = new GanjoorPoemSummaryViewModel() { @@ -942,6 +966,15 @@ namespace RMuseum.Services.Implementation foreach (GanjoorCommentFullViewModel comment in paginatedResult.Items) { comment.AuthorName = comment.AuthorName.ToPersianNumbers().ApplyCorrectYeKe(); + if(comment.InReplyTo != null) + { + string coupleText = comment.InReplyTo.Verse1Id == -1 ? "" : (await _context.GanjoorVerses.Where(v => v.Id == comment.InReplyTo.Verse1Id).FirstAsync()).Text; + if(comment.InReplyTo.Verse2Id != -1) + { + coupleText += $" {(await _context.GanjoorVerses.Where(v => v.Id == comment.InReplyTo.Verse2Id).FirstAsync()).Text}"; + } + comment.InReplyTo.CoupletSummary = coupleText; + } } return new RServiceResult<(PaginationMetadata PagingMeta, GanjoorCommentFullViewModel[] Items)>(paginatedResult); @@ -1011,7 +1044,7 @@ namespace RMuseum.Services.Implementation HtmlComment = comment.HtmlComment, PublishStatus = "",//invalid! UserId = comment.UserId, - InReplayTo = comment.InReplyTo == null ? null : + InReplyTo = comment.InReplyTo == null ? null : new GanjoorCommentSummaryViewModel() { Id = comment.InReplyTo.Id,