naming
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
// src/Webshop.Api/Controllers/Admin/AdminCategoriesController.cs
|
// src/Webshop.Api/Controllers/Admin/AdmincategorysController.cs
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using System;
|
using System;
|
||||||
@@ -10,7 +10,7 @@ using Webshop.Application.Services.Admin;
|
|||||||
namespace Webshop.Api.Controllers.Admin
|
namespace Webshop.Api.Controllers.Admin
|
||||||
{
|
{
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("api/v1/admin/categories")]
|
[Route("api/v1/admin/categorys")]
|
||||||
[Authorize(Roles = "Admin")]
|
[Authorize(Roles = "Admin")]
|
||||||
public class AdminCategorysController : ControllerBase
|
public class AdminCategorysController : ControllerBase
|
||||||
{
|
{
|
||||||
@@ -22,10 +22,10 @@ namespace Webshop.Api.Controllers.Admin
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public async Task<ActionResult<IEnumerable<CategoryDto>>> GetAllCategories()
|
public async Task<ActionResult<IEnumerable<CategoryDto>>> GetAllcategorys()
|
||||||
{
|
{
|
||||||
var categories = await _adminCategoryService.GetAllAsync();
|
var categorys = await _adminCategoryService.GetAllAsync();
|
||||||
return Ok(categories);
|
return Ok(categorys);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("{id}")]
|
[HttpGet("{id}")]
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// src/Webshop.Api/Controllers/Public/CategoriesController.cs
|
// src/Webshop.Api/Controllers/Public/categorysController.cs
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -9,22 +9,22 @@ using Webshop.Application.Services.Public;
|
|||||||
namespace Webshop.Api.Controllers.Public
|
namespace Webshop.Api.Controllers.Public
|
||||||
{
|
{
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("api/v1/public/categories")]
|
[Route("api/v1/public/categorys")]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
public class CategorysController : ControllerBase
|
public class CategoryController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly ICategoryService _categoryService;
|
private readonly ICategoryService _categoryService;
|
||||||
|
|
||||||
public CategorysController(ICategoryService categoryService)
|
public CategoryController(ICategoryService categoryService)
|
||||||
{
|
{
|
||||||
_categoryService = categoryService;
|
_categoryService = categoryService;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public async Task<ActionResult<IEnumerable<CategoryDto>>> GetActiveCategories()
|
public async Task<ActionResult<IEnumerable<CategoryDto>>> GetActivecategorys()
|
||||||
{
|
{
|
||||||
var categories = await _categoryService.GetAllActiveAsync();
|
var categorys = await _categoryService.GetAllActiveAsync();
|
||||||
return Ok(categories);
|
return Ok(categorys);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("{slug}")]
|
[HttpGet("{slug}")]
|
||||||
@@ -115,7 +115,7 @@ namespace Webshop.Api.SwaggerFilters
|
|||||||
["stockQuantity"] = new OpenApiInteger(100),
|
["stockQuantity"] = new OpenApiInteger(100),
|
||||||
["imageUrl"] = new OpenApiString("https://example.com/images/public_prod.jpg"),
|
["imageUrl"] = new OpenApiString("https://example.com/images/public_prod.jpg"),
|
||||||
["slug"] = new OpenApiString($"public-produkt-beispiel-{uniqueId}"),
|
["slug"] = new OpenApiString($"public-produkt-beispiel-{uniqueId}"),
|
||||||
["categories"] = new OpenApiArray
|
["categorys"] = new OpenApiArray
|
||||||
{
|
{
|
||||||
new OpenApiObject
|
new OpenApiObject
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,6 +19,6 @@ namespace Webshop.Application.DTOs.Products
|
|||||||
public int StockQuantity { get; set; }
|
public int StockQuantity { get; set; }
|
||||||
public string? ImageUrl { get; set; }
|
public string? ImageUrl { get; set; }
|
||||||
public string Slug { get; set; } = string.Empty;
|
public string Slug { get; set; } = string.Empty;
|
||||||
public List<CategoryDto> Categories { get; set; } = new List<CategoryDto>();
|
public List<CategoryDto> categorys { get; set; } = new List<CategoryDto>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ namespace Webshop.Application.Services.Admin
|
|||||||
|
|
||||||
public async Task<IEnumerable<CategoryDto>> GetAllAsync()
|
public async Task<IEnumerable<CategoryDto>> GetAllAsync()
|
||||||
{
|
{
|
||||||
var categories = await _categoryRepository.GetAllAsync();
|
var categorys = await _categoryRepository.GetAllAsync();
|
||||||
return categories.Select(c => new CategoryDto
|
return categorys.Select(c => new CategoryDto
|
||||||
{
|
{
|
||||||
Id = c.Id,
|
Id = c.Id,
|
||||||
Name = c.Name,
|
Name = c.Name,
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace Webshop.Application.Services.Admin
|
|||||||
{
|
{
|
||||||
// Wir verwenden den DbContext, um auch die Kategorien effizient mitzuladen
|
// Wir verwenden den DbContext, um auch die Kategorien effizient mitzuladen
|
||||||
var products = await _context.Products
|
var products = await _context.Products
|
||||||
.Include(p => p.ProductCategories)
|
.Include(p => p.Productcategorys)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
return products.Select(p => new AdminProductDto
|
return products.Select(p => new AdminProductDto
|
||||||
@@ -48,14 +48,14 @@ namespace Webshop.Application.Services.Admin
|
|||||||
LastModifiedDate = p.LastModifiedDate,
|
LastModifiedDate = p.LastModifiedDate,
|
||||||
SupplierId = p.SupplierId,
|
SupplierId = p.SupplierId,
|
||||||
PurchasePrice = p.PurchasePrice,
|
PurchasePrice = p.PurchasePrice,
|
||||||
CategoryIds = p.ProductCategories.Select(pc => pc.CategoryId).ToList() // << NEU >>
|
CategoryIds = p.Productcategorys.Select(pc => pc.CategoryId).ToList() // << NEU >>
|
||||||
}).ToList();
|
}).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<AdminProductDto?> GetAdminProductByIdAsync(Guid id)
|
public async Task<AdminProductDto?> GetAdminProductByIdAsync(Guid id)
|
||||||
{
|
{
|
||||||
var product = await _context.Products
|
var product = await _context.Products
|
||||||
.Include(p => p.ProductCategories) // << NEU: Lade die Join-Tabelle mit >>
|
.Include(p => p.Productcategorys) // << NEU: Lade die Join-Tabelle mit >>
|
||||||
.FirstOrDefaultAsync(p => p.Id == id);
|
.FirstOrDefaultAsync(p => p.Id == id);
|
||||||
|
|
||||||
if (product == null) return null;
|
if (product == null) return null;
|
||||||
@@ -78,7 +78,7 @@ namespace Webshop.Application.Services.Admin
|
|||||||
LastModifiedDate = product.LastModifiedDate,
|
LastModifiedDate = product.LastModifiedDate,
|
||||||
SupplierId = product.SupplierId,
|
SupplierId = product.SupplierId,
|
||||||
PurchasePrice = product.PurchasePrice,
|
PurchasePrice = product.PurchasePrice,
|
||||||
CategoryIds = product.ProductCategories.Select(pc => pc.CategoryId).ToList() // << NEU: Mappe die CategoryIds >>
|
CategoryIds = product.Productcategorys.Select(pc => pc.CategoryId).ToList() // << NEU: Mappe die CategoryIds >>
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,13 +101,13 @@ namespace Webshop.Application.Services.Admin
|
|||||||
CreatedDate = DateTimeOffset.UtcNow,
|
CreatedDate = DateTimeOffset.UtcNow,
|
||||||
SupplierId = productDto.SupplierId,
|
SupplierId = productDto.SupplierId,
|
||||||
PurchasePrice = productDto.PurchasePrice,
|
PurchasePrice = productDto.PurchasePrice,
|
||||||
ProductCategories = new List<ProductCategory>() // Initialisiere die Collection
|
Productcategorys = new List<ProductCategory>() // Initialisiere die Collection
|
||||||
};
|
};
|
||||||
|
|
||||||
// << NEU: F<>ge die Kategorien hinzu >>
|
// << NEU: F<>ge die Kategorien hinzu >>
|
||||||
foreach (var categoryId in productDto.CategoryIds)
|
foreach (var categoryId in productDto.CategoryIds)
|
||||||
{
|
{
|
||||||
newProduct.ProductCategories.Add(new ProductCategory { CategoryId = categoryId });
|
newProduct.Productcategorys.Add(new ProductCategory { CategoryId = categoryId });
|
||||||
}
|
}
|
||||||
|
|
||||||
await _productRepository.AddProductAsync(newProduct); // << KORREKT: VERWENDET AddProductAsync >>
|
await _productRepository.AddProductAsync(newProduct); // << KORREKT: VERWENDET AddProductAsync >>
|
||||||
@@ -119,7 +119,7 @@ namespace Webshop.Application.Services.Admin
|
|||||||
public async Task<bool> UpdateAdminProductAsync(AdminProductDto productDto)
|
public async Task<bool> UpdateAdminProductAsync(AdminProductDto productDto)
|
||||||
{
|
{
|
||||||
var existingProduct = await _context.Products
|
var existingProduct = await _context.Products
|
||||||
.Include(p => p.ProductCategories) // Lade die aktuellen Zuweisungen
|
.Include(p => p.Productcategorys) // Lade die aktuellen Zuweisungen
|
||||||
.FirstOrDefaultAsync(p => p.Id == productDto.Id);
|
.FirstOrDefaultAsync(p => p.Id == productDto.Id);
|
||||||
|
|
||||||
if (existingProduct == null) return false;
|
if (existingProduct == null) return false;
|
||||||
@@ -141,10 +141,10 @@ namespace Webshop.Application.Services.Admin
|
|||||||
existingProduct.LastModifiedDate = DateTimeOffset.UtcNow;
|
existingProduct.LastModifiedDate = DateTimeOffset.UtcNow;
|
||||||
|
|
||||||
// << NEU: Kategorien synchronisieren (alte l<>schen, neue hinzuf<75>gen) >>
|
// << NEU: Kategorien synchronisieren (alte l<>schen, neue hinzuf<75>gen) >>
|
||||||
existingProduct.ProductCategories.Clear();
|
existingProduct.Productcategorys.Clear();
|
||||||
foreach (var categoryId in productDto.CategoryIds)
|
foreach (var categoryId in productDto.CategoryIds)
|
||||||
{
|
{
|
||||||
existingProduct.ProductCategories.Add(new ProductCategory { ProductId = existingProduct.Id, CategoryId = categoryId });
|
existingProduct.Productcategorys.Add(new ProductCategory { ProductId = existingProduct.Id, CategoryId = categoryId });
|
||||||
}
|
}
|
||||||
// << ENDE NEUER TEIL >>
|
// << ENDE NEUER TEIL >>
|
||||||
|
|
||||||
|
|||||||
@@ -18,10 +18,10 @@ namespace Webshop.Application.Services.Public
|
|||||||
|
|
||||||
public async Task<IEnumerable<CategoryDto>> GetAllActiveAsync()
|
public async Task<IEnumerable<CategoryDto>> GetAllActiveAsync()
|
||||||
{
|
{
|
||||||
var categories = await _categoryRepository.GetAllAsync();
|
var categorys = await _categoryRepository.GetAllAsync();
|
||||||
|
|
||||||
// Hier könnte man eine Baumstruktur aufbauen, für den Anfang eine flache Liste
|
// Hier könnte man eine Baumstruktur aufbauen, für den Anfang eine flache Liste
|
||||||
return categories
|
return categorys
|
||||||
.Where(c => c.IsActive)
|
.Where(c => c.IsActive)
|
||||||
.Select(c => new CategoryDto
|
.Select(c => new CategoryDto
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace Webshop.Application.Services.Public
|
|||||||
{
|
{
|
||||||
// Wir verwenden den DbContext, um Produkte und ihre Kategorien zu laden
|
// Wir verwenden den DbContext, um Produkte und ihre Kategorien zu laden
|
||||||
var products = await _context.Products
|
var products = await _context.Products
|
||||||
.Include(p => p.ProductCategories) // Lade die Join-Tabelle
|
.Include(p => p.Productcategorys) // Lade die Join-Tabelle
|
||||||
.ThenInclude(pc => pc.Category) // Lade die zugehörige Kategorie-Entität
|
.ThenInclude(pc => pc.Category) // Lade die zugehörige Kategorie-Entität
|
||||||
.Where(p => p.IsActive) // Nur aktive Produkte
|
.Where(p => p.IsActive) // Nur aktive Produkte
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
@@ -41,7 +41,7 @@ namespace Webshop.Application.Services.Public
|
|||||||
ImageUrl = p.ImageUrl,
|
ImageUrl = p.ImageUrl,
|
||||||
IsInStock = p.IsInStock,
|
IsInStock = p.IsInStock,
|
||||||
Slug = p.Slug,
|
Slug = p.Slug,
|
||||||
Categories = p.ProductCategories.Select(pc => new CategoryDto
|
categorys = p.Productcategorys.Select(pc => new CategoryDto
|
||||||
{
|
{
|
||||||
Id = pc.Category.Id,
|
Id = pc.Category.Id,
|
||||||
Name = pc.Category.Name,
|
Name = pc.Category.Name,
|
||||||
@@ -54,7 +54,7 @@ namespace Webshop.Application.Services.Public
|
|||||||
public async Task<ProductDto?> GetProductBySlugAsync(string slug)
|
public async Task<ProductDto?> GetProductBySlugAsync(string slug)
|
||||||
{
|
{
|
||||||
var product = await _context.Products
|
var product = await _context.Products
|
||||||
.Include(p => p.ProductCategories)
|
.Include(p => p.Productcategorys)
|
||||||
.ThenInclude(pc => pc.Category)
|
.ThenInclude(pc => pc.Category)
|
||||||
.FirstOrDefaultAsync(p => p.Slug == slug && p.IsActive); // Nur aktives Produkt finden
|
.FirstOrDefaultAsync(p => p.Slug == slug && p.IsActive); // Nur aktives Produkt finden
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ namespace Webshop.Application.Services.Public
|
|||||||
ImageUrl = product.ImageUrl,
|
ImageUrl = product.ImageUrl,
|
||||||
IsInStock = product.IsInStock,
|
IsInStock = product.IsInStock,
|
||||||
Slug = product.Slug,
|
Slug = product.Slug,
|
||||||
Categories = product.ProductCategories.Select(pc => new CategoryDto
|
categorys = product.Productcategorys.Select(pc => new CategoryDto
|
||||||
{
|
{
|
||||||
Id = pc.Category.Id,
|
Id = pc.Category.Id,
|
||||||
Name = pc.Category.Name,
|
Name = pc.Category.Name,
|
||||||
|
|||||||
@@ -44,8 +44,8 @@ namespace Webshop.Domain.Entities
|
|||||||
|
|
||||||
// Navigation Properties
|
// Navigation Properties
|
||||||
public virtual Category? ParentCategory { get; set; }
|
public virtual Category? ParentCategory { get; set; }
|
||||||
public virtual ICollection<Category> SubCategories { get; set; } = new List<Category>();
|
public virtual ICollection<Category> Subcategorys { get; set; } = new List<Category>();
|
||||||
public virtual ICollection<ProductCategory> ProductCategories { get; set; } = new List<ProductCategory>();
|
public virtual ICollection<ProductCategory> Productcategorys { get; set; } = new List<ProductCategory>();
|
||||||
public virtual ICollection<CategoryDiscount> CategoryDiscounts { get; set; } = new List<CategoryDiscount>();
|
public virtual ICollection<CategoryDiscount> CategoryDiscounts { get; set; } = new List<CategoryDiscount>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -67,5 +67,5 @@ public class Product
|
|||||||
public virtual ICollection<ProductVariant> Variants { get; set; } = new List<ProductVariant>();
|
public virtual ICollection<ProductVariant> Variants { get; set; } = new List<ProductVariant>();
|
||||||
public virtual ICollection<Review> Reviews { get; set; } = new List<Review>();
|
public virtual ICollection<Review> Reviews { get; set; } = new List<Review>();
|
||||||
public virtual ICollection<ProductDiscount> ProductDiscounts { get; set; } = new List<ProductDiscount>();
|
public virtual ICollection<ProductDiscount> ProductDiscounts { get; set; } = new List<ProductDiscount>();
|
||||||
public virtual ICollection<ProductCategory> ProductCategories { get; set; } = new List<ProductCategory>();
|
public virtual ICollection<ProductCategory> Productcategorys { get; set; } = new List<ProductCategory>();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ namespace Webshop.Infrastructure.Data
|
|||||||
|
|
||||||
public DbSet<Product> Products { get; set; } = default!;
|
public DbSet<Product> Products { get; set; } = default!;
|
||||||
public DbSet<ProductVariant> ProductVariants { 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<Customer> Customers { get; set; } = default!;
|
||||||
public DbSet<Address> Addresses { get; set; } = default!;
|
public DbSet<Address> Addresses { get; set; } = default!;
|
||||||
public DbSet<Order> Orders { 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<PaymentMethod> PaymentMethods { get; set; } = default!;
|
||||||
public DbSet<Setting> Settings { 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<ProductDiscount> ProductDiscounts { get; set; } = default!;
|
||||||
public DbSet<CategoryDiscount> CategoryDiscounts { get; set; } = default!;
|
public DbSet<CategoryDiscount> CategoryDiscounts { get; set; } = default!;
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@ namespace Webshop.Infrastructure.Data
|
|||||||
|
|
||||||
modelBuilder.Entity<Category>()
|
modelBuilder.Entity<Category>()
|
||||||
.HasOne(c => c.ParentCategory)
|
.HasOne(c => c.ParentCategory)
|
||||||
.WithMany(c => c.SubCategories)
|
.WithMany(c => c.Subcategorys)
|
||||||
.HasForeignKey(c => c.ParentCategoryId)
|
.HasForeignKey(c => c.ParentCategoryId)
|
||||||
.OnDelete(DeleteBehavior.Restrict);
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
|
|
||||||
|
|||||||
@@ -264,7 +264,7 @@ namespace Webshop.Infrastructure.Migrations
|
|||||||
b.HasIndex("Slug")
|
b.HasIndex("Slug")
|
||||||
.IsUnique();
|
.IsUnique();
|
||||||
|
|
||||||
b.ToTable("Categories");
|
b.ToTable("categorys");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Webshop.Domain.Entities.CategoryDiscount", b =>
|
modelBuilder.Entity("Webshop.Domain.Entities.CategoryDiscount", b =>
|
||||||
@@ -667,7 +667,7 @@ namespace Webshop.Infrastructure.Migrations
|
|||||||
|
|
||||||
b.HasIndex("CategoryId");
|
b.HasIndex("CategoryId");
|
||||||
|
|
||||||
b.ToTable("ProductCategories");
|
b.ToTable("Productcategorys");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Webshop.Domain.Entities.ProductDiscount", b =>
|
modelBuilder.Entity("Webshop.Domain.Entities.ProductDiscount", b =>
|
||||||
@@ -1009,7 +1009,7 @@ namespace Webshop.Infrastructure.Migrations
|
|||||||
modelBuilder.Entity("Webshop.Domain.Entities.Category", b =>
|
modelBuilder.Entity("Webshop.Domain.Entities.Category", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("Webshop.Domain.Entities.Category", "ParentCategory")
|
b.HasOne("Webshop.Domain.Entities.Category", "ParentCategory")
|
||||||
.WithMany("SubCategories")
|
.WithMany("Subcategorys")
|
||||||
.HasForeignKey("ParentCategoryId")
|
.HasForeignKey("ParentCategoryId")
|
||||||
.OnDelete(DeleteBehavior.Restrict);
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
|
|
||||||
@@ -1120,13 +1120,13 @@ namespace Webshop.Infrastructure.Migrations
|
|||||||
modelBuilder.Entity("Webshop.Domain.Entities.ProductCategory", b =>
|
modelBuilder.Entity("Webshop.Domain.Entities.ProductCategory", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("Webshop.Domain.Entities.Category", "Category")
|
b.HasOne("Webshop.Domain.Entities.Category", "Category")
|
||||||
.WithMany("ProductCategories")
|
.WithMany("Productcategorys")
|
||||||
.HasForeignKey("CategoryId")
|
.HasForeignKey("CategoryId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.HasOne("Webshop.Domain.Entities.Product", "Product")
|
b.HasOne("Webshop.Domain.Entities.Product", "Product")
|
||||||
.WithMany("ProductCategories")
|
.WithMany("Productcategorys")
|
||||||
.HasForeignKey("ProductId")
|
.HasForeignKey("ProductId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
@@ -1196,9 +1196,9 @@ namespace Webshop.Infrastructure.Migrations
|
|||||||
{
|
{
|
||||||
b.Navigation("CategoryDiscounts");
|
b.Navigation("CategoryDiscounts");
|
||||||
|
|
||||||
b.Navigation("ProductCategories");
|
b.Navigation("Productcategorys");
|
||||||
|
|
||||||
b.Navigation("SubCategories");
|
b.Navigation("Subcategorys");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Webshop.Domain.Entities.Customer", b =>
|
modelBuilder.Entity("Webshop.Domain.Entities.Customer", b =>
|
||||||
@@ -1224,7 +1224,7 @@ namespace Webshop.Infrastructure.Migrations
|
|||||||
|
|
||||||
modelBuilder.Entity("Webshop.Domain.Entities.Product", b =>
|
modelBuilder.Entity("Webshop.Domain.Entities.Product", b =>
|
||||||
{
|
{
|
||||||
b.Navigation("ProductCategories");
|
b.Navigation("Productcategorys");
|
||||||
|
|
||||||
b.Navigation("ProductDiscounts");
|
b.Navigation("ProductDiscounts");
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace Webshop.Infrastructure.Migrations
|
|||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "Categories",
|
name: "categorys",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
@@ -29,11 +29,11 @@ namespace Webshop.Infrastructure.Migrations
|
|||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
table.PrimaryKey("PK_Categories", x => x.Id);
|
table.PrimaryKey("PK_categorys", x => x.Id);
|
||||||
table.ForeignKey(
|
table.ForeignKey(
|
||||||
name: "FK_Categories_Categories_ParentCategoryId",
|
name: "FK_categorys_categorys_ParentCategoryId",
|
||||||
column: x => x.ParentCategoryId,
|
column: x => x.ParentCategoryId,
|
||||||
principalTable: "Categories",
|
principalTable: "categorys",
|
||||||
principalColumn: "Id",
|
principalColumn: "Id",
|
||||||
onDelete: ReferentialAction.Restrict);
|
onDelete: ReferentialAction.Restrict);
|
||||||
});
|
});
|
||||||
@@ -164,9 +164,9 @@ namespace Webshop.Infrastructure.Migrations
|
|||||||
{
|
{
|
||||||
table.PrimaryKey("PK_CategoryDiscounts", x => new { x.CategoryId, x.DiscountId });
|
table.PrimaryKey("PK_CategoryDiscounts", x => new { x.CategoryId, x.DiscountId });
|
||||||
table.ForeignKey(
|
table.ForeignKey(
|
||||||
name: "FK_CategoryDiscounts_Categories_CategoryId",
|
name: "FK_CategoryDiscounts_categorys_CategoryId",
|
||||||
column: x => x.CategoryId,
|
column: x => x.CategoryId,
|
||||||
principalTable: "Categories",
|
principalTable: "categorys",
|
||||||
principalColumn: "Id",
|
principalColumn: "Id",
|
||||||
onDelete: ReferentialAction.Cascade);
|
onDelete: ReferentialAction.Cascade);
|
||||||
table.ForeignKey(
|
table.ForeignKey(
|
||||||
@@ -450,7 +450,7 @@ namespace Webshop.Infrastructure.Migrations
|
|||||||
});
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "ProductCategories",
|
name: "Productcategorys",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
ProductId = table.Column<Guid>(type: "uuid", nullable: false),
|
ProductId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
@@ -458,15 +458,15 @@ namespace Webshop.Infrastructure.Migrations
|
|||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
table.PrimaryKey("PK_ProductCategories", x => new { x.ProductId, x.CategoryId });
|
table.PrimaryKey("PK_Productcategorys", x => new { x.ProductId, x.CategoryId });
|
||||||
table.ForeignKey(
|
table.ForeignKey(
|
||||||
name: "FK_ProductCategories_Categories_CategoryId",
|
name: "FK_Productcategorys_categorys_CategoryId",
|
||||||
column: x => x.CategoryId,
|
column: x => x.CategoryId,
|
||||||
principalTable: "Categories",
|
principalTable: "categorys",
|
||||||
principalColumn: "Id",
|
principalColumn: "Id",
|
||||||
onDelete: ReferentialAction.Cascade);
|
onDelete: ReferentialAction.Cascade);
|
||||||
table.ForeignKey(
|
table.ForeignKey(
|
||||||
name: "FK_ProductCategories_Products_ProductId",
|
name: "FK_Productcategorys_Products_ProductId",
|
||||||
column: x => x.ProductId,
|
column: x => x.ProductId,
|
||||||
principalTable: "Products",
|
principalTable: "Products",
|
||||||
principalColumn: "Id",
|
principalColumn: "Id",
|
||||||
@@ -594,13 +594,13 @@ namespace Webshop.Infrastructure.Migrations
|
|||||||
column: "CustomerId");
|
column: "CustomerId");
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
name: "IX_Categories_ParentCategoryId",
|
name: "IX_categorys_ParentCategoryId",
|
||||||
table: "Categories",
|
table: "categorys",
|
||||||
column: "ParentCategoryId");
|
column: "ParentCategoryId");
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
name: "IX_Categories_Slug",
|
name: "IX_categorys_Slug",
|
||||||
table: "Categories",
|
table: "categorys",
|
||||||
column: "Slug",
|
column: "Slug",
|
||||||
unique: true);
|
unique: true);
|
||||||
|
|
||||||
@@ -669,8 +669,8 @@ namespace Webshop.Infrastructure.Migrations
|
|||||||
column: "ShippingMethodId");
|
column: "ShippingMethodId");
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
name: "IX_ProductCategories_CategoryId",
|
name: "IX_Productcategorys_CategoryId",
|
||||||
table: "ProductCategories",
|
table: "Productcategorys",
|
||||||
column: "CategoryId");
|
column: "CategoryId");
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
@@ -769,7 +769,7 @@ namespace Webshop.Infrastructure.Migrations
|
|||||||
name: "OrderItems");
|
name: "OrderItems");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "ProductCategories");
|
name: "Productcategorys");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "ProductDiscounts");
|
name: "ProductDiscounts");
|
||||||
@@ -802,7 +802,7 @@ namespace Webshop.Infrastructure.Migrations
|
|||||||
name: "ProductVariants");
|
name: "ProductVariants");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "Categories");
|
name: "categorys");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "Discounts");
|
name: "Discounts");
|
||||||
|
|||||||
@@ -261,7 +261,7 @@ namespace Webshop.Infrastructure.Migrations
|
|||||||
b.HasIndex("Slug")
|
b.HasIndex("Slug")
|
||||||
.IsUnique();
|
.IsUnique();
|
||||||
|
|
||||||
b.ToTable("Categories");
|
b.ToTable("categorys");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Webshop.Domain.Entities.CategoryDiscount", b =>
|
modelBuilder.Entity("Webshop.Domain.Entities.CategoryDiscount", b =>
|
||||||
@@ -664,7 +664,7 @@ namespace Webshop.Infrastructure.Migrations
|
|||||||
|
|
||||||
b.HasIndex("CategoryId");
|
b.HasIndex("CategoryId");
|
||||||
|
|
||||||
b.ToTable("ProductCategories");
|
b.ToTable("Productcategorys");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Webshop.Domain.Entities.ProductDiscount", b =>
|
modelBuilder.Entity("Webshop.Domain.Entities.ProductDiscount", b =>
|
||||||
@@ -1006,7 +1006,7 @@ namespace Webshop.Infrastructure.Migrations
|
|||||||
modelBuilder.Entity("Webshop.Domain.Entities.Category", b =>
|
modelBuilder.Entity("Webshop.Domain.Entities.Category", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("Webshop.Domain.Entities.Category", "ParentCategory")
|
b.HasOne("Webshop.Domain.Entities.Category", "ParentCategory")
|
||||||
.WithMany("SubCategories")
|
.WithMany("Subcategorys")
|
||||||
.HasForeignKey("ParentCategoryId")
|
.HasForeignKey("ParentCategoryId")
|
||||||
.OnDelete(DeleteBehavior.Restrict);
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
|
|
||||||
@@ -1117,13 +1117,13 @@ namespace Webshop.Infrastructure.Migrations
|
|||||||
modelBuilder.Entity("Webshop.Domain.Entities.ProductCategory", b =>
|
modelBuilder.Entity("Webshop.Domain.Entities.ProductCategory", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("Webshop.Domain.Entities.Category", "Category")
|
b.HasOne("Webshop.Domain.Entities.Category", "Category")
|
||||||
.WithMany("ProductCategories")
|
.WithMany("Productcategorys")
|
||||||
.HasForeignKey("CategoryId")
|
.HasForeignKey("CategoryId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.HasOne("Webshop.Domain.Entities.Product", "Product")
|
b.HasOne("Webshop.Domain.Entities.Product", "Product")
|
||||||
.WithMany("ProductCategories")
|
.WithMany("Productcategorys")
|
||||||
.HasForeignKey("ProductId")
|
.HasForeignKey("ProductId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
@@ -1193,9 +1193,9 @@ namespace Webshop.Infrastructure.Migrations
|
|||||||
{
|
{
|
||||||
b.Navigation("CategoryDiscounts");
|
b.Navigation("CategoryDiscounts");
|
||||||
|
|
||||||
b.Navigation("ProductCategories");
|
b.Navigation("Productcategorys");
|
||||||
|
|
||||||
b.Navigation("SubCategories");
|
b.Navigation("Subcategorys");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Webshop.Domain.Entities.Customer", b =>
|
modelBuilder.Entity("Webshop.Domain.Entities.Customer", b =>
|
||||||
@@ -1221,7 +1221,7 @@ namespace Webshop.Infrastructure.Migrations
|
|||||||
|
|
||||||
modelBuilder.Entity("Webshop.Domain.Entities.Product", b =>
|
modelBuilder.Entity("Webshop.Domain.Entities.Product", b =>
|
||||||
{
|
{
|
||||||
b.Navigation("ProductCategories");
|
b.Navigation("Productcategorys");
|
||||||
|
|
||||||
b.Navigation("ProductDiscounts");
|
b.Navigation("ProductDiscounts");
|
||||||
|
|
||||||
|
|||||||
@@ -20,37 +20,37 @@ namespace Webshop.Infrastructure.Repositories
|
|||||||
|
|
||||||
public async Task<IEnumerable<Category>> GetAllAsync()
|
public async Task<IEnumerable<Category>> GetAllAsync()
|
||||||
{
|
{
|
||||||
return await _context.Categories.ToListAsync();
|
return await _context.categorys.ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Category?> GetByIdAsync(Guid id)
|
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)
|
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)
|
public async Task AddAsync(Category category)
|
||||||
{
|
{
|
||||||
_context.Categories.Add(category);
|
_context.categorys.Add(category);
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task UpdateAsync(Category category)
|
public async Task UpdateAsync(Category category)
|
||||||
{
|
{
|
||||||
_context.Categories.Update(category);
|
_context.categorys.Update(category);
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task DeleteAsync(Guid id)
|
public async Task DeleteAsync(Guid id)
|
||||||
{
|
{
|
||||||
var category = await _context.Categories.FindAsync(id);
|
var category = await _context.categorys.FindAsync(id);
|
||||||
if (category != null)
|
if (category != null)
|
||||||
{
|
{
|
||||||
_context.Categories.Remove(category);
|
_context.categorys.Remove(category);
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user