naming
This commit is contained in:
@@ -1,10 +1,10 @@
|
|||||||
// src/Webshop.Api/Controllers/Admin/AdmincategorysController.cs
|
// src/Webshop.Api/Controllers/Admin/AdmincategoriesController.cs
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Webshop.Application.DTOs.Categorys;
|
using Webshop.Application.DTOs.categories;
|
||||||
using Webshop.Application.Services.Admin;
|
using Webshop.Application.Services.Admin;
|
||||||
|
|
||||||
namespace Webshop.Api.Controllers.Admin
|
namespace Webshop.Api.Controllers.Admin
|
||||||
@@ -12,51 +12,51 @@ namespace Webshop.Api.Controllers.Admin
|
|||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("api/v1/admin/[controller]")]
|
[Route("api/v1/admin/[controller]")]
|
||||||
[Authorize(Roles = "Admin")]
|
[Authorize(Roles = "Admin")]
|
||||||
public class AdminCategorysController : ControllerBase
|
public class AdmincategoriesController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly IAdminCategoryService _adminCategoryService;
|
private readonly IAdminCategorieService _admincategorieservice;
|
||||||
|
|
||||||
public AdminCategorysController(IAdminCategoryService adminCategoryService)
|
public AdmincategoriesController(IAdminCategorieService admincategorieservice)
|
||||||
{
|
{
|
||||||
_adminCategoryService = adminCategoryService;
|
_admincategorieservice = admincategorieservice;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public async Task<ActionResult<IEnumerable<CategoryDto>>> GetAllcategorys()
|
public async Task<ActionResult<IEnumerable<categorieDto>>> GetAllcategories()
|
||||||
{
|
{
|
||||||
var categorys = await _adminCategoryService.GetAllAsync();
|
var categories = await _admincategorieservice.GetAllAsync();
|
||||||
return Ok(categorys);
|
return Ok(categories);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("{id}")]
|
[HttpGet("{id}")]
|
||||||
public async Task<ActionResult<CategoryDto>> GetCategoryById(Guid id)
|
public async Task<ActionResult<categorieDto>> GetcategorieById(Guid id)
|
||||||
{
|
{
|
||||||
var category = await _adminCategoryService.GetByIdAsync(id);
|
var categorie = await _admincategorieservice.GetByIdAsync(id);
|
||||||
if (category == null) return NotFound();
|
if (categorie == null) return NotFound();
|
||||||
return Ok(category);
|
return Ok(categorie);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<ActionResult<CategoryDto>> CreateCategory([FromBody] CreateCategoryDto categoryDto)
|
public async Task<ActionResult<categorieDto>> Createcategorie([FromBody] CreatecategorieDto categorieDto)
|
||||||
{
|
{
|
||||||
if (!ModelState.IsValid) return BadRequest(ModelState);
|
if (!ModelState.IsValid) return BadRequest(ModelState);
|
||||||
|
|
||||||
var (createdCategory, errorMessage) = await _adminCategoryService.CreateAsync(categoryDto);
|
var (createdcategorie, errorMessage) = await _admincategorieservice.CreateAsync(categorieDto);
|
||||||
|
|
||||||
if (createdCategory == null)
|
if (createdcategorie == null)
|
||||||
{
|
{
|
||||||
return BadRequest(new { Message = errorMessage });
|
return BadRequest(new { Message = errorMessage });
|
||||||
}
|
}
|
||||||
|
|
||||||
return CreatedAtAction(nameof(GetCategoryById), new { id = createdCategory.Id }, createdCategory);
|
return CreatedAtAction(nameof(GetcategorieById), new { id = createdcategorie.Id }, createdcategorie);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPut("{id}")]
|
[HttpPut("{id}")]
|
||||||
public async Task<IActionResult> UpdateCategory(Guid id, [FromBody] CreateCategoryDto categoryDto)
|
public async Task<IActionResult> Updatecategorie(Guid id, [FromBody] CreatecategorieDto categorieDto)
|
||||||
{
|
{
|
||||||
if (!ModelState.IsValid) return BadRequest(ModelState);
|
if (!ModelState.IsValid) return BadRequest(ModelState);
|
||||||
|
|
||||||
var (success, errorMessage) = await _adminCategoryService.UpdateAsync(id, categoryDto);
|
var (success, errorMessage) = await _admincategorieservice.UpdateAsync(id, categorieDto);
|
||||||
|
|
||||||
if (!success)
|
if (!success)
|
||||||
{
|
{
|
||||||
@@ -67,9 +67,9 @@ namespace Webshop.Api.Controllers.Admin
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpDelete("{id}")]
|
[HttpDelete("{id}")]
|
||||||
public async Task<IActionResult> DeleteCategory(Guid id)
|
public async Task<IActionResult> Deletecategorie(Guid id)
|
||||||
{
|
{
|
||||||
var success = await _adminCategoryService.DeleteAsync(id);
|
var success = await _admincategorieservice.DeleteAsync(id);
|
||||||
if (!success) return NotFound();
|
if (!success) return NotFound();
|
||||||
return NoContent();
|
return NoContent();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
// src/Webshop.Api/Controllers/Public/categorysController.cs
|
// src/Webshop.Api/Controllers/Public/categoriesController.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;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Webshop.Application.DTOs.Categorys;
|
using Webshop.Application.DTOs.categories;
|
||||||
using Webshop.Application.Services.Public;
|
using Webshop.Application.Services.Public;
|
||||||
|
|
||||||
namespace Webshop.Api.Controllers.Public
|
namespace Webshop.Api.Controllers.Public
|
||||||
@@ -11,28 +11,28 @@ namespace Webshop.Api.Controllers.Public
|
|||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("api/v1/public/[controller]")]
|
[Route("api/v1/public/[controller]")]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
public class CategoryController : ControllerBase
|
public class categorieController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly ICategoryService _categoryService;
|
private readonly ICategorieService _categorieservice;
|
||||||
|
|
||||||
public CategoryController(ICategoryService categoryService)
|
public categorieController(ICategorieService categorieservice)
|
||||||
{
|
{
|
||||||
_categoryService = categoryService;
|
_categorieservice = categorieservice;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public async Task<ActionResult<IEnumerable<CategoryDto>>> GetActivecategorys()
|
public async Task<ActionResult<IEnumerable<categorieDto>>> GetActivecategories()
|
||||||
{
|
{
|
||||||
var categorys = await _categoryService.GetAllActiveAsync();
|
var categories = await _categorieservice.GetAllActiveAsync();
|
||||||
return Ok(categorys);
|
return Ok(categories);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("{slug}")]
|
[HttpGet("{slug}")]
|
||||||
public async Task<ActionResult<CategoryDto>> GetCategoryBySlug(string slug)
|
public async Task<ActionResult<categorieDto>> GetcategorieBySlug(string slug)
|
||||||
{
|
{
|
||||||
var category = await _categoryService.GetBySlugAsync(slug);
|
var categorie = await _categorieservice.GetBySlugAsync(slug);
|
||||||
if (category == null) return NotFound();
|
if (categorie == null) return NotFound();
|
||||||
return Ok(category);
|
return Ok(categorie);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -79,7 +79,7 @@ builder.Services.AddScoped<IProductRepository, ProductRepository>();
|
|||||||
builder.Services.AddScoped<ISupplierRepository, SupplierRepository>();
|
builder.Services.AddScoped<ISupplierRepository, SupplierRepository>();
|
||||||
builder.Services.AddScoped<ICustomerRepository, CustomerRepository>();
|
builder.Services.AddScoped<ICustomerRepository, CustomerRepository>();
|
||||||
builder.Services.AddScoped<IPaymentMethodRepository, PaymentMethodRepository>();
|
builder.Services.AddScoped<IPaymentMethodRepository, PaymentMethodRepository>();
|
||||||
builder.Services.AddScoped<ICategoryRepository, CategoryRepository>();
|
builder.Services.AddScoped<IcategorieRepository, categorieRepository>();
|
||||||
builder.Services.AddScoped<IOrderRepository, OrderRepository>();
|
builder.Services.AddScoped<IOrderRepository, OrderRepository>();
|
||||||
builder.Services.AddScoped<IShippingMethodRepository, ShippingMethodRepository>();
|
builder.Services.AddScoped<IShippingMethodRepository, ShippingMethodRepository>();
|
||||||
builder.Services.AddScoped<IAddressRepository, AddressRepository>();
|
builder.Services.AddScoped<IAddressRepository, AddressRepository>();
|
||||||
@@ -91,12 +91,12 @@ builder.Services.AddScoped<ISettingRepository, SettingRepository>();
|
|||||||
builder.Services.AddScoped<IAuthService, AuthService>();
|
builder.Services.AddScoped<IAuthService, AuthService>();
|
||||||
builder.Services.AddScoped<IProductService, ProductService>();
|
builder.Services.AddScoped<IProductService, ProductService>();
|
||||||
builder.Services.AddScoped<IPaymentMethodService, PaymentMethodService>();
|
builder.Services.AddScoped<IPaymentMethodService, PaymentMethodService>();
|
||||||
builder.Services.AddScoped<ICategoryService, CategoryService>();
|
builder.Services.AddScoped<ICategorieService, CategorieService>();
|
||||||
builder.Services.AddScoped<IAdminUserService, AdminUserService>();
|
builder.Services.AddScoped<IAdminUserService, AdminUserService>();
|
||||||
builder.Services.AddScoped<IAdminProductService, AdminProductService>();
|
builder.Services.AddScoped<IAdminProductService, AdminProductService>();
|
||||||
builder.Services.AddScoped<IAdminSupplierService, AdminSupplierService>();
|
builder.Services.AddScoped<IAdminSupplierService, AdminSupplierService>();
|
||||||
builder.Services.AddScoped<IAdminPaymentMethodService, AdminPaymentMethodService>();
|
builder.Services.AddScoped<IAdminPaymentMethodService, AdminPaymentMethodService>();
|
||||||
builder.Services.AddScoped<IAdminCategoryService, AdminCategoryService>();
|
builder.Services.AddScoped<IAdminCategorieService, AdminCategorieService>();
|
||||||
builder.Services.AddScoped<IAdminOrderService, AdminOrderService>();
|
builder.Services.AddScoped<IAdminOrderService, AdminOrderService>();
|
||||||
builder.Services.AddScoped<IAdminShippingMethodService, AdminShippingMethodService>();
|
builder.Services.AddScoped<IAdminShippingMethodService, AdminShippingMethodService>();
|
||||||
builder.Services.AddScoped<IAdminDiscountService, AdminDiscountService>();
|
builder.Services.AddScoped<IAdminDiscountService, AdminDiscountService>();
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Webshop.Application.DTOs;
|
using Webshop.Application.DTOs;
|
||||||
using Webshop.Application.DTOs.Auth;
|
using Webshop.Application.DTOs.Auth;
|
||||||
using Webshop.Application.DTOs.Categorys;
|
using Webshop.Application.DTOs.categories;
|
||||||
using Webshop.Application.DTOs.Customers;
|
using Webshop.Application.DTOs.Customers;
|
||||||
using Webshop.Application.DTOs.Discounts;
|
using Webshop.Application.DTOs.Discounts;
|
||||||
using Webshop.Application.DTOs.Email;
|
using Webshop.Application.DTOs.Email;
|
||||||
@@ -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}"),
|
||||||
["categorys"] = new OpenApiArray
|
["categories"] = new OpenApiArray
|
||||||
{
|
{
|
||||||
new OpenApiObject
|
new OpenApiObject
|
||||||
{
|
{
|
||||||
@@ -146,19 +146,19 @@ namespace Webshop.Api.SwaggerFilters
|
|||||||
["lastModifiedDate"] = new OpenApiNull(),
|
["lastModifiedDate"] = new OpenApiNull(),
|
||||||
["supplierId"] = new OpenApiNull(),
|
["supplierId"] = new OpenApiNull(),
|
||||||
["purchasePrice"] = new OpenApiDouble(80.00),
|
["purchasePrice"] = new OpenApiDouble(80.00),
|
||||||
["categoryIds"] = new OpenApiArray { new OpenApiString("EXISTING_CATEGORY_ID_HERE") }
|
["categorieIds"] = new OpenApiArray { new OpenApiString("EXISTING_categorie_ID_HERE") }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// --- Kategorien ---
|
// --- Kategorien ---
|
||||||
else if (type == typeof(CreateCategoryDto))
|
else if (type == typeof(CreatecategorieDto))
|
||||||
{
|
{
|
||||||
schema.Example = new OpenApiObject
|
schema.Example = new OpenApiObject
|
||||||
{
|
{
|
||||||
["name"] = new OpenApiString($"Neue Kategorie {uniqueId}"),
|
["name"] = new OpenApiString($"Neue Kategorie {uniqueId}"),
|
||||||
["slug"] = new OpenApiString($"neue-kategorie-{uniqueId}"),
|
["slug"] = new OpenApiString($"neue-kategorie-{uniqueId}"),
|
||||||
["description"] = new OpenApiString("Eine Beschreibung für die neue Kategorie."),
|
["description"] = new OpenApiString("Eine Beschreibung für die neue Kategorie."),
|
||||||
["parentCategoryId"] = new OpenApiNull(),
|
["parentcategorieId"] = new OpenApiNull(),
|
||||||
["imageUrl"] = new OpenApiString("https://example.com/images/new_category.jpg"),
|
["imageUrl"] = new OpenApiString("https://example.com/images/new_categorie.jpg"),
|
||||||
["isActive"] = new OpenApiBoolean(true),
|
["isActive"] = new OpenApiBoolean(true),
|
||||||
["displayOrder"] = new OpenApiInteger(1)
|
["displayOrder"] = new OpenApiInteger(1)
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,15 +4,15 @@ using System.Collections.Generic;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
|
||||||
namespace Webshop.Application.DTOs.Categorys
|
namespace Webshop.Application.DTOs.categories
|
||||||
{
|
{
|
||||||
public class CategoryDto
|
public class categorieDto
|
||||||
{
|
{
|
||||||
public Guid Id { get; set; }
|
public Guid Id { get; set; }
|
||||||
public string Name { get; set; } = string.Empty;
|
public string Name { get; set; } = string.Empty;
|
||||||
public string Slug { get; set; } = string.Empty;
|
public string Slug { get; set; } = string.Empty;
|
||||||
public string Description { get; set; } = string.Empty;
|
public string Description { get; set; } = string.Empty;
|
||||||
public Guid? ParentCategoryId { get; set; }
|
public Guid? ParentcategorieId { get; set; }
|
||||||
public string? ImageUrl { get; set; }
|
public string? ImageUrl { get; set; }
|
||||||
public bool IsActive { get; set; }
|
public bool IsActive { get; set; }
|
||||||
public int DisplayOrder { get; set; }
|
public int DisplayOrder { get; set; }
|
||||||
@@ -4,14 +4,14 @@ using System.Collections.Generic;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
|
||||||
namespace Webshop.Application.DTOs.Categorys
|
namespace Webshop.Application.DTOs.categories
|
||||||
{
|
{
|
||||||
public class CreateCategoryDto
|
public class CreatecategorieDto
|
||||||
{
|
{
|
||||||
public string Name { get; set; } = string.Empty;
|
public string Name { get; set; } = string.Empty;
|
||||||
public string Slug { get; set; } = string.Empty;
|
public string Slug { get; set; } = string.Empty;
|
||||||
public string Description { get; set; } = string.Empty;
|
public string Description { get; set; } = string.Empty;
|
||||||
public Guid? ParentCategoryId { get; set; }
|
public Guid? ParentcategorieId { get; set; }
|
||||||
public string? ImageUrl { get; set; }
|
public string? ImageUrl { get; set; }
|
||||||
public bool IsActive { get; set; } = true;
|
public bool IsActive { get; set; } = true;
|
||||||
public int DisplayOrder { get; set; } = 0;
|
public int DisplayOrder { get; set; } = 0;
|
||||||
@@ -24,6 +24,6 @@ namespace Webshop.Application.DTOs.Products
|
|||||||
public DateTimeOffset? LastModifiedDate { get; set; }
|
public DateTimeOffset? LastModifiedDate { get; set; }
|
||||||
public Guid? SupplierId { get; set; }
|
public Guid? SupplierId { get; set; }
|
||||||
public decimal? PurchasePrice { get; set; }
|
public decimal? PurchasePrice { get; set; }
|
||||||
public List<Guid> CategoryIds { get; set; } = new List<Guid>();
|
public List<Guid> categorieIds { get; set; } = new List<Guid>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Webshop.Application.DTOs.Categorys;
|
using Webshop.Application.DTOs.categories;
|
||||||
|
|
||||||
|
|
||||||
namespace Webshop.Application.DTOs.Products
|
namespace Webshop.Application.DTOs.Products
|
||||||
@@ -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> categorys { get; set; } = new List<CategoryDto>();
|
public List<categorieDto> categories { get; set; } = new List<categorieDto>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
129
Webshop.Application/Services/Admin/AdminCategorieService.cs
Normal file
129
Webshop.Application/Services/Admin/AdminCategorieService.cs
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
// src/Webshop.Application/Services/Admin/Admincategorieservice.cs
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Webshop.Application.DTOs.categories;
|
||||||
|
using Webshop.Domain.Entities;
|
||||||
|
using Webshop.Domain.Interfaces;
|
||||||
|
|
||||||
|
namespace Webshop.Application.Services.Admin
|
||||||
|
{
|
||||||
|
public class AdminCategorieService : IAdminCategorieService
|
||||||
|
{
|
||||||
|
private readonly IcategorieRepository _categorieRepository;
|
||||||
|
|
||||||
|
public AdminCategorieService(IcategorieRepository categorieRepository)
|
||||||
|
{
|
||||||
|
_categorieRepository = categorieRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<categorieDto>> GetAllAsync()
|
||||||
|
{
|
||||||
|
var categories = await _categorieRepository.GetAllAsync();
|
||||||
|
return categories.Select(c => new categorieDto
|
||||||
|
{
|
||||||
|
Id = c.Id,
|
||||||
|
Name = c.Name,
|
||||||
|
Slug = c.Slug,
|
||||||
|
Description = c.Description,
|
||||||
|
ParentcategorieId = c.ParentcategorieId,
|
||||||
|
ImageUrl = c.ImageUrl,
|
||||||
|
IsActive = c.IsActive,
|
||||||
|
DisplayOrder = c.DisplayOrder
|
||||||
|
}).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<categorieDto?> GetByIdAsync(Guid id)
|
||||||
|
{
|
||||||
|
var categorie = await _categorieRepository.GetByIdAsync(id);
|
||||||
|
if (categorie == null) return null;
|
||||||
|
|
||||||
|
return new categorieDto
|
||||||
|
{
|
||||||
|
Id = categorie.Id,
|
||||||
|
Name = categorie.Name,
|
||||||
|
Slug = categorie.Slug,
|
||||||
|
Description = categorie.Description,
|
||||||
|
ParentcategorieId = categorie.ParentcategorieId,
|
||||||
|
ImageUrl = categorie.ImageUrl,
|
||||||
|
IsActive = categorie.IsActive,
|
||||||
|
DisplayOrder = categorie.DisplayOrder
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<(categorieDto? Createdcategorie, string? ErrorMessage)> CreateAsync(CreatecategorieDto categorieDto)
|
||||||
|
{
|
||||||
|
var existingcategorie = await _categorieRepository.GetBySlugAsync(categorieDto.Slug);
|
||||||
|
if (existingcategorie != null)
|
||||||
|
{
|
||||||
|
return (null, "Eine Kategorie mit diesem Slug existiert bereits.");
|
||||||
|
}
|
||||||
|
|
||||||
|
var categorie = new categorie
|
||||||
|
{
|
||||||
|
Id = Guid.NewGuid(),
|
||||||
|
Name = categorieDto.Name,
|
||||||
|
Slug = categorieDto.Slug,
|
||||||
|
Description = categorieDto.Description,
|
||||||
|
ParentcategorieId = categorieDto.ParentcategorieId,
|
||||||
|
ImageUrl = categorieDto.ImageUrl,
|
||||||
|
IsActive = categorieDto.IsActive,
|
||||||
|
DisplayOrder = categorieDto.DisplayOrder,
|
||||||
|
CreatedDate = DateTimeOffset.UtcNow
|
||||||
|
};
|
||||||
|
|
||||||
|
await _categorieRepository.AddAsync(categorie);
|
||||||
|
|
||||||
|
var createdDto = new categorieDto
|
||||||
|
{
|
||||||
|
Id = categorie.Id,
|
||||||
|
Name = categorie.Name,
|
||||||
|
Slug = categorie.Slug,
|
||||||
|
Description = categorie.Description,
|
||||||
|
ParentcategorieId = categorie.ParentcategorieId,
|
||||||
|
ImageUrl = categorie.ImageUrl,
|
||||||
|
IsActive = categorie.IsActive,
|
||||||
|
DisplayOrder = categorie.DisplayOrder
|
||||||
|
};
|
||||||
|
|
||||||
|
return (createdDto, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<(bool Success, string? ErrorMessage)> UpdateAsync(Guid id, CreatecategorieDto categorieDto)
|
||||||
|
{
|
||||||
|
var existingcategorie = await _categorieRepository.GetByIdAsync(id);
|
||||||
|
if (existingcategorie == null)
|
||||||
|
{
|
||||||
|
return (false, "Kategorie nicht gefunden.");
|
||||||
|
}
|
||||||
|
|
||||||
|
var categorieWithSameSlug = await _categorieRepository.GetBySlugAsync(categorieDto.Slug);
|
||||||
|
if (categorieWithSameSlug != null && categorieWithSameSlug.Id != id)
|
||||||
|
{
|
||||||
|
return (false, "Eine andere Kategorie mit diesem Slug existiert bereits.");
|
||||||
|
}
|
||||||
|
|
||||||
|
existingcategorie.Name = categorieDto.Name;
|
||||||
|
existingcategorie.Slug = categorieDto.Slug;
|
||||||
|
existingcategorie.Description = categorieDto.Description;
|
||||||
|
existingcategorie.ParentcategorieId = categorieDto.ParentcategorieId;
|
||||||
|
existingcategorie.ImageUrl = categorieDto.ImageUrl;
|
||||||
|
existingcategorie.IsActive = categorieDto.IsActive;
|
||||||
|
existingcategorie.DisplayOrder = categorieDto.DisplayOrder;
|
||||||
|
existingcategorie.LastModifiedDate = DateTimeOffset.UtcNow;
|
||||||
|
|
||||||
|
await _categorieRepository.UpdateAsync(existingcategorie);
|
||||||
|
return (true, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<bool> DeleteAsync(Guid id)
|
||||||
|
{
|
||||||
|
var categorie = await _categorieRepository.GetByIdAsync(id);
|
||||||
|
if (categorie == null) return false;
|
||||||
|
|
||||||
|
await _categorieRepository.DeleteAsync(id);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,129 +0,0 @@
|
|||||||
// src/Webshop.Application/Services/Admin/AdminCategoryService.cs
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Webshop.Application.DTOs.Categorys;
|
|
||||||
using Webshop.Domain.Entities;
|
|
||||||
using Webshop.Domain.Interfaces;
|
|
||||||
|
|
||||||
namespace Webshop.Application.Services.Admin
|
|
||||||
{
|
|
||||||
public class AdminCategoryService : IAdminCategoryService
|
|
||||||
{
|
|
||||||
private readonly ICategoryRepository _categoryRepository;
|
|
||||||
|
|
||||||
public AdminCategoryService(ICategoryRepository categoryRepository)
|
|
||||||
{
|
|
||||||
_categoryRepository = categoryRepository;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<IEnumerable<CategoryDto>> GetAllAsync()
|
|
||||||
{
|
|
||||||
var categorys = await _categoryRepository.GetAllAsync();
|
|
||||||
return categorys.Select(c => new CategoryDto
|
|
||||||
{
|
|
||||||
Id = c.Id,
|
|
||||||
Name = c.Name,
|
|
||||||
Slug = c.Slug,
|
|
||||||
Description = c.Description,
|
|
||||||
ParentCategoryId = c.ParentCategoryId,
|
|
||||||
ImageUrl = c.ImageUrl,
|
|
||||||
IsActive = c.IsActive,
|
|
||||||
DisplayOrder = c.DisplayOrder
|
|
||||||
}).ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<CategoryDto?> GetByIdAsync(Guid id)
|
|
||||||
{
|
|
||||||
var category = await _categoryRepository.GetByIdAsync(id);
|
|
||||||
if (category == null) return null;
|
|
||||||
|
|
||||||
return new CategoryDto
|
|
||||||
{
|
|
||||||
Id = category.Id,
|
|
||||||
Name = category.Name,
|
|
||||||
Slug = category.Slug,
|
|
||||||
Description = category.Description,
|
|
||||||
ParentCategoryId = category.ParentCategoryId,
|
|
||||||
ImageUrl = category.ImageUrl,
|
|
||||||
IsActive = category.IsActive,
|
|
||||||
DisplayOrder = category.DisplayOrder
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<(CategoryDto? CreatedCategory, string? ErrorMessage)> CreateAsync(CreateCategoryDto categoryDto)
|
|
||||||
{
|
|
||||||
var existingCategory = await _categoryRepository.GetBySlugAsync(categoryDto.Slug);
|
|
||||||
if (existingCategory != null)
|
|
||||||
{
|
|
||||||
return (null, "Eine Kategorie mit diesem Slug existiert bereits.");
|
|
||||||
}
|
|
||||||
|
|
||||||
var category = new Category
|
|
||||||
{
|
|
||||||
Id = Guid.NewGuid(),
|
|
||||||
Name = categoryDto.Name,
|
|
||||||
Slug = categoryDto.Slug,
|
|
||||||
Description = categoryDto.Description,
|
|
||||||
ParentCategoryId = categoryDto.ParentCategoryId,
|
|
||||||
ImageUrl = categoryDto.ImageUrl,
|
|
||||||
IsActive = categoryDto.IsActive,
|
|
||||||
DisplayOrder = categoryDto.DisplayOrder,
|
|
||||||
CreatedDate = DateTimeOffset.UtcNow
|
|
||||||
};
|
|
||||||
|
|
||||||
await _categoryRepository.AddAsync(category);
|
|
||||||
|
|
||||||
var createdDto = new CategoryDto
|
|
||||||
{
|
|
||||||
Id = category.Id,
|
|
||||||
Name = category.Name,
|
|
||||||
Slug = category.Slug,
|
|
||||||
Description = category.Description,
|
|
||||||
ParentCategoryId = category.ParentCategoryId,
|
|
||||||
ImageUrl = category.ImageUrl,
|
|
||||||
IsActive = category.IsActive,
|
|
||||||
DisplayOrder = category.DisplayOrder
|
|
||||||
};
|
|
||||||
|
|
||||||
return (createdDto, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<(bool Success, string? ErrorMessage)> UpdateAsync(Guid id, CreateCategoryDto categoryDto)
|
|
||||||
{
|
|
||||||
var existingCategory = await _categoryRepository.GetByIdAsync(id);
|
|
||||||
if (existingCategory == null)
|
|
||||||
{
|
|
||||||
return (false, "Kategorie nicht gefunden.");
|
|
||||||
}
|
|
||||||
|
|
||||||
var categoryWithSameSlug = await _categoryRepository.GetBySlugAsync(categoryDto.Slug);
|
|
||||||
if (categoryWithSameSlug != null && categoryWithSameSlug.Id != id)
|
|
||||||
{
|
|
||||||
return (false, "Eine andere Kategorie mit diesem Slug existiert bereits.");
|
|
||||||
}
|
|
||||||
|
|
||||||
existingCategory.Name = categoryDto.Name;
|
|
||||||
existingCategory.Slug = categoryDto.Slug;
|
|
||||||
existingCategory.Description = categoryDto.Description;
|
|
||||||
existingCategory.ParentCategoryId = categoryDto.ParentCategoryId;
|
|
||||||
existingCategory.ImageUrl = categoryDto.ImageUrl;
|
|
||||||
existingCategory.IsActive = categoryDto.IsActive;
|
|
||||||
existingCategory.DisplayOrder = categoryDto.DisplayOrder;
|
|
||||||
existingCategory.LastModifiedDate = DateTimeOffset.UtcNow;
|
|
||||||
|
|
||||||
await _categoryRepository.UpdateAsync(existingCategory);
|
|
||||||
return (true, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<bool> DeleteAsync(Guid id)
|
|
||||||
{
|
|
||||||
var category = await _categoryRepository.GetByIdAsync(id);
|
|
||||||
if (category == null) return false;
|
|
||||||
|
|
||||||
await _categoryRepository.DeleteAsync(id);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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.Productcategorys)
|
.Include(p => p.Productcategories)
|
||||||
.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.Productcategorys.Select(pc => pc.CategoryId).ToList() // << NEU >>
|
categorieIds = p.Productcategories.Select(pc => pc.categorieId).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.Productcategorys) // << NEU: Lade die Join-Tabelle mit >>
|
.Include(p => p.Productcategories) // << 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.Productcategorys.Select(pc => pc.CategoryId).ToList() // << NEU: Mappe die CategoryIds >>
|
categorieIds = product.Productcategories.Select(pc => pc.categorieId).ToList() // << NEU: Mappe die categorieIds >>
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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,
|
||||||
Productcategorys = new List<ProductCategory>() // Initialisiere die Collection
|
Productcategories = new List<Productcategorie>() // Initialisiere die Collection
|
||||||
};
|
};
|
||||||
|
|
||||||
// << NEU: F<>ge die Kategorien hinzu >>
|
// << NEU: F<>ge die Kategorien hinzu >>
|
||||||
foreach (var categoryId in productDto.CategoryIds)
|
foreach (var categorieId in productDto.categorieIds)
|
||||||
{
|
{
|
||||||
newProduct.Productcategorys.Add(new ProductCategory { CategoryId = categoryId });
|
newProduct.Productcategories.Add(new Productcategorie { categorieId = categorieId });
|
||||||
}
|
}
|
||||||
|
|
||||||
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.Productcategorys) // Lade die aktuellen Zuweisungen
|
.Include(p => p.Productcategories) // 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.Productcategorys.Clear();
|
existingProduct.Productcategories.Clear();
|
||||||
foreach (var categoryId in productDto.CategoryIds)
|
foreach (var categorieId in productDto.categorieIds)
|
||||||
{
|
{
|
||||||
existingProduct.Productcategorys.Add(new ProductCategory { ProductId = existingProduct.Id, CategoryId = categoryId });
|
existingProduct.Productcategories.Add(new Productcategorie { ProductId = existingProduct.Id, categorieId = categorieId });
|
||||||
}
|
}
|
||||||
// << ENDE NEUER TEIL >>
|
// << ENDE NEUER TEIL >>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
// src/Webshop.Application/Services/Admin/IAdmincategorieservice.cs
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Webshop.Application.DTOs.categories;
|
||||||
|
|
||||||
|
namespace Webshop.Application.Services.Admin
|
||||||
|
{
|
||||||
|
public interface IAdminCategorieService
|
||||||
|
{
|
||||||
|
Task<IEnumerable<categorieDto>> GetAllAsync();
|
||||||
|
Task<categorieDto?> GetByIdAsync(Guid id);
|
||||||
|
Task<(categorieDto? Createdcategorie, string? ErrorMessage)> CreateAsync(CreatecategorieDto categorieDto);
|
||||||
|
Task<(bool Success, string? ErrorMessage)> UpdateAsync(Guid id, CreatecategorieDto categorieDto);
|
||||||
|
Task<bool> DeleteAsync(Guid id);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
// src/Webshop.Application/Services/Admin/IAdminCategoryService.cs
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Webshop.Application.DTOs.Categorys;
|
|
||||||
|
|
||||||
namespace Webshop.Application.Services.Admin
|
|
||||||
{
|
|
||||||
public interface IAdminCategoryService
|
|
||||||
{
|
|
||||||
Task<IEnumerable<CategoryDto>> GetAllAsync();
|
|
||||||
Task<CategoryDto?> GetByIdAsync(Guid id);
|
|
||||||
Task<(CategoryDto? CreatedCategory, string? ErrorMessage)> CreateAsync(CreateCategoryDto categoryDto);
|
|
||||||
Task<(bool Success, string? ErrorMessage)> UpdateAsync(Guid id, CreateCategoryDto categoryDto);
|
|
||||||
Task<bool> DeleteAsync(Guid id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
57
Webshop.Application/Services/Public/CategorieService.cs
Normal file
57
Webshop.Application/Services/Public/CategorieService.cs
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
// src/Webshop.Application/Services/Public/categorieservice.cs
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Webshop.Application.DTOs.categories;
|
||||||
|
using Webshop.Domain.Interfaces;
|
||||||
|
|
||||||
|
namespace Webshop.Application.Services.Public
|
||||||
|
{
|
||||||
|
public class CategorieService : ICategorieService
|
||||||
|
{
|
||||||
|
private readonly IcategorieRepository _categorieRepository;
|
||||||
|
|
||||||
|
public CategorieService(IcategorieRepository categorieRepository)
|
||||||
|
{
|
||||||
|
_categorieRepository = categorieRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<categorieDto>> GetAllActiveAsync()
|
||||||
|
{
|
||||||
|
var categories = await _categorieRepository.GetAllAsync();
|
||||||
|
|
||||||
|
// Hier könnte man eine Baumstruktur aufbauen, für den Anfang eine flache Liste
|
||||||
|
return categories
|
||||||
|
.Where(c => c.IsActive)
|
||||||
|
.Select(c => new categorieDto
|
||||||
|
{
|
||||||
|
Id = c.Id,
|
||||||
|
Name = c.Name,
|
||||||
|
Slug = c.Slug,
|
||||||
|
Description = c.Description,
|
||||||
|
ParentcategorieId = c.ParentcategorieId,
|
||||||
|
ImageUrl = c.ImageUrl,
|
||||||
|
IsActive = c.IsActive,
|
||||||
|
DisplayOrder = c.DisplayOrder
|
||||||
|
}).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<categorieDto?> GetBySlugAsync(string slug)
|
||||||
|
{
|
||||||
|
var categorie = await _categorieRepository.GetBySlugAsync(slug);
|
||||||
|
if (categorie == null || !categorie.IsActive) return null;
|
||||||
|
|
||||||
|
return new categorieDto
|
||||||
|
{
|
||||||
|
Id = categorie.Id,
|
||||||
|
Name = categorie.Name,
|
||||||
|
Slug = categorie.Slug,
|
||||||
|
Description = categorie.Description,
|
||||||
|
ParentcategorieId = categorie.ParentcategorieId,
|
||||||
|
ImageUrl = categorie.ImageUrl,
|
||||||
|
IsActive = categorie.IsActive,
|
||||||
|
DisplayOrder = categorie.DisplayOrder
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
// src/Webshop.Application/Services/Public/CategoryService.cs
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Webshop.Application.DTOs.Categorys;
|
|
||||||
using Webshop.Domain.Interfaces;
|
|
||||||
|
|
||||||
namespace Webshop.Application.Services.Public
|
|
||||||
{
|
|
||||||
public class CategoryService : ICategoryService
|
|
||||||
{
|
|
||||||
private readonly ICategoryRepository _categoryRepository;
|
|
||||||
|
|
||||||
public CategoryService(ICategoryRepository categoryRepository)
|
|
||||||
{
|
|
||||||
_categoryRepository = categoryRepository;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<IEnumerable<CategoryDto>> GetAllActiveAsync()
|
|
||||||
{
|
|
||||||
var categorys = await _categoryRepository.GetAllAsync();
|
|
||||||
|
|
||||||
// Hier könnte man eine Baumstruktur aufbauen, für den Anfang eine flache Liste
|
|
||||||
return categorys
|
|
||||||
.Where(c => c.IsActive)
|
|
||||||
.Select(c => new CategoryDto
|
|
||||||
{
|
|
||||||
Id = c.Id,
|
|
||||||
Name = c.Name,
|
|
||||||
Slug = c.Slug,
|
|
||||||
Description = c.Description,
|
|
||||||
ParentCategoryId = c.ParentCategoryId,
|
|
||||||
ImageUrl = c.ImageUrl,
|
|
||||||
IsActive = c.IsActive,
|
|
||||||
DisplayOrder = c.DisplayOrder
|
|
||||||
}).ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<CategoryDto?> GetBySlugAsync(string slug)
|
|
||||||
{
|
|
||||||
var category = await _categoryRepository.GetBySlugAsync(slug);
|
|
||||||
if (category == null || !category.IsActive) return null;
|
|
||||||
|
|
||||||
return new CategoryDto
|
|
||||||
{
|
|
||||||
Id = category.Id,
|
|
||||||
Name = category.Name,
|
|
||||||
Slug = category.Slug,
|
|
||||||
Description = category.Description,
|
|
||||||
ParentCategoryId = category.ParentCategoryId,
|
|
||||||
ImageUrl = category.ImageUrl,
|
|
||||||
IsActive = category.IsActive,
|
|
||||||
DisplayOrder = category.DisplayOrder
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
// src/Webshop.Application/Services/Public/Icategorieservice.cs
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Webshop.Application.DTOs.categories;
|
||||||
|
|
||||||
|
namespace Webshop.Application.Services.Public
|
||||||
|
{
|
||||||
|
public interface ICategorieService
|
||||||
|
{
|
||||||
|
Task<IEnumerable<categorieDto>> GetAllActiveAsync();
|
||||||
|
Task<categorieDto?> GetBySlugAsync(string slug);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
// src/Webshop.Application/Services/Public/ICategoryService.cs
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Webshop.Application.DTOs.Categorys;
|
|
||||||
|
|
||||||
namespace Webshop.Application.Services.Public
|
|
||||||
{
|
|
||||||
public interface ICategoryService
|
|
||||||
{
|
|
||||||
Task<IEnumerable<CategoryDto>> GetAllActiveAsync();
|
|
||||||
Task<CategoryDto?> GetBySlugAsync(string slug);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,7 +3,7 @@ using Microsoft.EntityFrameworkCore; // << NEU: Für Include() und ThenInclude()
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Webshop.Application.DTOs.Categorys; // Für CategoryDto
|
using Webshop.Application.DTOs.categories; // Für categorieDto
|
||||||
using Webshop.Application.DTOs.Products; // Für ProductDto
|
using Webshop.Application.DTOs.Products; // Für ProductDto
|
||||||
using Webshop.Application.Services.Public.Interfaces; // Für IProductService
|
using Webshop.Application.Services.Public.Interfaces; // Für IProductService
|
||||||
using Webshop.Domain.Interfaces; // Für IProductRepository
|
using Webshop.Domain.Interfaces; // Für IProductRepository
|
||||||
@@ -26,8 +26,8 @@ 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.Productcategorys) // Lade die Join-Tabelle
|
.Include(p => p.Productcategories) // Lade die Join-Tabelle
|
||||||
.ThenInclude(pc => pc.Category) // Lade die zugehörige Kategorie-Entität
|
.ThenInclude(pc => pc.categorie) // Lade die zugehörige Kategorie-Entität
|
||||||
.Where(p => p.IsActive) // Nur aktive Produkte
|
.Where(p => p.IsActive) // Nur aktive Produkte
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
@@ -41,12 +41,12 @@ namespace Webshop.Application.Services.Public
|
|||||||
ImageUrl = p.ImageUrl,
|
ImageUrl = p.ImageUrl,
|
||||||
IsInStock = p.IsInStock,
|
IsInStock = p.IsInStock,
|
||||||
Slug = p.Slug,
|
Slug = p.Slug,
|
||||||
categorys = p.Productcategorys.Select(pc => new CategoryDto
|
categories = p.Productcategories.Select(pc => new categorieDto
|
||||||
{
|
{
|
||||||
Id = pc.Category.Id,
|
Id = pc.categorie.Id,
|
||||||
Name = pc.Category.Name,
|
Name = pc.categorie.Name,
|
||||||
Slug = pc.Category.Slug
|
Slug = pc.categorie.Slug
|
||||||
// ... weitere CategoryDto-Felder bei Bedarf
|
// ... weitere categorieDto-Felder bei Bedarf
|
||||||
}).ToList()
|
}).ToList()
|
||||||
}).ToList();
|
}).ToList();
|
||||||
}
|
}
|
||||||
@@ -54,8 +54,8 @@ 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.Productcategorys)
|
.Include(p => p.Productcategories)
|
||||||
.ThenInclude(pc => pc.Category)
|
.ThenInclude(pc => pc.categorie)
|
||||||
.FirstOrDefaultAsync(p => p.Slug == slug && p.IsActive); // Nur aktives Produkt finden
|
.FirstOrDefaultAsync(p => p.Slug == slug && p.IsActive); // Nur aktives Produkt finden
|
||||||
|
|
||||||
if (product == null)
|
if (product == null)
|
||||||
@@ -73,11 +73,11 @@ namespace Webshop.Application.Services.Public
|
|||||||
ImageUrl = product.ImageUrl,
|
ImageUrl = product.ImageUrl,
|
||||||
IsInStock = product.IsInStock,
|
IsInStock = product.IsInStock,
|
||||||
Slug = product.Slug,
|
Slug = product.Slug,
|
||||||
categorys = product.Productcategorys.Select(pc => new CategoryDto
|
categories = product.Productcategories.Select(pc => new categorieDto
|
||||||
{
|
{
|
||||||
Id = pc.Category.Id,
|
Id = pc.categorie.Id,
|
||||||
Name = pc.Category.Name,
|
Name = pc.categorie.Name,
|
||||||
Slug = pc.Category.Slug
|
Slug = pc.categorie.Slug
|
||||||
}).ToList()
|
}).ToList()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// src/Webshop.Domain/Entities/Category.cs
|
// src/Webshop.Domain/Entities/categorie.cs
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
@@ -9,7 +9,7 @@ namespace Webshop.Domain.Entities
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Zum Gruppieren und Organisieren von Produkten.
|
/// Zum Gruppieren und Organisieren von Produkten.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Category
|
public class categorie
|
||||||
{
|
{
|
||||||
[Key]
|
[Key]
|
||||||
public Guid Id { get; set; } = Guid.NewGuid(); // Hinzufügen von Default-Wert
|
public Guid Id { get; set; } = Guid.NewGuid(); // Hinzufügen von Default-Wert
|
||||||
@@ -25,8 +25,8 @@ namespace Webshop.Domain.Entities
|
|||||||
[MaxLength(255)]
|
[MaxLength(255)]
|
||||||
public string Slug { get; set; } = string.Empty; // Hinzufügen von Default-Wert
|
public string Slug { get; set; } = string.Empty; // Hinzufügen von Default-Wert
|
||||||
|
|
||||||
[ForeignKey(nameof(ParentCategory))]
|
[ForeignKey(nameof(Parentcategorie))]
|
||||||
public Guid? ParentCategoryId { get; set; }
|
public Guid? ParentcategorieId { get; set; }
|
||||||
|
|
||||||
[MaxLength(2000)]
|
[MaxLength(2000)]
|
||||||
public string? ImageUrl { get; set; }
|
public string? ImageUrl { get; set; }
|
||||||
@@ -43,9 +43,9 @@ namespace Webshop.Domain.Entities
|
|||||||
// << ENDE NEUE EIGENSCHAFTEN >>
|
// << ENDE NEUE EIGENSCHAFTEN >>
|
||||||
|
|
||||||
// Navigation Properties
|
// Navigation Properties
|
||||||
public virtual Category? ParentCategory { get; set; }
|
public virtual categorie? Parentcategorie { get; set; }
|
||||||
public virtual ICollection<Category> Subcategorys { get; set; } = new List<Category>();
|
public virtual ICollection<categorie> Subcategories { get; set; } = new List<categorie>();
|
||||||
public virtual ICollection<ProductCategory> Productcategorys { get; set; } = new List<ProductCategory>();
|
public virtual ICollection<Productcategorie> Productcategories { get; set; } = new List<Productcategorie>();
|
||||||
public virtual ICollection<CategoryDiscount> CategoryDiscounts { get; set; } = new List<CategoryDiscount>();
|
public virtual ICollection<categorieDiscount> categorieDiscounts { get; set; } = new List<categorieDiscount>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,19 +5,19 @@ using System.ComponentModel.DataAnnotations.Schema;
|
|||||||
namespace Webshop.Domain.Entities;
|
namespace Webshop.Domain.Entities;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Verknüpfungstabelle für die Viele-zu-Viele-Beziehung zwischen Category und Discount.
|
/// Verknüpfungstabelle für die Viele-zu-Viele-Beziehung zwischen categorie und Discount.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class CategoryDiscount
|
public class categorieDiscount
|
||||||
{
|
{
|
||||||
[Required]
|
[Required]
|
||||||
[ForeignKey(nameof(Category))]
|
[ForeignKey(nameof(categorie))]
|
||||||
public Guid CategoryId { get; set; }
|
public Guid categorieId { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
[ForeignKey(nameof(Discount))]
|
[ForeignKey(nameof(Discount))]
|
||||||
public Guid DiscountId { get; set; }
|
public Guid DiscountId { get; set; }
|
||||||
|
|
||||||
// Navigation Properties
|
// Navigation Properties
|
||||||
public virtual Category Category { get; set; }
|
public virtual categorie categorie { get; set; }
|
||||||
public virtual Discount Discount { get; set; }
|
public virtual Discount Discount { get; set; }
|
||||||
}
|
}
|
||||||
@@ -51,5 +51,5 @@ public class Discount
|
|||||||
|
|
||||||
// Navigation Properties
|
// Navigation Properties
|
||||||
public virtual ICollection<ProductDiscount> ProductDiscounts { get; set; } = new List<ProductDiscount>();
|
public virtual ICollection<ProductDiscount> ProductDiscounts { get; set; } = new List<ProductDiscount>();
|
||||||
public virtual ICollection<CategoryDiscount> CategoryDiscounts { get; set; } = new List<CategoryDiscount>();
|
public virtual ICollection<categorieDiscount> categorieDiscounts { get; set; } = new List<categorieDiscount>();
|
||||||
}
|
}
|
||||||
@@ -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> Productcategorys { get; set; } = new List<ProductCategory>();
|
public virtual ICollection<Productcategorie> Productcategories { get; set; } = new List<Productcategorie>();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,20 +5,20 @@ using System.ComponentModel.DataAnnotations.Schema;
|
|||||||
namespace Webshop.Domain.Entities;
|
namespace Webshop.Domain.Entities;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Verknüpfungstabelle für die Viele-zu-Viele-Beziehung zwischen Category und Discount.
|
/// Verknüpfungstabelle für die Viele-zu-Viele-Beziehung zwischen categorie und Discount.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ProductCategory
|
public class Productcategorie
|
||||||
{
|
{
|
||||||
// Composite Primary Key wird via Fluent API in Ihrem DbContext konfiguriert:
|
// Composite Primary Key wird via Fluent API in Ihrem DbContext konfiguriert:
|
||||||
// modelBuilder.Entity<ProductCategory>().HasKey(pc => new { pc.ProductId, pc.CategoryId });
|
// modelBuilder.Entity<Productcategorie>().HasKey(pc => new { pc.ProductId, pc.categorieId });
|
||||||
|
|
||||||
[ForeignKey(nameof(Product))]
|
[ForeignKey(nameof(Product))]
|
||||||
public Guid ProductId { get; set; }
|
public Guid ProductId { get; set; }
|
||||||
|
|
||||||
[ForeignKey(nameof(Category))]
|
[ForeignKey(nameof(categorie))]
|
||||||
public Guid CategoryId { get; set; }
|
public Guid categorieId { get; set; }
|
||||||
|
|
||||||
// Navigation Properties
|
// Navigation Properties
|
||||||
public virtual Product Product { get; set; }
|
public virtual Product Product { get; set; }
|
||||||
public virtual Category Category { get; set; }
|
public virtual categorie categorie { get; set; }
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// src/Webshop.Domain/Interfaces/ICategoryRepository.cs
|
// src/Webshop.Domain/Interfaces/IcategorieRepository.cs
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@@ -6,13 +6,13 @@ using Webshop.Domain.Entities;
|
|||||||
|
|
||||||
namespace Webshop.Domain.Interfaces
|
namespace Webshop.Domain.Interfaces
|
||||||
{
|
{
|
||||||
public interface ICategoryRepository
|
public interface IcategorieRepository
|
||||||
{
|
{
|
||||||
Task<IEnumerable<Category>> GetAllAsync();
|
Task<IEnumerable<categorie>> GetAllAsync();
|
||||||
Task<Category?> GetByIdAsync(Guid id);
|
Task<categorie?> GetByIdAsync(Guid id);
|
||||||
Task<Category?> GetBySlugAsync(string slug);
|
Task<categorie?> GetBySlugAsync(string slug);
|
||||||
Task AddAsync(Category category);
|
Task AddAsync(categorie categorie);
|
||||||
Task UpdateAsync(Category category);
|
Task UpdateAsync(categorie categorie);
|
||||||
Task DeleteAsync(Guid id);
|
Task DeleteAsync(Guid id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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> categorys { get; set; } = default!;
|
public DbSet<categorie> categories { 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,9 +26,9 @@ 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> Productcategorys { get; set; } = default!;
|
public DbSet<Productcategorie> Productcategories { 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<categorieDiscount> categorieDiscounts { get; set; } = default!;
|
||||||
|
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
@@ -45,13 +45,13 @@ namespace Webshop.Infrastructure.Data
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
modelBuilder.Entity<ProductCategory>().HasKey(pc => new { pc.ProductId, pc.CategoryId });
|
modelBuilder.Entity<Productcategorie>().HasKey(pc => new { pc.ProductId, pc.categorieId });
|
||||||
modelBuilder.Entity<ProductDiscount>().HasKey(pd => new { pd.ProductId, pd.DiscountId });
|
modelBuilder.Entity<ProductDiscount>().HasKey(pd => new { pd.ProductId, pd.DiscountId });
|
||||||
modelBuilder.Entity<CategoryDiscount>().HasKey(cd => new { cd.CategoryId, cd.DiscountId });
|
modelBuilder.Entity<categorieDiscount>().HasKey(cd => new { cd.categorieId, cd.DiscountId });
|
||||||
|
|
||||||
modelBuilder.Entity<Product>().HasIndex(p => p.SKU).IsUnique();
|
modelBuilder.Entity<Product>().HasIndex(p => p.SKU).IsUnique();
|
||||||
modelBuilder.Entity<Product>().HasIndex(p => p.Slug).IsUnique();
|
modelBuilder.Entity<Product>().HasIndex(p => p.Slug).IsUnique();
|
||||||
modelBuilder.Entity<Category>().HasIndex(c => c.Slug).IsUnique();
|
modelBuilder.Entity<categorie>().HasIndex(c => c.Slug).IsUnique();
|
||||||
modelBuilder.Entity<Discount>().HasIndex(d => d.CouponCode).IsUnique().HasFilter("\"CouponCode\" IS NOT NULL");
|
modelBuilder.Entity<Discount>().HasIndex(d => d.CouponCode).IsUnique().HasFilter("\"CouponCode\" IS NOT NULL");
|
||||||
modelBuilder.Entity<Setting>().HasIndex(s => s.Key).IsUnique();
|
modelBuilder.Entity<Setting>().HasIndex(s => s.Key).IsUnique();
|
||||||
modelBuilder.Entity<Order>().HasIndex(o => o.OrderNumber).IsUnique();
|
modelBuilder.Entity<Order>().HasIndex(o => o.OrderNumber).IsUnique();
|
||||||
@@ -99,10 +99,10 @@ namespace Webshop.Infrastructure.Data
|
|||||||
modelBuilder.Entity<PaymentMethod>()
|
modelBuilder.Entity<PaymentMethod>()
|
||||||
.Property(pm => pm.ProcessingFee).HasPrecision(18, 2);
|
.Property(pm => pm.ProcessingFee).HasPrecision(18, 2);
|
||||||
|
|
||||||
modelBuilder.Entity<Category>()
|
modelBuilder.Entity<categorie>()
|
||||||
.HasOne(c => c.ParentCategory)
|
.HasOne(c => c.Parentcategorie)
|
||||||
.WithMany(c => c.Subcategorys)
|
.WithMany(c => c.Subcategories)
|
||||||
.HasForeignKey(c => c.ParentCategoryId)
|
.HasForeignKey(c => c.ParentcategorieId)
|
||||||
.OnDelete(DeleteBehavior.Restrict);
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
|
|
||||||
modelBuilder.Entity<OrderItem>()
|
modelBuilder.Entity<OrderItem>()
|
||||||
|
|||||||
@@ -218,7 +218,7 @@ namespace Webshop.Infrastructure.Migrations
|
|||||||
b.ToTable("Addresses");
|
b.ToTable("Addresses");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Webshop.Domain.Entities.Category", b =>
|
modelBuilder.Entity("Webshop.Domain.Entities.categorie", b =>
|
||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
@@ -249,7 +249,7 @@ namespace Webshop.Infrastructure.Migrations
|
|||||||
.HasMaxLength(255)
|
.HasMaxLength(255)
|
||||||
.HasColumnType("character varying(255)");
|
.HasColumnType("character varying(255)");
|
||||||
|
|
||||||
b.Property<Guid?>("ParentCategoryId")
|
b.Property<Guid?>("ParentcategorieId")
|
||||||
.HasColumnType("uuid");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<string>("Slug")
|
b.Property<string>("Slug")
|
||||||
@@ -259,27 +259,27 @@ namespace Webshop.Infrastructure.Migrations
|
|||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.HasIndex("ParentCategoryId");
|
b.HasIndex("ParentcategorieId");
|
||||||
|
|
||||||
b.HasIndex("Slug")
|
b.HasIndex("Slug")
|
||||||
.IsUnique();
|
.IsUnique();
|
||||||
|
|
||||||
b.ToTable("categorys");
|
b.ToTable("categories");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Webshop.Domain.Entities.CategoryDiscount", b =>
|
modelBuilder.Entity("Webshop.Domain.Entities.categorieDiscount", b =>
|
||||||
{
|
{
|
||||||
b.Property<Guid>("CategoryId")
|
b.Property<Guid>("categorieId")
|
||||||
.HasColumnType("uuid");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid>("DiscountId")
|
b.Property<Guid>("DiscountId")
|
||||||
.HasColumnType("uuid");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.HasKey("CategoryId", "DiscountId");
|
b.HasKey("categorieId", "DiscountId");
|
||||||
|
|
||||||
b.HasIndex("DiscountId");
|
b.HasIndex("DiscountId");
|
||||||
|
|
||||||
b.ToTable("CategoryDiscounts");
|
b.ToTable("categorieDiscounts");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Webshop.Domain.Entities.Customer", b =>
|
modelBuilder.Entity("Webshop.Domain.Entities.Customer", b =>
|
||||||
@@ -655,19 +655,19 @@ namespace Webshop.Infrastructure.Migrations
|
|||||||
b.ToTable("Products");
|
b.ToTable("Products");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Webshop.Domain.Entities.ProductCategory", b =>
|
modelBuilder.Entity("Webshop.Domain.Entities.Productcategorie", b =>
|
||||||
{
|
{
|
||||||
b.Property<Guid>("ProductId")
|
b.Property<Guid>("ProductId")
|
||||||
.HasColumnType("uuid");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid>("CategoryId")
|
b.Property<Guid>("categorieId")
|
||||||
.HasColumnType("uuid");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.HasKey("ProductId", "CategoryId");
|
b.HasKey("ProductId", "categorieId");
|
||||||
|
|
||||||
b.HasIndex("CategoryId");
|
b.HasIndex("categorieId");
|
||||||
|
|
||||||
b.ToTable("Productcategorys");
|
b.ToTable("Productcategories");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Webshop.Domain.Entities.ProductDiscount", b =>
|
modelBuilder.Entity("Webshop.Domain.Entities.ProductDiscount", b =>
|
||||||
@@ -1006,31 +1006,31 @@ namespace Webshop.Infrastructure.Migrations
|
|||||||
b.Navigation("Customer");
|
b.Navigation("Customer");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Webshop.Domain.Entities.Category", b =>
|
modelBuilder.Entity("Webshop.Domain.Entities.categorie", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("Webshop.Domain.Entities.Category", "ParentCategory")
|
b.HasOne("Webshop.Domain.Entities.categorie", "Parentcategorie")
|
||||||
.WithMany("Subcategorys")
|
.WithMany("Subcategories")
|
||||||
.HasForeignKey("ParentCategoryId")
|
.HasForeignKey("ParentcategorieId")
|
||||||
.OnDelete(DeleteBehavior.Restrict);
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
|
|
||||||
b.Navigation("ParentCategory");
|
b.Navigation("Parentcategorie");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Webshop.Domain.Entities.CategoryDiscount", b =>
|
modelBuilder.Entity("Webshop.Domain.Entities.categorieDiscount", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("Webshop.Domain.Entities.Category", "Category")
|
b.HasOne("Webshop.Domain.Entities.categorie", "categorie")
|
||||||
.WithMany("CategoryDiscounts")
|
.WithMany("categorieDiscounts")
|
||||||
.HasForeignKey("CategoryId")
|
.HasForeignKey("categorieId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.HasOne("Webshop.Domain.Entities.Discount", "Discount")
|
b.HasOne("Webshop.Domain.Entities.Discount", "Discount")
|
||||||
.WithMany("CategoryDiscounts")
|
.WithMany("categorieDiscounts")
|
||||||
.HasForeignKey("DiscountId")
|
.HasForeignKey("DiscountId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.Navigation("Category");
|
b.Navigation("categorie");
|
||||||
|
|
||||||
b.Navigation("Discount");
|
b.Navigation("Discount");
|
||||||
});
|
});
|
||||||
@@ -1117,21 +1117,21 @@ namespace Webshop.Infrastructure.Migrations
|
|||||||
b.Navigation("Supplier");
|
b.Navigation("Supplier");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Webshop.Domain.Entities.ProductCategory", b =>
|
modelBuilder.Entity("Webshop.Domain.Entities.Productcategorie", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("Webshop.Domain.Entities.Category", "Category")
|
b.HasOne("Webshop.Domain.Entities.categorie", "categorie")
|
||||||
.WithMany("Productcategorys")
|
.WithMany("Productcategories")
|
||||||
.HasForeignKey("CategoryId")
|
.HasForeignKey("categorieId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.HasOne("Webshop.Domain.Entities.Product", "Product")
|
b.HasOne("Webshop.Domain.Entities.Product", "Product")
|
||||||
.WithMany("Productcategorys")
|
.WithMany("Productcategories")
|
||||||
.HasForeignKey("ProductId")
|
.HasForeignKey("ProductId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.Navigation("Category");
|
b.Navigation("categorie");
|
||||||
|
|
||||||
b.Navigation("Product");
|
b.Navigation("Product");
|
||||||
});
|
});
|
||||||
@@ -1192,13 +1192,13 @@ namespace Webshop.Infrastructure.Migrations
|
|||||||
b.Navigation("Address");
|
b.Navigation("Address");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Webshop.Domain.Entities.Category", b =>
|
modelBuilder.Entity("Webshop.Domain.Entities.categorie", b =>
|
||||||
{
|
{
|
||||||
b.Navigation("CategoryDiscounts");
|
b.Navigation("categorieDiscounts");
|
||||||
|
|
||||||
b.Navigation("Productcategorys");
|
b.Navigation("Productcategories");
|
||||||
|
|
||||||
b.Navigation("Subcategorys");
|
b.Navigation("Subcategories");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Webshop.Domain.Entities.Customer", b =>
|
modelBuilder.Entity("Webshop.Domain.Entities.Customer", b =>
|
||||||
@@ -1212,7 +1212,7 @@ namespace Webshop.Infrastructure.Migrations
|
|||||||
|
|
||||||
modelBuilder.Entity("Webshop.Domain.Entities.Discount", b =>
|
modelBuilder.Entity("Webshop.Domain.Entities.Discount", b =>
|
||||||
{
|
{
|
||||||
b.Navigation("CategoryDiscounts");
|
b.Navigation("categorieDiscounts");
|
||||||
|
|
||||||
b.Navigation("ProductDiscounts");
|
b.Navigation("ProductDiscounts");
|
||||||
});
|
});
|
||||||
@@ -1226,7 +1226,7 @@ namespace Webshop.Infrastructure.Migrations
|
|||||||
{
|
{
|
||||||
b.Navigation("ProductDiscounts");
|
b.Navigation("ProductDiscounts");
|
||||||
|
|
||||||
b.Navigation("Productcategorys");
|
b.Navigation("Productcategories");
|
||||||
|
|
||||||
b.Navigation("Reviews");
|
b.Navigation("Reviews");
|
||||||
|
|
||||||
|
|||||||
@@ -13,14 +13,14 @@ namespace Webshop.Infrastructure.Migrations
|
|||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "categorys",
|
name: "categories",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
Name = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
|
Name = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
|
||||||
Description = table.Column<string>(type: "character varying(1000)", maxLength: 1000, nullable: true),
|
Description = table.Column<string>(type: "character varying(1000)", maxLength: 1000, nullable: true),
|
||||||
Slug = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
|
Slug = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
|
||||||
ParentCategoryId = table.Column<Guid>(type: "uuid", nullable: true),
|
ParentcategorieId = table.Column<Guid>(type: "uuid", nullable: true),
|
||||||
ImageUrl = table.Column<string>(type: "character varying(2000)", maxLength: 2000, nullable: true),
|
ImageUrl = table.Column<string>(type: "character varying(2000)", maxLength: 2000, nullable: true),
|
||||||
IsActive = table.Column<bool>(type: "boolean", nullable: false),
|
IsActive = table.Column<bool>(type: "boolean", nullable: false),
|
||||||
DisplayOrder = table.Column<int>(type: "integer", nullable: false),
|
DisplayOrder = table.Column<int>(type: "integer", nullable: false),
|
||||||
@@ -29,11 +29,11 @@ namespace Webshop.Infrastructure.Migrations
|
|||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
table.PrimaryKey("PK_categorys", x => x.Id);
|
table.PrimaryKey("PK_categories", x => x.Id);
|
||||||
table.ForeignKey(
|
table.ForeignKey(
|
||||||
name: "FK_categorys_categorys_ParentCategoryId",
|
name: "FK_categories_categories_ParentcategorieId",
|
||||||
column: x => x.ParentCategoryId,
|
column: x => x.ParentcategorieId,
|
||||||
principalTable: "categorys",
|
principalTable: "categories",
|
||||||
principalColumn: "Id",
|
principalColumn: "Id",
|
||||||
onDelete: ReferentialAction.Restrict);
|
onDelete: ReferentialAction.Restrict);
|
||||||
});
|
});
|
||||||
@@ -154,25 +154,25 @@ namespace Webshop.Infrastructure.Migrations
|
|||||||
});
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "CategoryDiscounts",
|
name: "categorieDiscounts",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
CategoryId = table.Column<Guid>(type: "uuid", nullable: false),
|
categorieId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
DiscountId = table.Column<Guid>(type: "uuid", nullable: false)
|
DiscountId = table.Column<Guid>(type: "uuid", nullable: false)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
table.PrimaryKey("PK_CategoryDiscounts", x => new { x.CategoryId, x.DiscountId });
|
table.PrimaryKey("PK_categorieDiscounts", x => new { x.categorieId, x.DiscountId });
|
||||||
table.ForeignKey(
|
table.ForeignKey(
|
||||||
name: "FK_CategoryDiscounts_Discounts_DiscountId",
|
name: "FK_categorieDiscounts_Discounts_DiscountId",
|
||||||
column: x => x.DiscountId,
|
column: x => x.DiscountId,
|
||||||
principalTable: "Discounts",
|
principalTable: "Discounts",
|
||||||
principalColumn: "Id",
|
principalColumn: "Id",
|
||||||
onDelete: ReferentialAction.Cascade);
|
onDelete: ReferentialAction.Cascade);
|
||||||
table.ForeignKey(
|
table.ForeignKey(
|
||||||
name: "FK_CategoryDiscounts_categorys_CategoryId",
|
name: "FK_categorieDiscounts_categories_categorieId",
|
||||||
column: x => x.CategoryId,
|
column: x => x.categorieId,
|
||||||
principalTable: "categorys",
|
principalTable: "categories",
|
||||||
principalColumn: "Id",
|
principalColumn: "Id",
|
||||||
onDelete: ReferentialAction.Cascade);
|
onDelete: ReferentialAction.Cascade);
|
||||||
});
|
});
|
||||||
@@ -450,25 +450,25 @@ namespace Webshop.Infrastructure.Migrations
|
|||||||
});
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "Productcategorys",
|
name: "Productcategories",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
ProductId = table.Column<Guid>(type: "uuid", nullable: false),
|
ProductId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
CategoryId = table.Column<Guid>(type: "uuid", nullable: false)
|
categorieId = table.Column<Guid>(type: "uuid", nullable: false)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
table.PrimaryKey("PK_Productcategorys", x => new { x.ProductId, x.CategoryId });
|
table.PrimaryKey("PK_Productcategories", x => new { x.ProductId, x.categorieId });
|
||||||
table.ForeignKey(
|
table.ForeignKey(
|
||||||
name: "FK_Productcategorys_Products_ProductId",
|
name: "FK_Productcategories_Products_ProductId",
|
||||||
column: x => x.ProductId,
|
column: x => x.ProductId,
|
||||||
principalTable: "Products",
|
principalTable: "Products",
|
||||||
principalColumn: "Id",
|
principalColumn: "Id",
|
||||||
onDelete: ReferentialAction.Cascade);
|
onDelete: ReferentialAction.Cascade);
|
||||||
table.ForeignKey(
|
table.ForeignKey(
|
||||||
name: "FK_Productcategorys_categorys_CategoryId",
|
name: "FK_Productcategories_categories_categorieId",
|
||||||
column: x => x.CategoryId,
|
column: x => x.categorieId,
|
||||||
principalTable: "categorys",
|
principalTable: "categories",
|
||||||
principalColumn: "Id",
|
principalColumn: "Id",
|
||||||
onDelete: ReferentialAction.Cascade);
|
onDelete: ReferentialAction.Cascade);
|
||||||
});
|
});
|
||||||
@@ -594,18 +594,18 @@ namespace Webshop.Infrastructure.Migrations
|
|||||||
column: "CustomerId");
|
column: "CustomerId");
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
name: "IX_CategoryDiscounts_DiscountId",
|
name: "IX_categorieDiscounts_DiscountId",
|
||||||
table: "CategoryDiscounts",
|
table: "categorieDiscounts",
|
||||||
column: "DiscountId");
|
column: "DiscountId");
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
name: "IX_categorys_ParentCategoryId",
|
name: "IX_categories_ParentcategorieId",
|
||||||
table: "categorys",
|
table: "categories",
|
||||||
column: "ParentCategoryId");
|
column: "ParentcategorieId");
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
name: "IX_categorys_Slug",
|
name: "IX_categories_Slug",
|
||||||
table: "categorys",
|
table: "categories",
|
||||||
column: "Slug",
|
column: "Slug",
|
||||||
unique: true);
|
unique: true);
|
||||||
|
|
||||||
@@ -669,9 +669,9 @@ namespace Webshop.Infrastructure.Migrations
|
|||||||
column: "ShippingMethodId");
|
column: "ShippingMethodId");
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
name: "IX_Productcategorys_CategoryId",
|
name: "IX_Productcategories_categorieId",
|
||||||
table: "Productcategorys",
|
table: "Productcategories",
|
||||||
column: "CategoryId");
|
column: "categorieId");
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
name: "IX_ProductDiscounts_DiscountId",
|
name: "IX_ProductDiscounts_DiscountId",
|
||||||
@@ -763,13 +763,13 @@ namespace Webshop.Infrastructure.Migrations
|
|||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "CategoryDiscounts");
|
name: "categorieDiscounts");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "OrderItems");
|
name: "OrderItems");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "Productcategorys");
|
name: "Productcategories");
|
||||||
|
|
||||||
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: "categorys");
|
name: "categories");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "Discounts");
|
name: "Discounts");
|
||||||
|
|||||||
@@ -215,7 +215,7 @@ namespace Webshop.Infrastructure.Migrations
|
|||||||
b.ToTable("Addresses");
|
b.ToTable("Addresses");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Webshop.Domain.Entities.Category", b =>
|
modelBuilder.Entity("Webshop.Domain.Entities.categorie", b =>
|
||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
@@ -246,7 +246,7 @@ namespace Webshop.Infrastructure.Migrations
|
|||||||
.HasMaxLength(255)
|
.HasMaxLength(255)
|
||||||
.HasColumnType("character varying(255)");
|
.HasColumnType("character varying(255)");
|
||||||
|
|
||||||
b.Property<Guid?>("ParentCategoryId")
|
b.Property<Guid?>("ParentcategorieId")
|
||||||
.HasColumnType("uuid");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<string>("Slug")
|
b.Property<string>("Slug")
|
||||||
@@ -256,27 +256,27 @@ namespace Webshop.Infrastructure.Migrations
|
|||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.HasIndex("ParentCategoryId");
|
b.HasIndex("ParentcategorieId");
|
||||||
|
|
||||||
b.HasIndex("Slug")
|
b.HasIndex("Slug")
|
||||||
.IsUnique();
|
.IsUnique();
|
||||||
|
|
||||||
b.ToTable("categorys");
|
b.ToTable("categories");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Webshop.Domain.Entities.CategoryDiscount", b =>
|
modelBuilder.Entity("Webshop.Domain.Entities.categorieDiscount", b =>
|
||||||
{
|
{
|
||||||
b.Property<Guid>("CategoryId")
|
b.Property<Guid>("categorieId")
|
||||||
.HasColumnType("uuid");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid>("DiscountId")
|
b.Property<Guid>("DiscountId")
|
||||||
.HasColumnType("uuid");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.HasKey("CategoryId", "DiscountId");
|
b.HasKey("categorieId", "DiscountId");
|
||||||
|
|
||||||
b.HasIndex("DiscountId");
|
b.HasIndex("DiscountId");
|
||||||
|
|
||||||
b.ToTable("CategoryDiscounts");
|
b.ToTable("categorieDiscounts");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Webshop.Domain.Entities.Customer", b =>
|
modelBuilder.Entity("Webshop.Domain.Entities.Customer", b =>
|
||||||
@@ -652,19 +652,19 @@ namespace Webshop.Infrastructure.Migrations
|
|||||||
b.ToTable("Products");
|
b.ToTable("Products");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Webshop.Domain.Entities.ProductCategory", b =>
|
modelBuilder.Entity("Webshop.Domain.Entities.Productcategorie", b =>
|
||||||
{
|
{
|
||||||
b.Property<Guid>("ProductId")
|
b.Property<Guid>("ProductId")
|
||||||
.HasColumnType("uuid");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.Property<Guid>("CategoryId")
|
b.Property<Guid>("categorieId")
|
||||||
.HasColumnType("uuid");
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
b.HasKey("ProductId", "CategoryId");
|
b.HasKey("ProductId", "categorieId");
|
||||||
|
|
||||||
b.HasIndex("CategoryId");
|
b.HasIndex("categorieId");
|
||||||
|
|
||||||
b.ToTable("Productcategorys");
|
b.ToTable("Productcategories");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Webshop.Domain.Entities.ProductDiscount", b =>
|
modelBuilder.Entity("Webshop.Domain.Entities.ProductDiscount", b =>
|
||||||
@@ -1003,31 +1003,31 @@ namespace Webshop.Infrastructure.Migrations
|
|||||||
b.Navigation("Customer");
|
b.Navigation("Customer");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Webshop.Domain.Entities.Category", b =>
|
modelBuilder.Entity("Webshop.Domain.Entities.categorie", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("Webshop.Domain.Entities.Category", "ParentCategory")
|
b.HasOne("Webshop.Domain.Entities.categorie", "Parentcategorie")
|
||||||
.WithMany("Subcategorys")
|
.WithMany("Subcategories")
|
||||||
.HasForeignKey("ParentCategoryId")
|
.HasForeignKey("ParentcategorieId")
|
||||||
.OnDelete(DeleteBehavior.Restrict);
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
|
|
||||||
b.Navigation("ParentCategory");
|
b.Navigation("Parentcategorie");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Webshop.Domain.Entities.CategoryDiscount", b =>
|
modelBuilder.Entity("Webshop.Domain.Entities.categorieDiscount", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("Webshop.Domain.Entities.Category", "Category")
|
b.HasOne("Webshop.Domain.Entities.categorie", "categorie")
|
||||||
.WithMany("CategoryDiscounts")
|
.WithMany("categorieDiscounts")
|
||||||
.HasForeignKey("CategoryId")
|
.HasForeignKey("categorieId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.HasOne("Webshop.Domain.Entities.Discount", "Discount")
|
b.HasOne("Webshop.Domain.Entities.Discount", "Discount")
|
||||||
.WithMany("CategoryDiscounts")
|
.WithMany("categorieDiscounts")
|
||||||
.HasForeignKey("DiscountId")
|
.HasForeignKey("DiscountId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.Navigation("Category");
|
b.Navigation("categorie");
|
||||||
|
|
||||||
b.Navigation("Discount");
|
b.Navigation("Discount");
|
||||||
});
|
});
|
||||||
@@ -1114,21 +1114,21 @@ namespace Webshop.Infrastructure.Migrations
|
|||||||
b.Navigation("Supplier");
|
b.Navigation("Supplier");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Webshop.Domain.Entities.ProductCategory", b =>
|
modelBuilder.Entity("Webshop.Domain.Entities.Productcategorie", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("Webshop.Domain.Entities.Category", "Category")
|
b.HasOne("Webshop.Domain.Entities.categorie", "categorie")
|
||||||
.WithMany("Productcategorys")
|
.WithMany("Productcategories")
|
||||||
.HasForeignKey("CategoryId")
|
.HasForeignKey("categorieId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.HasOne("Webshop.Domain.Entities.Product", "Product")
|
b.HasOne("Webshop.Domain.Entities.Product", "Product")
|
||||||
.WithMany("Productcategorys")
|
.WithMany("Productcategories")
|
||||||
.HasForeignKey("ProductId")
|
.HasForeignKey("ProductId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.Navigation("Category");
|
b.Navigation("categorie");
|
||||||
|
|
||||||
b.Navigation("Product");
|
b.Navigation("Product");
|
||||||
});
|
});
|
||||||
@@ -1189,13 +1189,13 @@ namespace Webshop.Infrastructure.Migrations
|
|||||||
b.Navigation("Address");
|
b.Navigation("Address");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Webshop.Domain.Entities.Category", b =>
|
modelBuilder.Entity("Webshop.Domain.Entities.categorie", b =>
|
||||||
{
|
{
|
||||||
b.Navigation("CategoryDiscounts");
|
b.Navigation("categorieDiscounts");
|
||||||
|
|
||||||
b.Navigation("Productcategorys");
|
b.Navigation("Productcategories");
|
||||||
|
|
||||||
b.Navigation("Subcategorys");
|
b.Navigation("Subcategories");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Webshop.Domain.Entities.Customer", b =>
|
modelBuilder.Entity("Webshop.Domain.Entities.Customer", b =>
|
||||||
@@ -1209,7 +1209,7 @@ namespace Webshop.Infrastructure.Migrations
|
|||||||
|
|
||||||
modelBuilder.Entity("Webshop.Domain.Entities.Discount", b =>
|
modelBuilder.Entity("Webshop.Domain.Entities.Discount", b =>
|
||||||
{
|
{
|
||||||
b.Navigation("CategoryDiscounts");
|
b.Navigation("categorieDiscounts");
|
||||||
|
|
||||||
b.Navigation("ProductDiscounts");
|
b.Navigation("ProductDiscounts");
|
||||||
});
|
});
|
||||||
@@ -1223,7 +1223,7 @@ namespace Webshop.Infrastructure.Migrations
|
|||||||
{
|
{
|
||||||
b.Navigation("ProductDiscounts");
|
b.Navigation("ProductDiscounts");
|
||||||
|
|
||||||
b.Navigation("Productcategorys");
|
b.Navigation("Productcategories");
|
||||||
|
|
||||||
b.Navigation("Reviews");
|
b.Navigation("Reviews");
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// src/Webshop.Infrastructure/Repositories/CategoryRepository.cs
|
// src/Webshop.Infrastructure/Repositories/categorieRepository.cs
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -9,48 +9,48 @@ using Webshop.Infrastructure.Data;
|
|||||||
|
|
||||||
namespace Webshop.Infrastructure.Repositories
|
namespace Webshop.Infrastructure.Repositories
|
||||||
{
|
{
|
||||||
public class CategoryRepository : ICategoryRepository
|
public class categorieRepository : IcategorieRepository
|
||||||
{
|
{
|
||||||
private readonly ApplicationDbContext _context;
|
private readonly ApplicationDbContext _context;
|
||||||
|
|
||||||
public CategoryRepository(ApplicationDbContext context)
|
public categorieRepository(ApplicationDbContext context)
|
||||||
{
|
{
|
||||||
_context = context;
|
_context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<Category>> GetAllAsync()
|
public async Task<IEnumerable<categorie>> GetAllAsync()
|
||||||
{
|
{
|
||||||
return await _context.categorys.ToListAsync();
|
return await _context.categories.ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Category?> GetByIdAsync(Guid id)
|
public async Task<categorie?> GetByIdAsync(Guid id)
|
||||||
{
|
{
|
||||||
return await _context.categorys.FindAsync(id);
|
return await _context.categories.FindAsync(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Category?> GetBySlugAsync(string slug)
|
public async Task<categorie?> GetBySlugAsync(string slug)
|
||||||
{
|
{
|
||||||
return await _context.categorys.FirstOrDefaultAsync(c => c.Slug == slug);
|
return await _context.categories.FirstOrDefaultAsync(c => c.Slug == slug);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task AddAsync(Category category)
|
public async Task AddAsync(categorie categorie)
|
||||||
{
|
{
|
||||||
_context.categorys.Add(category);
|
_context.categories.Add(categorie);
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task UpdateAsync(Category category)
|
public async Task UpdateAsync(categorie categorie)
|
||||||
{
|
{
|
||||||
_context.categorys.Update(category);
|
_context.categories.Update(categorie);
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task DeleteAsync(Guid id)
|
public async Task DeleteAsync(Guid id)
|
||||||
{
|
{
|
||||||
var category = await _context.categorys.FindAsync(id);
|
var categorie = await _context.categories.FindAsync(id);
|
||||||
if (category != null)
|
if (categorie != null)
|
||||||
{
|
{
|
||||||
_context.categorys.Remove(category);
|
_context.categories.Remove(categorie);
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user