#65 fixing GanjoorComment table design fault (InReplyToId)
This commit is contained in:
parent
7a21697401
commit
dc44390f5b
@ -10,7 +10,7 @@ using RMuseum.DbContext;
|
||||
namespace RMuseum.Migrations
|
||||
{
|
||||
[DbContext(typeof(RMuseumDbContext))]
|
||||
[Migration("20210204114910_GanjoorComments")]
|
||||
[Migration("20210205054558_GanjoorComments")]
|
||||
partial class GanjoorComments
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
@ -394,10 +394,7 @@ namespace RMuseum.Migrations
|
||||
b.Property<string>("HtmlComment")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<Guid?>("InReplyToId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<int?>("InReplyToId1")
|
||||
b.Property<int?>("InReplyToId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("PoemId")
|
||||
@ -411,7 +408,7 @@ namespace RMuseum.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("InReplyToId1");
|
||||
b.HasIndex("InReplyToId");
|
||||
|
||||
b.HasIndex("PoemId");
|
||||
|
||||
@ -1847,7 +1844,7 @@ namespace RMuseum.Migrations
|
||||
{
|
||||
b.HasOne("RMuseum.Models.Ganjoor.GanjoorComment", "InReplyTo")
|
||||
.WithMany()
|
||||
.HasForeignKey("InReplyToId1");
|
||||
.HasForeignKey("InReplyToId");
|
||||
|
||||
b.HasOne("RMuseum.Models.Ganjoor.GanjoorPoem", "Poem")
|
||||
.WithMany()
|
||||
@ -21,16 +21,15 @@ namespace RMuseum.Migrations
|
||||
AuthorIpAddress = table.Column<string>(nullable: true),
|
||||
CommentDate = table.Column<DateTime>(nullable: false),
|
||||
HtmlComment = table.Column<string>(nullable: true),
|
||||
InReplyToId1 = table.Column<int>(nullable: true),
|
||||
InReplyToId = table.Column<Guid>(nullable: true),
|
||||
InReplyToId = table.Column<int>(nullable: true),
|
||||
Status = table.Column<int>(nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_GanjoorComments", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_GanjoorComments_GanjoorComments_InReplyToId1",
|
||||
column: x => x.InReplyToId1,
|
||||
name: "FK_GanjoorComments_GanjoorComments_InReplyToId",
|
||||
column: x => x.InReplyToId,
|
||||
principalTable: "GanjoorComments",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
@ -49,9 +48,9 @@ namespace RMuseum.Migrations
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_GanjoorComments_InReplyToId1",
|
||||
name: "IX_GanjoorComments_InReplyToId",
|
||||
table: "GanjoorComments",
|
||||
column: "InReplyToId1");
|
||||
column: "InReplyToId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_GanjoorComments_PoemId",
|
||||
@ -392,10 +392,7 @@ namespace RMuseum.Migrations
|
||||
b.Property<string>("HtmlComment")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<Guid?>("InReplyToId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<int?>("InReplyToId1")
|
||||
b.Property<int?>("InReplyToId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("PoemId")
|
||||
@ -409,7 +406,7 @@ namespace RMuseum.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("InReplyToId1");
|
||||
b.HasIndex("InReplyToId");
|
||||
|
||||
b.HasIndex("PoemId");
|
||||
|
||||
@ -1845,7 +1842,7 @@ namespace RMuseum.Migrations
|
||||
{
|
||||
b.HasOne("RMuseum.Models.Ganjoor.GanjoorComment", "InReplyTo")
|
||||
.WithMany()
|
||||
.HasForeignKey("InReplyToId1");
|
||||
.HasForeignKey("InReplyToId");
|
||||
|
||||
b.HasOne("RMuseum.Models.Ganjoor.GanjoorPoem", "Poem")
|
||||
.WithMany()
|
||||
|
||||
@ -72,7 +72,7 @@ namespace RMuseum.Models.Ganjoor
|
||||
/// <summary>
|
||||
/// Reference Comment Id
|
||||
/// </summary>
|
||||
public Guid? InReplyToId { get; set; }
|
||||
public int? InReplyToId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// publish status
|
||||
|
||||
@ -0,0 +1,47 @@
|
||||
using System;
|
||||
|
||||
namespace RMuseum.Models.Ganjoor.ViewModels
|
||||
{
|
||||
/// <summary>
|
||||
/// GanjoorComment Summary View Model
|
||||
/// </summary>
|
||||
public class GanjoorCommentSummaryViewModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Id
|
||||
/// </summary>
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// author name (MySql imported field)
|
||||
/// </summary>
|
||||
public string AuthorName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// author url (MySql imported field)
|
||||
/// </summary>
|
||||
public string AuthorUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// comment date
|
||||
/// </summary>
|
||||
public DateTime CommentDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// comment
|
||||
/// </summary>
|
||||
public string HtmlComment { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// status
|
||||
/// </summary>
|
||||
public string PublishStatus { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// replies
|
||||
/// </summary>
|
||||
|
||||
public GanjoorCommentSummaryViewModel[] Replies { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@ -4184,6 +4184,46 @@
|
||||
poems
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:RMuseum.Models.Ganjoor.ViewModels.GanjoorCommentSummaryViewModel">
|
||||
<summary>
|
||||
GanjoorComment Summary View Model
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.Ganjoor.ViewModels.GanjoorCommentSummaryViewModel.Id">
|
||||
<summary>
|
||||
Id
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.Ganjoor.ViewModels.GanjoorCommentSummaryViewModel.AuthorName">
|
||||
<summary>
|
||||
author name (MySql imported field)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.Ganjoor.ViewModels.GanjoorCommentSummaryViewModel.AuthorUrl">
|
||||
<summary>
|
||||
author url (MySql imported field)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.Ganjoor.ViewModels.GanjoorCommentSummaryViewModel.CommentDate">
|
||||
<summary>
|
||||
comment date
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.Ganjoor.ViewModels.GanjoorCommentSummaryViewModel.HtmlComment">
|
||||
<summary>
|
||||
comment
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.Ganjoor.ViewModels.GanjoorCommentSummaryViewModel.PublishStatus">
|
||||
<summary>
|
||||
status
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.Ganjoor.ViewModels.GanjoorCommentSummaryViewModel.Replies">
|
||||
<summary>
|
||||
replies
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:RMuseum.Models.Ganjoor.ViewModels.GanjoorPageCompleteViewModel">
|
||||
<summary>
|
||||
Ganjoor Page View Model
|
||||
|
||||
@ -15,6 +15,7 @@ using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using RMuseum.Services.Implementation.ImportedFromDesktopGanjoor;
|
||||
using RMuseum.Models.Artifact;
|
||||
|
||||
namespace RMuseum.Services.Implementation
|
||||
{
|
||||
@ -415,6 +416,48 @@ namespace RMuseum.Services.Implementation
|
||||
return new RServiceResult<PublicRecitationViewModel[]>(null, exp.ToString());
|
||||
}
|
||||
}
|
||||
/*
|
||||
public async Task<RServiceResult<GanjoorCommentSummaryViewModel[]>> GetPoemComments(int id, Guid userId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var source =
|
||||
from comment in _context.GanjoorComments
|
||||
where
|
||||
(comment.Status == PublishStatus.Published || (userId != Guid.Empty && comment.Status == PublishStatus.Awaiting && comment.UserId == userId))
|
||||
&&
|
||||
comment.Id == id
|
||||
orderby comment.CommentDate
|
||||
select new GanjoorCommentSummaryViewModel()
|
||||
{
|
||||
Id = comment.Id,
|
||||
};
|
||||
return new RServiceResult<GanjoorCommentSummaryViewModel[]>(await source.ToArrayAsync());
|
||||
}
|
||||
catch (Exception exp)
|
||||
{
|
||||
return new RServiceResult<GanjoorCommentSummaryViewModel[]>(null, exp.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<GanjoorCommentSummaryViewModel[]> _GetPoemComments(int id, Guid userId, int? inReplyToId)
|
||||
{
|
||||
var source =
|
||||
from comment in _context.GanjoorComments
|
||||
where
|
||||
(comment.Status == PublishStatus.Published || (userId != Guid.Empty && comment.Status == PublishStatus.Awaiting && comment.UserId == userId))
|
||||
&&
|
||||
comment.Id == id
|
||||
&&
|
||||
comment.InReplyToId == inReplyToId
|
||||
orderby comment.CommentDate
|
||||
select new GanjoorCommentSummaryViewModel()
|
||||
{
|
||||
Id = comment.Id,
|
||||
};
|
||||
return await source.ToArrayAsync();
|
||||
}
|
||||
*/
|
||||
|
||||
/// <summary>
|
||||
/// get poem images by id (some fields are intentionally field with blank or null),
|
||||
|
||||
@ -11,7 +11,7 @@ namespace RSecurityBackend.Models.Auth.ViewModels
|
||||
/// username
|
||||
/// </summary>
|
||||
/// <example>
|
||||
/// admin
|
||||
/// admin@ganjoor.net
|
||||
/// </example>
|
||||
public string Username { get; set; }
|
||||
|
||||
|
||||
@ -1165,7 +1165,7 @@
|
||||
username
|
||||
</summary>
|
||||
<example>
|
||||
admin
|
||||
admin@ganjoor.net
|
||||
</example>
|
||||
</member>
|
||||
<member name="P:RSecurityBackend.Models.Auth.ViewModels.LoginViewModel.Password">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user