change to comment

subProduct
Amir Hossein Khademi 2024-09-25 17:08:35 +03:30
parent ca934aecc8
commit 908424f9be
17 changed files with 3014 additions and 744 deletions

View File

@ -1,34 +1,34 @@
namespace Netina.Api.Controllers;
public class ProductCommentController : ICarterModule
public class CommentController : ICarterModule
{
public void AddRoutes(IEndpointRouteBuilder app)
{
var group = app.NewVersionedApi("ProductComment")
.MapGroup("api/product/comment");
var group = app.NewVersionedApi("Comments")
.MapGroup("api/comment");
group.MapGet("{id}", GetAsync)
.WithDisplayName("Get Product Comment")
.WithDisplayName("Get Comment")
.RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ViewAllReviews,ApplicationPermission.ManageReview))
.HasApiVersion(1.0);
group.MapGet("", GetAllAsync)
.WithDisplayName("Get Product Comments")
.WithDisplayName("Get Comments")
.RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ViewAllReviews, ApplicationPermission.ManageReview))
.HasApiVersion(1.0);
group.MapPost("", PostAsync)
.WithDisplayName("Create Product Comment")
.WithDisplayName("Create Comment")
.RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser())
.HasApiVersion(1.0);
group.MapPut("confirm/{id}", ConfirmAsync)
.WithDisplayName("Confirm Product Comment")
.WithDisplayName("Confirm Comment")
.RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ConfirmReview, ApplicationPermission.ManageReview))
.HasApiVersion(1.0);
group.MapDelete("{id}", DeleteAsync)
.WithDisplayName("Delete Product Comment")
.WithDisplayName("Delete Comment")
.RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ManageReview))
.HasApiVersion(1.0);
}

View File

@ -15,8 +15,6 @@ public class DashboardController : ICarterModule
group.MapGet("orders", GetOrdersDashboardAsync)
.WithDisplayName("Get Orders Dashboard")
.HasApiVersion(1.0);
}
private async Task<IResult> GetOrdersDashboardAsync([FromServices] IDashboardService dashboardService, CancellationToken cancellationToken)

View File

@ -39,7 +39,7 @@ public class ProductController : ICarterModule
.HasApiVersion(1.0);
group.MapGet("{productId}/comment",GetProductCommentsAsync)
.WithDisplayName("Get Product Reviews")
.WithDisplayName("Get Product Comments")
.HasApiVersion(1.0);
group.MapDelete("{id}", Delete)

View File

