naming
This commit is contained in:
@@ -14,7 +14,7 @@ namespace Webshop.Infrastructure.Data
|
||||
|
||||
public DbSet<Product> Products { get; set; } = default!;
|
||||
public DbSet<ProductVariant> ProductVariants { get; set; } = default!;
|
||||
public DbSet<Category> Categories { get; set; } = default!;
|
||||
public DbSet<Category> categorys { get; set; } = default!;
|
||||
public DbSet<Customer> Customers { get; set; } = default!;
|
||||
public DbSet<Address> Addresses { get; set; } = default!;
|
||||
public DbSet<Order> Orders { get; set; } = default!;
|
||||
@@ -26,7 +26,7 @@ namespace Webshop.Infrastructure.Data
|
||||
public DbSet<PaymentMethod> PaymentMethods { get; set; } = default!;
|
||||
public DbSet<Setting> Settings { get; set; } = default!;
|
||||
|
||||
public DbSet<ProductCategory> ProductCategories { get; set; } = default!;
|
||||
public DbSet<ProductCategory> Productcategorys { get; set; } = default!;
|
||||
public DbSet<ProductDiscount> ProductDiscounts { get; set; } = default!;
|
||||
public DbSet<CategoryDiscount> CategoryDiscounts { get; set; } = default!;
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace Webshop.Infrastructure.Data
|
||||
|
||||
modelBuilder.Entity<Category>()
|
||||
.HasOne(c => c.ParentCategory)
|
||||
.WithMany(c => c.SubCategories)
|
||||
.WithMany(c => c.Subcategorys)
|
||||
.HasForeignKey(c => c.ParentCategoryId)
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
|
||||
|
||||
@@ -264,7 +264,7 @@ namespace Webshop.Infrastructure.Migrations
|
||||
b.HasIndex("Slug")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Categories");
|
||||
b.ToTable("categorys");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Webshop.Domain.Entities.CategoryDiscount", b =>
|
||||
@@ -667,7 +667,7 @@ namespace Webshop.Infrastructure.Migrations
|
||||
|
||||
b.HasIndex("CategoryId");
|
||||
|
||||
b.ToTable("ProductCategories");
|
||||
b.ToTable("Productcategorys");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Webshop.Domain.Entities.ProductDiscount", b =>
|
||||
@@ -1009,7 +1009,7 @@ namespace Webshop.Infrastructure.Migrations
|
||||
modelBuilder.Entity("Webshop.Domain.Entities.Category", b =>
|
||||
{
|
||||
b.HasOne("Webshop.Domain.Entities.Category", "ParentCategory")
|
||||
.WithMany("SubCategories")
|
||||
.WithMany("Subcategorys")
|
||||
.HasForeignKey("ParentCategoryId")
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
|
||||
@@ -1120,13 +1120,13 @@ namespace Webshop.Infrastructure.Migrations
|
||||
modelBuilder.Entity("Webshop.Domain.Entities.ProductCategory", b =>
|
||||
{
|
||||
b.HasOne("Webshop.Domain.Entities.Category", "Category")
|
||||
.WithMany("ProductCategories")
|
||||
.WithMany("Productcategorys")
|
||||
.HasForeignKey("CategoryId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Webshop.Domain.Entities.Product", "Product")
|
||||
.WithMany("ProductCategories")
|
||||
.WithMany("Productcategorys")
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
@@ -1196,9 +1196,9 @@ namespace Webshop.Infrastructure.Migrations
|
||||
{
|
||||
b.Navigation("CategoryDiscounts");
|
||||
|
||||
b.Navigation("ProductCategories");
|
||||
b.Navigation("Productcategorys");
|
||||
|
||||
b.Navigation("SubCategories");
|
||||
b.Navigation("Subcategorys");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Webshop.Domain.Entities.Customer", b =>
|
||||
@@ -1224,7 +1224,7 @@ namespace Webshop.Infrastructure.Migrations
|
||||
|
||||
modelBuilder.Entity("Webshop.Domain.Entities.Product", b =>
|
||||
{
|
||||
b.Navigation("ProductCategories");
|
||||
b.Navigation("Productcategorys");
|
||||
|
||||
b.Navigation("ProductDiscounts");
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Webshop.Infrastructure.Migrations
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Categories",
|
||||
name: "categorys",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
@@ -29,11 +29,11 @@ namespace Webshop.Infrastructure.Migrations
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Categories", x => x.Id);
|
||||
table.PrimaryKey("PK_categorys", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Categories_Categories_ParentCategoryId",
|
||||
name: "FK_categorys_categorys_ParentCategoryId",
|
||||
column: x => x.ParentCategoryId,
|
||||
principalTable: "Categories",
|
||||
principalTable: "categorys",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
@@ -164,9 +164,9 @@ namespace Webshop.Infrastructure.Migrations
|
||||
{
|
||||
table.PrimaryKey("PK_CategoryDiscounts", x => new { x.CategoryId, x.DiscountId });
|
||||
table.ForeignKey(
|
||||
name: "FK_CategoryDiscounts_Categories_CategoryId",
|
||||
name: "FK_CategoryDiscounts_categorys_CategoryId",
|
||||
column: x => x.CategoryId,
|
||||
principalTable: "Categories",
|
||||
principalTable: "categorys",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
@@ -450,7 +450,7 @@ namespace Webshop.Infrastructure.Migrations
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ProductCategories",
|
||||
name: "Productcategorys",
|
||||
columns: table => new
|
||||
{
|
||||
ProductId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
@@ -458,15 +458,15 @@ namespace Webshop.Infrastructure.Migrations
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ProductCategories", x => new { x.ProductId, x.CategoryId });
|
||||
table.PrimaryKey("PK_Productcategorys", x => new { x.ProductId, x.CategoryId });
|
||||
table.ForeignKey(
|
||||
name: "FK_ProductCategories_Categories_CategoryId",
|
||||
name: "FK_Productcategorys_categorys_CategoryId",
|
||||
column: x => x.CategoryId,
|
||||
principalTable: "Categories",
|
||||
principalTable: "categorys",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_ProductCategories_Products_ProductId",
|
||||
name: "FK_Productcategorys_Products_ProductId",
|
||||
column: x => x.ProductId,
|
||||
principalTable: "Products",
|
||||
principalColumn: "Id",
|
||||
@@ -594,13 +594,13 @@ namespace Webshop.Infrastructure.Migrations
|
||||
column: "CustomerId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Categories_ParentCategoryId",
|
||||
table: "Categories",
|
||||
name: "IX_categorys_ParentCategoryId",
|
||||
table: "categorys",
|
||||
column: "ParentCategoryId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Categories_Slug",
|
||||
table: "Categories",
|
||||
name: "IX_categorys_Slug",
|
||||
table: "categorys",
|
||||
column: "Slug",
|
||||
unique: true);
|
||||
|
||||
@@ -669,8 +669,8 @@ namespace Webshop.Infrastructure.Migrations
|
||||
column: "ShippingMethodId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ProductCategories_CategoryId",
|
||||
table: "ProductCategories",
|
||||
name: "IX_Productcategorys_CategoryId",
|
||||
table: "Productcategorys",
|
||||
column: "CategoryId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
@@ -769,7 +769,7 @@ namespace Webshop.Infrastructure.Migrations
|
||||
name: "OrderItems");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ProductCategories");
|
||||
name: "Productcategorys");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ProductDiscounts");
|
||||
@@ -802,7 +802,7 @@ namespace Webshop.Infrastructure.Migrations
|
||||
name: "ProductVariants");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Categories");
|
||||
name: "categorys");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Discounts");
|
||||
|
||||
@@ -261,7 +261,7 @@ namespace Webshop.Infrastructure.Migrations
|
||||
b.HasIndex("Slug")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Categories");
|
||||
b.ToTable("categorys");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Webshop.Domain.Entities.CategoryDiscount", b =>
|
||||
@@ -664,7 +664,7 @@ namespace Webshop.Infrastructure.Migrations
|
||||
|
||||
b.HasIndex("CategoryId");
|
||||
|
||||
b.ToTable("ProductCategories");
|
||||
b.ToTable("Productcategorys");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Webshop.Domain.Entities.ProductDiscount", b =>
|
||||
@@ -1006,7 +1006,7 @@ namespace Webshop.Infrastructure.Migrations
|
||||
modelBuilder.Entity("Webshop.Domain.Entities.Category", b =>
|
||||
{
|
||||
b.HasOne("Webshop.Domain.Entities.Category", "ParentCategory")
|
||||
.WithMany("SubCategories")
|
||||
.WithMany("Subcategorys")
|
||||
.HasForeignKey("ParentCategoryId")
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
|
||||
@@ -1117,13 +1117,13 @@ namespace Webshop.Infrastructure.Migrations
|
||||
modelBuilder.Entity("Webshop.Domain.Entities.ProductCategory", b =>
|
||||
{
|
||||
b.HasOne("Webshop.Domain.Entities.Category", "Category")
|
||||
.WithMany("ProductCategories")
|
||||
.WithMany("Productcategorys")
|
||||
.HasForeignKey("CategoryId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Webshop.Domain.Entities.Product", "Product")
|
||||
.WithMany("ProductCategories")
|
||||
.WithMany("Productcategorys")
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
@@ -1193,9 +1193,9 @@ namespace Webshop.Infrastructure.Migrations
|
||||
{
|
||||
b.Navigation("CategoryDiscounts");
|
||||
|
||||
b.Navigation("ProductCategories");
|
||||
b.Navigation("Productcategorys");
|
||||
|
||||
b.Navigation("SubCategories");
|
||||
b.Navigation("Subcategorys");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Webshop.Domain.Entities.Customer", b =>
|
||||
@@ -1221,7 +1221,7 @@ namespace Webshop.Infrastructure.Migrations
|
||||
|
||||
modelBuilder.Entity("Webshop.Domain.Entities.Product", b =>
|
||||
{
|
||||
b.Navigation("ProductCategories");
|
||||
b.Navigation("Productcategorys");
|
||||
|
||||
b.Navigation("ProductDiscounts");
|
||||
|
||||
|
||||
@@ -20,37 +20,37 @@ namespace Webshop.Infrastructure.Repositories
|
||||
|
||||
public async Task<IEnumerable<Category>> GetAllAsync()
|
||||
{
|
||||
return await _context.Categories.ToListAsync();
|
||||
return await _context.categorys.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<Category?> GetByIdAsync(Guid id)
|
||||
{
|
||||
return await _context.Categories.FindAsync(id);
|
||||
return await _context.categorys.FindAsync(id);
|
||||
}
|
||||
|
||||
public async Task<Category?> GetBySlugAsync(string slug)
|
||||
{
|
||||
return await _context.Categories.FirstOrDefaultAsync(c => c.Slug == slug);
|
||||
return await _context.categorys.FirstOrDefaultAsync(c => c.Slug == slug);
|
||||
}
|
||||
|
||||
public async Task AddAsync(Category category)
|
||||
{
|
||||
_context.Categories.Add(category);
|
||||
_context.categorys.Add(category);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task UpdateAsync(Category category)
|
||||
{
|
||||
_context.Categories.Update(category);
|
||||
_context.categorys.Update(category);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task DeleteAsync(Guid id)
|
||||
{
|
||||
var category = await _context.Categories.FindAsync(id);
|
||||
var category = await _context.categorys.FindAsync(id);
|
||||
if (category != null)
|
||||
{
|
||||
_context.Categories.Remove(category);
|
||||
_context.categorys.Remove(category);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user