@ -5,7 +5,7 @@ namespace Netina.Domain.Dtos.LargDtos;
public class CommentLDto : BaseDto<CommentLDto,Comment>
{
public string Title { get; set; } = string.Empty;
public string Comment { get; set; } = string.Empty;
public string Content { get; set; } = string.Empty;
public float Rate { get; set; }
public bool IsBuyer { get; set; }
public bool IsConfirmed { get; set; }

View File

@ -27,7 +27,6 @@ public class ProductLDto : BaseDto<ProductLDto,Product>
public bool IsSpecialOffer { get; set; }
public List<SpecificationSDto> Specifications { get; set; } = new();
public List<CommentSDto> Reviews { get; set; } = new();
public List<StorageFileSDto> Files { get; set; } = new();
public DiscountSDto? SpecialOffer { get; set; }

View File

@ -6,9 +6,7 @@ public class CommentSDto : BaseDto<CommentSDto, Comment>
{
public string Title { get; set; } = string.Empty;
public string Content { get; set; } = string.Empty;
public string FullName { get; set; } = string.Empty;
public string Email { get; set; } = string.Empty;
public string PhoneNumber { get; set; } = string.Empty;
public bool IsAdmin { get; internal set; }
public bool IsConfirmed { get; set; }
public Guid ParentId { get; set; }
public Guid UserId { get; set; }

View File

@ -82,7 +82,7 @@ public partial class Product : ApiEntity
public ProductCategory? Category { get; internal set; }
public List<Specification> Specifications { get; internal set; } = new();
public List<Comment> Reviews { get; internal set; } = new();
public List<ProductComment> Comments { get; internal set; } = new();
public List<ProductStorageFile> Files { get; internal set; } = new();
public List<OrderProduct> OrderProducts { get; internal set; } = new();

View File

@ -1,8 +1,10 @@
using System;
using System.Linq.Expressions;
using Mapster.Models;
using Netina.Domain.Dtos.LargDtos;
using Netina.Domain.Dtos.SmallDtos;
using Netina.Domain.Entities.Comments;
using Netina.Domain.Entities.Users;
namespace Netina.Domain.Mappers
{
@ -13,10 +15,13 @@ namespace Netina.Domain.Mappers
return p1 == null ? null : new Comment()
{
Title = p1.Title,
Content = p1.Content,
Rate = p1.Rate,
IsConfirmed = p1.IsConfirmed,
ParentId = (Guid?)p1.ParentId,
Parent = new Comment() {Id = p1.ParentId},
UserId = p1.UserId,
User = new ApplicationUser() {Id = p1.UserId},
Id = p1.Id,
CreatedAt = p1.CreatedAt
};
@ -30,137 +35,197 @@ namespace Netina.Domain.Mappers
Comment result = p3 ?? new Comment();
result.Title = p2.Title;
result.Content = p2.Content;
result.Rate = p2.Rate;
result.IsConfirmed = p2.IsConfirmed;
result.ParentId = (Guid?)p2.ParentId;
result.Parent = funcMain1(new Never(), result.Parent, p2);
result.UserId = p2.UserId;
result.User = funcMain2(new Never(), result.User, p2);
result.Id = p2.Id;
result.CreatedAt = p2.CreatedAt;
return result;
}
public static Expression<Func<CommentLDto, Comment>> ProjectToComment => p4 => new Comment()
{
Title = p4.Title,
Rate = p4.Rate,
IsConfirmed = p4.IsConfirmed,
ParentId = (Guid?)p4.ParentId,
UserId = p4.UserId,
Id = p4.Id,
CreatedAt = p4.CreatedAt
};
public static CommentLDto AdaptToLDto(this Comment p5)
{
return p5 == null ? null : new CommentLDto()
{
Title = p5.Title,
Rate = p5.Rate,
IsConfirmed = p5.IsConfirmed,
ParentId = p5.ParentId == null ? default(Guid) : (Guid)p5.ParentId,
UserId = p5.UserId,
Id = p5.Id,
CreatedAt = p5.CreatedAt
};
}
public static CommentLDto AdaptTo(this Comment p6, CommentLDto p7)
{
if (p6 == null)
{
return null;
}
CommentLDto result = p7 ?? new CommentLDto();
result.Title = p6.Title;
result.Rate = p6.Rate;
result.IsConfirmed = p6.IsConfirmed;
result.ParentId = p6.ParentId == null ? default(Guid) : (Guid)p6.ParentId;
result.UserId = p6.UserId;
result.Id = p6.Id;
result.CreatedAt = p6.CreatedAt;
return result;
}
public static Expression<Func<Comment, CommentLDto>> ProjectToLDto => p8 => new CommentLDto()
public static Expression<Func<CommentLDto, Comment>> ProjectToComment => p8 => new Comment()
{
Title = p8.Title,
Content = p8.Content,
Rate = p8.Rate,
IsConfirmed = p8.IsConfirmed,
ParentId = p8.ParentId == null ? default(Guid) : (Guid)p8.ParentId,
ParentId = (Guid?)p8.ParentId,
Parent = new Comment() {Id = p8.ParentId},
UserId = p8.UserId,
User = new ApplicationUser() {Id = p8.UserId},
Id = p8.Id,
CreatedAt = p8.CreatedAt
};
public static Comment AdaptToComment(this CommentSDto p9)
public static CommentLDto AdaptToLDto(this Comment p9)
{
return p9 == null ? null : new Comment()
return p9 == null ? null : new CommentLDto()
{
Title = p9.Title,
Content = p9.Content,
Rate = p9.Rate,
IsConfirmed = p9.IsConfirmed,
ParentId = (Guid?)p9.ParentId,
ParentId = p9.ParentId == null ? default(Guid) : (Guid)p9.ParentId,
UserId = p9.UserId,
UserFullName = p9.User != null ? p9.User.FirstName + " " + p9.User.LastName : string.Empty,
Id = p9.Id,
CreatedAt = p9.CreatedAt
};
}
public static Comment AdaptTo(this CommentSDto p10, Comment p11)
public static CommentLDto AdaptTo(this Comment p10, CommentLDto p11)
{
if (p10 == null)
{
return null;
}
Comment result = p11 ?? new Comment();
CommentLDto result = p11 ?? new CommentLDto();
result.Title = p10.Title;
result.Content = p10.Content;
result.Rate = p10.Rate;
result.IsConfirmed = p10.IsConfirmed;
result.ParentId = (Guid?)p10.ParentId;
result.ParentId = p10.ParentId == null ? default(Guid) : (Guid)p10.ParentId;
result.UserId = p10.UserId;
result.UserFullName = p10.User != null ? p10.User.FirstName + " " + p10.User.LastName : string.Empty;
result.Id = p10.Id;
result.CreatedAt = p10.CreatedAt;
return result;
}
public static CommentSDto AdaptToSDto(this Comment p12)
{
return p12 == null ? null : new CommentSDto()
public static Expression<Func<Comment, CommentLDto>> ProjectToLDto => p12 => new CommentLDto()
{
Title = p12.Title,
Content = p12.Content,
Rate = p12.Rate,
IsConfirmed = p12.IsConfirmed,
ParentId = p12.ParentId == null ? default(Guid) : (Guid)p12.ParentId,
UserId = p12.UserId,
UserFullName = p12.User != null ? p12.User.FirstName + " " + p12.User.LastName : string.Empty,
Id = p12.Id,
CreatedAt = p12.CreatedAt
};
}
public static CommentSDto AdaptTo(this Comment p13, CommentSDto p14)
public static Comment AdaptToComment(this CommentSDto p13)
{
if (p13 == null)
return p13 == null ? null : new Comment()
{
Title = p13.Title,
Content = p13.Content,
IsConfirmed = p13.IsConfirmed,
IsAdmin = p13.IsAdmin,
ParentId = (Guid?)p13.ParentId,
Parent = new Comment() {Id = p13.ParentId},
UserId = p13.UserId,
User = new ApplicationUser() {Id = p13.UserId},
Id = p13.Id,
CreatedAt = p13.CreatedAt
};
}
public static Comment AdaptTo(this CommentSDto p14, Comment p15)
{
if (p14 == null)
{
return null;
}
CommentSDto result = p14 ?? new CommentSDto();
Comment result = p15 ?? new Comment();
result.Title = p13.Title;
result.Content = p13.Content;
result.IsConfirmed = p13.IsConfirmed;
result.ParentId = p13.ParentId == null ? default(Guid) : (Guid)p13.ParentId;
result.UserId = p13.UserId;
result.Id = p13.Id;
result.CreatedAt = p13.CreatedAt;
result.Title = p14.Title;
result.Content = p14.Content;
result.IsConfirmed = p14.IsConfirmed;
result.IsAdmin = p14.IsAdmin;
result.ParentId = (Guid?)p14.ParentId;
result.Parent = funcMain3(new Never(), result.Parent, p14);
result.UserId = p14.UserId;
result.User = funcMain4(new Never(), result.User, p14);
result.Id = p14.Id;
result.CreatedAt = p14.CreatedAt;
return result;
}
public static Expression<Func<Comment, CommentSDto>> ProjectToSDto => p15 => new CommentSDto()
public static CommentSDto AdaptToSDto(this Comment p20)
{
Title = p15.Title,
Content = p15.Content,
IsConfirmed = p15.IsConfirmed,
ParentId = p15.ParentId == null ? default(Guid) : (Guid)p15.ParentId,
UserId = p15.UserId,
Id = p15.Id,
CreatedAt = p15.CreatedAt
return p20 == null ? null : new CommentSDto()
{
Title = p20.Title,
Content = p20.Content,
IsAdmin = p20.IsAdmin,
IsConfirmed = p20.IsConfirmed,
ParentId = p20.ParentId == null ? default(Guid) : (Guid)p20.ParentId,
UserId = p20.UserId,
UserFullName = p20.User != null ? p20.User.FirstName + " " + p20.User.LastName : string.Empty,
Id = p20.Id,
CreatedAt = p20.CreatedAt
};
}
public static CommentSDto AdaptTo(this Comment p21, CommentSDto p22)
{
if (p21 == null)
{
return null;
}
CommentSDto result = p22 ?? new CommentSDto();
result.Title = p21.Title;
result.Content = p21.Content;
result.IsAdmin = p21.IsAdmin;
result.IsConfirmed = p21.IsConfirmed;
result.ParentId = p21.ParentId == null ? default(Guid) : (Guid)p21.ParentId;
result.UserId = p21.UserId;
result.UserFullName = p21.User != null ? p21.User.FirstName + " " + p21.User.LastName : string.Empty;
result.Id = p21.Id;
result.CreatedAt = p21.CreatedAt;
return result;
}
public static Expression<Func<Comment, CommentSDto>> ProjectToSDto => p23 => new CommentSDto()
{
Title = p23.Title,
Content = p23.Content,
IsAdmin = p23.IsAdmin,
IsConfirmed = p23.IsConfirmed,
ParentId = p23.ParentId == null ? default(Guid) : (Guid)p23.ParentId,
UserId = p23.UserId,
UserFullName = p23.User != null ? p23.User.FirstName + " " + p23.User.LastName : string.Empty,
Id = p23.Id,
CreatedAt = p23.CreatedAt
};
private static Comment funcMain1(Never p4, Comment p5, CommentLDto p2)
{
Comment result = p5 ?? new Comment();
result.Id = p2.ParentId;
return result;
}
private static ApplicationUser funcMain2(Never p6, ApplicationUser p7, CommentLDto p2)
{
ApplicationUser result = p7 ?? new ApplicationUser();
result.Id = p2.UserId;
return result;
}
private static Comment funcMain3(Never p16, Comment p17, CommentSDto p14)
{
Comment result = p17 ?? new Comment();
result.Id = p14.ParentId;
return result;
}
private static ApplicationUser funcMain4(Never p18, ApplicationUser p19, CommentSDto p14)
{
ApplicationUser result = p19 ?? new ApplicationUser();
result.Id = p14.UserId;
return result;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,6 @@
using Netina.Domain.Dtos.ResponseDtos.Torob;
using Netina.Domain.Entities.Accounting;
using Netina.Domain.Entities.Comments;
namespace Netina.Domain;
@ -28,6 +29,26 @@ public class MapsterRegister : IRegister
.Map("ShippingMethod", o => o.Shipping != null ? o.Shipping.Name : string.Empty)
.TwoWays();
config.NewConfig<Comment, CommentSDto>()
.Map(d => d.UserFullName, o => o.User != null ? o.User.FirstName + " " + o.User.LastName : string.Empty)
.TwoWays();
config.NewConfig<Comment, CommentLDto>()
.Map(d => d.UserFullName, o => o.User != null ? o.User.FirstName + " " + o.User.LastName : string.Empty)
.TwoWays();
ConfigProductMappers(config);
ConfigOrderMappers(config);
ConfigUserMappers(config);
}
private void ConfigProductMappers(TypeAdapterConfig config)
{
config.NewConfig<ProductCategory, ProductCategorySDto>()
.Map("MainImage", o => o.Files.FirstOrDefault(f => f.IsPrimary) != null ? o.Files.FirstOrDefault(f => f.IsPrimary).FileLocation : o.Files.Count > 0 ? o.Files.FirstOrDefault().FileLocation : string.Empty)
.Map("ParentName", o => o.Parent != null ? o.Parent.Name : string.Empty)
@ -62,16 +83,11 @@ public class MapsterRegister : IRegister
.TwoWays();
config.NewConfig<Product, TorobProductResponseDto>()
.Map(s=>s.availibility,o=>o.IsEnable)
.Map(s=>s.price , o=>o.Cost)
.Map(s=>s.product_id,o=>o.Id.ToString())
.Map(s => s.availibility, o => o.IsEnable)
.Map(s => s.price, o => o.Cost)
.Map(s => s.product_id, o => o.Id.ToString())
.IgnoreNullValues(false)
.TwoWays();
ConfigOrderMappers(config);
ConfigUserMappers(config);
}
private void ConfigOrderMappers(TypeAdapterConfig config)

View File

@ -16,13 +16,15 @@ public class CreateCommentCommandHandler(IRepositoryWrapper repositoryWrapper, I
else
userId = request.UserId.Value;
if (request.BlogId != null)
{
var entBlog = BlogComment.Create(request.Title, request.Content, request.Rate, request.IsAdmin, userId,
request.BlogId.Value);
var entBlog = BlogComment.Create(request.Title, request.Content, request.Rate, request.IsAdmin, userId, request.BlogId.Value);
if (request.IsAdmin)
entBlog.ConfirmReview();
if (request.ParentId != null)
entBlog.SetParent(request.ParentId.Value);
repositoryWrapper.SetRepository<BlogComment>().Add(entBlog);
await repositoryWrapper.SaveChangesAsync(cancellationToken);
return entBlog.Id;
@ -33,6 +35,8 @@ public class CreateCommentCommandHandler(IRepositoryWrapper repositoryWrapper, I
var entBlog = ProductComment.Create(request.Title, request.Content, request.Rate, request.IsBuyer,
request.IsAdmin, userId, request.ProductId.Value);
if (request.IsAdmin)
entBlog.ConfirmReview();
if (request.ParentId != null)
entBlog.SetParent(request.ParentId.Value);
@ -43,6 +47,8 @@ public class CreateCommentCommandHandler(IRepositoryWrapper repositoryWrapper, I
}
var ent = Comment.Create(request.Title, request.Content, request.Rate, request.IsAdmin, userId);
if (request.IsAdmin)
ent.ConfirmReview();
if (request.ParentId != null)
ent.SetParent(request.ParentId.Value);
repositoryWrapper.SetRepository<Comment>().Add(ent);

View File

@ -19,6 +19,7 @@ public class GetCommentsQueryHandler(IRepositoryWrapper repositoryWrapper)
var blogRoots = await blogQuery.ToListAsync(cancellationToken);
foreach (var root in blogRoots)
await LoadChildrenAsync(root, cancellationToken);
return blogRoots;
}
if (request.ProductId != null)
@ -32,6 +33,7 @@ public class GetCommentsQueryHandler(IRepositoryWrapper repositoryWrapper)
var blogRoots = await blogQuery.ToListAsync(cancellationToken);
foreach (var root in blogRoots)
await LoadChildrenAsync(root, cancellationToken);
return blogRoots;
}
var query = repositoryWrapper.SetRepository<Comment>().TableNoTracking

View File

@ -15,10 +15,5 @@ public class CreateCommentCommandValidator : AbstractValidator<CreateCommentComm
.NotNull()
.NotEmpty()
.WithMessage("متن نظر مورد نظر را وارد کنید");
RuleFor(d => d.ProductId)
.NotEqual(Guid.Empty)
.NotEmpty()
.WithMessage("کالا مورد نظر را وارد کنید");
}
}

View File

@ -15,10 +15,5 @@ public class UpdateCommentCommandValidator : AbstractValidator<UpdateCommentComm
.NotNull()
.NotEmpty()
.WithMessage("متن نظر مورد نظر را وارد کنید");
RuleFor(d => d.ProductId)
.NotEqual(Guid.Empty)
.NotEmpty()
.WithMessage("کالا مورد نظر را وارد کنید");
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,162 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace NetinaShop.Repository.Migrations
{
/// <inheritdoc />
public partial class ChangeToComment : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Reviews",
schema: "public");
migrationBuilder.CreateTable(
name: "Comments",
schema: "public",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Title = table.Column<string>(type: "text", nullable: false),
Content = table.Column<string>(type: "text", nullable: false),
Rate = table.Column<float>(type: "real", nullable: false),
IsConfirmed = table.Column<bool>(type: "boolean", nullable: false),
IsAdmin = table.Column<bool>(type: "boolean", nullable: false),
IsRoot = table.Column<bool>(type: "boolean", nullable: false),
ParentId = table.Column<Guid>(type: "uuid", nullable: true),
UserId = table.Column<Guid>(type: "uuid", nullable: false),
Discriminator = table.Column<string>(type: "character varying(21)", maxLength: 21, nullable: false),
BlogId = table.Column<Guid>(type: "uuid", nullable: true),
IsBuyer = table.Column<bool>(type: "boolean", nullable: true),
ProductId = table.Column<Guid>(type: "uuid", nullable: true),
RemovedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedBy = table.Column<string>(type: "text", nullable: false),
IsRemoved = table.Column<bool>(type: "boolean", nullable: false),
RemovedBy = table.Column<string>(type: "text", nullable: false),
ModifiedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
ModifiedBy = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Comments", x => x.Id);
table.ForeignKey(
name: "FK_Comments_Blogs_BlogId",
column: x => x.BlogId,
principalSchema: "public",
principalTable: "Blogs",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_Comments_Comments_ParentId",
column: x => x.ParentId,
principalSchema: "public",
principalTable: "Comments",
principalColumn: "Id");
table.ForeignKey(
name: "FK_Comments_Products_ProductId",
column: x => x.ProductId,
principalSchema: "public",
principalTable: "Products",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_Comments_Users_UserId",
column: x => x.UserId,
principalSchema: "public",
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateIndex(
name: "IX_Comments_BlogId",
schema: "public",
table: "Comments",
column: "BlogId");
migrationBuilder.CreateIndex(
name: "IX_Comments_ParentId",
schema: "public",
table: "Comments",
column: "ParentId");
migrationBuilder.CreateIndex(
name: "IX_Comments_ProductId",
schema: "public",
table: "Comments",
column: "ProductId");
migrationBuilder.CreateIndex(
name: "IX_Comments_UserId",
schema: "public",
table: "Comments",
column: "UserId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Comments",
schema: "public");
migrationBuilder.CreateTable(
name: "Reviews",
schema: "public",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
ProductId = table.Column<Guid>(type: "uuid", nullable: false),
UserId = table.Column<Guid>(type: "uuid", nullable: false),
Comment = table.Column<string>(type: "text", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
CreatedBy = table.Column<string>(type: "text", nullable: false),
IsAdmin = table.Column<bool>(type: "boolean", nullable: false),
IsBuyer = table.Column<bool>(type: "boolean", nullable: false),
IsConfirmed = table.Column<bool>(type: "boolean", nullable: false),
IsRemoved = table.Column<bool>(type: "boolean", nullable: false),
ModifiedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
ModifiedBy = table.Column<string>(type: "text", nullable: false),
Rate = table.Column<float>(type: "real", nullable: false),
RemovedAt = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
RemovedBy = table.Column<string>(type: "text", nullable: false),
Title = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Reviews", x => x.Id);
table.ForeignKey(
name: "FK_Reviews_Products_ProductId",
column: x => x.ProductId,
principalSchema: "public",
principalTable: "Products",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_Reviews_Users_UserId",
column: x => x.UserId,
principalSchema: "public",
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateIndex(
name: "IX_Reviews_ProductId",
schema: "public",
table: "Reviews",
column: "ProductId");
migrationBuilder.CreateIndex(
name: "IX_Reviews_UserId",
schema: "public",
table: "Reviews",
column: "UserId");
}
}
}

View File

@ -18,7 +18,7 @@ namespace NetinaShop.Repository.Migrations
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("public")
.HasAnnotation("ProductVersion", "8.0.7")
.HasAnnotation("ProductVersion", "8.0.8")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.HasPostgresExtension(modelBuilder, "fuzzystrmatch");
@ -386,6 +386,80 @@ namespace NetinaShop.Repository.Migrations
b.ToTable("Brands", "public");
});
modelBuilder.Entity("Netina.Domain.Entities.Comments.Comment", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Content")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Discriminator")
.IsRequired()
.HasMaxLength(21)
.HasColumnType("character varying(21)");
b.Property<bool>("IsAdmin")
.HasColumnType("boolean");
b.Property<bool>("IsConfirmed")
.HasColumnType("boolean");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
b.Property<bool>("IsRoot")
.HasColumnType("boolean");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid?>("ParentId")
.HasColumnType("uuid");
b.Property<float>("Rate")
.HasColumnType("real");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("ParentId");
b.HasIndex("UserId");
b.ToTable("Comments", "public");
b.HasDiscriminator().HasValue("Comment");
b.UseTphMappingStrategy();
});
modelBuilder.Entity("Netina.Domain.Entities.Discounts.Discount", b =>
{
b.Property<Guid>("Id")
@ -958,71 +1032,6 @@ namespace NetinaShop.Repository.Migrations
b.ToTable("Specifications", "public");
});
modelBuilder.Entity("Netina.Domain.Entities.Reviews.Review", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Comment")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("CreatedBy")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsAdmin")
.HasColumnType("boolean");
b.Property<bool>("IsBuyer")
.HasColumnType("boolean");
b.Property<bool>("IsConfirmed")
.HasColumnType("boolean");
b.Property<bool>("IsRemoved")
.HasColumnType("boolean");
b.Property<DateTime>("ModifiedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("ModifiedBy")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("ProductId")
.HasColumnType("uuid");
b.Property<float>("Rate")
.HasColumnType("real");
b.Property<DateTime>("RemovedAt")
.HasColumnType("timestamp without time zone");
b.Property<string>("RemovedBy")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("UserId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("ProductId");
b.HasIndex("UserId");
b.ToTable("Reviews", "public");
});
modelBuilder.Entity("Netina.Domain.Entities.StorageFiles.StorageFile", b =>
{
b.Property<Guid>("Id")
@ -1574,6 +1583,33 @@ namespace NetinaShop.Repository.Migrations
b.ToTable("Shippings", "public");
});
modelBuilder.Entity("Netina.Domain.Entities.Blogs.BlogComment", b =>
{
b.HasBaseType("Netina.Domain.Entities.Comments.Comment");
b.Property<Guid>("BlogId")
.HasColumnType("uuid");
b.HasIndex("BlogId");
b.HasDiscriminator().HasValue("BlogComment");
});
modelBuilder.Entity("Netina.Domain.Entities.Products.ProductComment", b =>
{
b.HasBaseType("Netina.Domain.Entities.Comments.Comment");
b.Property<bool>("IsBuyer")
.HasColumnType("boolean");
b.Property<Guid>("ProductId")
.HasColumnType("uuid");
b.HasIndex("ProductId");
b.HasDiscriminator().HasValue("ProductComment");
});
modelBuilder.Entity("Netina.Domain.Entities.Discounts.CategoryDiscount", b =>
{
b.HasBaseType("Netina.Domain.Entities.Discounts.Discount");
@ -1734,6 +1770,22 @@ namespace NetinaShop.Repository.Migrations
b.Navigation("Parent");
});
modelBuilder.Entity("Netina.Domain.Entities.Comments.Comment", b =>
{
b.HasOne("Netina.Domain.Entities.Comments.Comment", "Parent")
.WithMany("Children")
.HasForeignKey("ParentId");
b.HasOne("Netina.Domain.Entities.Users.ApplicationUser", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("Parent");
b.Navigation("User");
});
modelBuilder.Entity("Netina.Domain.Entities.Discounts.Discount", b =>
{
b.HasOne("Netina.Domain.Entities.Users.Marketer", "Marketer")
@ -1847,23 +1899,6 @@ namespace NetinaShop.Repository.Migrations
b.Navigation("Product");
});
modelBuilder.Entity("Netina.Domain.Entities.Reviews.Review", b =>
{
b.HasOne("Netina.Domain.Entities.Products.Product", "Product")
.WithMany("Reviews")
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("Netina.Domain.Entities.Users.ApplicationUser", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("Product");
b.Navigation("User");
});
modelBuilder.Entity("Netina.Domain.Entities.Users.Customer", b =>
{
b.HasOne("Netina.Domain.Entities.Users.ApplicationUser", "User")
@ -1921,6 +1956,26 @@ namespace NetinaShop.Repository.Migrations
b.Navigation("User");
});
modelBuilder.Entity("Netina.Domain.Entities.Blogs.BlogComment", b =>
{
b.HasOne("Netina.Domain.Entities.Blogs.Blog", "Blog")
.WithMany()
.HasForeignKey("BlogId")
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("Blog");
});
modelBuilder.Entity("Netina.Domain.Entities.Products.ProductComment", b =>
{
b.HasOne("Netina.Domain.Entities.Products.Product", "Product")
.WithMany("Comments")
.HasForeignKey("ProductId")
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("Product");
});
modelBuilder.Entity("Netina.Domain.Entities.Discounts.CategoryDiscount", b =>
{
b.HasOne("Netina.Domain.Entities.ProductCategories.ProductCategory", "Category")
@ -1998,6 +2053,11 @@ namespace NetinaShop.Repository.Migrations
b.Navigation("Products");
});
modelBuilder.Entity("Netina.Domain.Entities.Comments.Comment", b =>
{
b.Navigation("Children");
});
modelBuilder.Entity("Netina.Domain.Entities.Discounts.Discount", b =>
{
b.Navigation("Orders");
@ -2021,12 +2081,12 @@ namespace NetinaShop.Repository.Migrations
modelBuilder.Entity("Netina.Domain.Entities.Products.Product", b =>
{
b.Navigation("Comments");
b.Navigation("Files");
b.Navigation("OrderProducts");
b.Navigation("Reviews");
b.Navigation("Specifications");
});