naming
This commit is contained in:
@@ -4,7 +4,7 @@ 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.categories;
|
using Webshop.Application.DTOs.Categorie;
|
||||||
using Webshop.Application.Services.Admin;
|
using Webshop.Application.Services.Admin;
|
||||||
|
|
||||||
namespace Webshop.Api.Controllers.Admin
|
namespace Webshop.Api.Controllers.Admin
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ 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.categories;
|
using Webshop.Application.DTOs.Categorie;
|
||||||
using Webshop.Application.Services.Public;
|
using Webshop.Application.Services.Public;
|
||||||
|
|
||||||
namespace Webshop.Api.Controllers.Public
|
namespace Webshop.Api.Controllers.Public
|
||||||
|
|||||||
@@ -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<IcategorieRepository, categorieRepository>();
|
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>();
|
||||||
|
|||||||
@@ -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.categories;
|
using Webshop.Application.DTOs.Categorie;
|
||||||
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;
|
||||||
@@ -29,27 +29,7 @@ namespace Webshop.Api.SwaggerFilters
|
|||||||
var uniqueId = Guid.NewGuid().ToString().Substring(0, 8);
|
var uniqueId = Guid.NewGuid().ToString().Substring(0, 8);
|
||||||
|
|
||||||
// --- Authentifizierung & Benutzer (Allgemeine Schemas) ---
|
// --- Authentifizierung & Benutzer (Allgemeine Schemas) ---
|
||||||
if (type == typeof(LoginRequestDto))
|
if (type == typeof(AuthResponseDto))
|
||||||
{
|
|
||||||
// Hinweis: Dieses Beispiel wird vom LoginExampleOperationFilter für spezifische Endpunkte überschrieben.
|
|
||||||
schema.Example = new OpenApiObject
|
|
||||||
{
|
|
||||||
["email"] = new OpenApiString("user@example.com"),
|
|
||||||
["password"] = new OpenApiString("Password123!")
|
|
||||||
};
|
|
||||||
}
|
|
||||||
else if (type == typeof(RegisterRequestDto))
|
|
||||||
{
|
|
||||||
schema.Example = new OpenApiObject
|
|
||||||
{
|
|
||||||
["email"] = new OpenApiString($"neuer.kunde.{uniqueId}@example.com"),
|
|
||||||
["password"] = new OpenApiString("NeuesPasswort123!"),
|
|
||||||
["confirmPassword"] = new OpenApiString("NeuesPasswort123!"),
|
|
||||||
["firstName"] = new OpenApiString("Erika"),
|
|
||||||
["lastName"] = new OpenApiString("Musterfrau")
|
|
||||||
};
|
|
||||||
}
|
|
||||||
else if (type == typeof(AuthResponseDto))
|
|
||||||
{
|
{
|
||||||
schema.Example = new OpenApiObject
|
schema.Example = new OpenApiObject
|
||||||
{
|
{
|
||||||
@@ -79,28 +59,7 @@ namespace Webshop.Api.SwaggerFilters
|
|||||||
["defaultBillingAddressId"] = new OpenApiNull()
|
["defaultBillingAddressId"] = new OpenApiNull()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else if (type == typeof(ResendEmailConfirmationRequestDto))
|
// --- Produkte & Kategorien (Antworten) ---
|
||||||
{
|
|
||||||
schema.Example = new OpenApiObject { ["email"] = new OpenApiString("unconfirmed.user@example.com") };
|
|
||||||
}
|
|
||||||
else if (type == typeof(ChangePasswordRequestDto))
|
|
||||||
{
|
|
||||||
schema.Example = new OpenApiObject
|
|
||||||
{
|
|
||||||
["oldPassword"] = new OpenApiString("SecureCustomerPass123!"),
|
|
||||||
["newPassword"] = new OpenApiString("NewSecurePass456!"),
|
|
||||||
["confirmNewPassword"] = new OpenApiString("NewSecurePass456!")
|
|
||||||
};
|
|
||||||
}
|
|
||||||
else if (type == typeof(ChangeEmailRequestDto))
|
|
||||||
{
|
|
||||||
schema.Example = new OpenApiObject
|
|
||||||
{
|
|
||||||
["newEmail"] = new OpenApiString($"new.email.{uniqueId}@example.com"),
|
|
||||||
["currentPassword"] = new OpenApiString("SecureCustomerPass123!")
|
|
||||||
};
|
|
||||||
}
|
|
||||||
// --- Produkte & Lieferanten ---
|
|
||||||
else if (type == typeof(ProductDto))
|
else if (type == typeof(ProductDto))
|
||||||
{
|
{
|
||||||
schema.Example = new OpenApiObject
|
schema.Example = new OpenApiObject
|
||||||
@@ -126,87 +85,47 @@ namespace Webshop.Api.SwaggerFilters
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else if (type == typeof(AdminProductDto))
|
else if (type == typeof(CategorieDto))
|
||||||
{
|
|
||||||
schema.Example = new OpenApiObject
|
|
||||||
{
|
|
||||||
["id"] = new OpenApiString(Guid.Empty.ToString()),
|
|
||||||
["name"] = new OpenApiString($"Admin Produkt (Beispiel) {uniqueId}"),
|
|
||||||
["description"] = new OpenApiString("Detaillierte Beschreibung für das Admin-Produkt."),
|
|
||||||
["sku"] = new OpenApiString($"ADM-PROD-{uniqueId}"),
|
|
||||||
["price"] = new OpenApiDouble(149.99),
|
|
||||||
["oldPrice"] = new OpenApiNull(),
|
|
||||||
["isActive"] = new OpenApiBoolean(true),
|
|
||||||
["isInStock"] = new OpenApiBoolean(true),
|
|
||||||
["stockQuantity"] = new OpenApiInteger(50),
|
|
||||||
["weight"] = new OpenApiDouble(1.2),
|
|
||||||
["imageUrl"] = new OpenApiString("https://example.com/images/admin_prod.jpg"),
|
|
||||||
["slug"] = new OpenApiString($"admin-produkt-beispiel-slug-{uniqueId}"),
|
|
||||||
["createdDate"] = new OpenApiString(DateTimeOffset.UtcNow.ToString("o")),
|
|
||||||
["lastModifiedDate"] = new OpenApiNull(),
|
|
||||||
["supplierId"] = new OpenApiNull(),
|
|
||||||
["purchasePrice"] = new OpenApiDouble(80.00),
|
|
||||||
["categorieIds"] = new OpenApiArray { new OpenApiString("EXISTING_categorie_ID_HERE") }
|
|
||||||
};
|
|
||||||
}
|
|
||||||
// --- Kategorien ---
|
|
||||||
else if (type == typeof(CreatecategorieDto))
|
|
||||||
{
|
|
||||||
schema.Example = new OpenApiObject
|
|
||||||
{
|
|
||||||
["name"] = new OpenApiString($"Neue Kategorie {uniqueId}"),
|
|
||||||
["slug"] = new OpenApiString($"neue-kategorie-{uniqueId}"),
|
|
||||||
["description"] = new OpenApiString("Eine Beschreibung für die neue Kategorie."),
|
|
||||||
["parentcategorieId"] = new OpenApiNull(),
|
|
||||||
["imageUrl"] = new OpenApiString("https://example.com/images/new_categorie.jpg"),
|
|
||||||
["isActive"] = new OpenApiBoolean(true),
|
|
||||||
["displayOrder"] = new OpenApiInteger(1)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
// --- Adressen ---
|
|
||||||
else if (type == typeof(AddressDto))
|
|
||||||
{
|
{
|
||||||
schema.Example = new OpenApiObject
|
schema.Example = new OpenApiObject
|
||||||
{
|
{
|
||||||
["id"] = new OpenApiString(Guid.NewGuid().ToString()),
|
["id"] = new OpenApiString(Guid.NewGuid().ToString()),
|
||||||
["street"] = new OpenApiString("Musterstraße"),
|
["name"] = new OpenApiString($"Elektronik {uniqueId}"),
|
||||||
["houseNumber"] = new OpenApiString("123a"),
|
["slug"] = new OpenApiString($"elektronik-{uniqueId}"),
|
||||||
["city"] = new OpenApiString("Musterstadt"),
|
["description"] = new OpenApiString("Produkte rund um Elektronik."),
|
||||||
["postalCode"] = new OpenApiString("12345"),
|
["parentCategorieId"] = new OpenApiNull(),
|
||||||
["country"] = new OpenApiString("Deutschland"),
|
["imageUrl"] = new OpenApiString("https://example.com/images/categorie_electronics.jpg"),
|
||||||
["type"] = new OpenApiString(AddressType.Shipping.ToString())
|
["isActive"] = new OpenApiBoolean(true),
|
||||||
|
["displayOrder"] = new OpenApiInteger(1)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// --- Kunden ---
|
// --- Kunden ---
|
||||||
else if (type == typeof(UpdateCustomerDto))
|
else if (type == typeof(CustomerDto))
|
||||||
{
|
{
|
||||||
schema.Example = new OpenApiObject
|
schema.Example = new OpenApiObject
|
||||||
{
|
{
|
||||||
|
["id"] = new OpenApiString(Guid.NewGuid().ToString()),
|
||||||
|
["userId"] = new OpenApiString("EIN_IDENTITY_USER_ID_HIER"),
|
||||||
["firstName"] = new OpenApiString("Max"),
|
["firstName"] = new OpenApiString("Max"),
|
||||||
["lastName"] = new OpenApiString("Mustermann"),
|
["lastName"] = new OpenApiString("Mustermann"),
|
||||||
["phoneNumber"] = new OpenApiString("+491701234567"),
|
["email"] = new OpenApiString($"max.mustermann.{uniqueId}@example.com"),
|
||||||
["currentPassword"] = new OpenApiString("SecureCustomerPass123!"),
|
["phoneNumber"] = new OpenApiString("+491719876543"),
|
||||||
["defaultShippingAddressId"] = new OpenApiNull(),
|
["defaultShippingAddressId"] = new OpenApiNull(),
|
||||||
["defaultBillingAddressId"] = new OpenApiNull()
|
["defaultBillingAddressId"] = new OpenApiNull()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// --- Bestellungen ---
|
// --- Bestellungen ---
|
||||||
else if (type == typeof(CreateOrderDto))
|
else if (type == typeof(OrderSummaryDto))
|
||||||
{
|
{
|
||||||
schema.Example = new OpenApiObject
|
schema.Example = new OpenApiObject
|
||||||
{
|
{
|
||||||
["shippingAddressId"] = new OpenApiString("VALID_ADDRESS_ID_HERE"),
|
["id"] = new OpenApiString(Guid.NewGuid().ToString()),
|
||||||
["billingAddressId"] = new OpenApiString("VALID_ADDRESS_ID_HERE"),
|
["orderNumber"] = new OpenApiString($"WS-2025-{uniqueId}"),
|
||||||
["paymentMethodId"] = new OpenApiString("VALID_PAYMENT_METHOD_ID_HERE"),
|
["orderDate"] = new OpenApiString(DateTimeOffset.UtcNow.ToString("o")),
|
||||||
["shippingMethodId"] = new OpenApiString("VALID_SHIPPING_METHOD_ID_HERE"),
|
["status"] = new OpenApiString(OrderStatus.Processing.ToString()),
|
||||||
["items"] = new OpenApiArray
|
["totalAmount"] = new OpenApiDouble(123.45),
|
||||||
{
|
["paymentStatus"] = new OpenApiString(PaymentStatus.Paid.ToString()),
|
||||||
new OpenApiObject
|
["customerName"] = new OpenApiString("Max Mustermann")
|
||||||
{
|
|
||||||
["productId"] = new OpenApiString("VALID_PRODUCT_ID_HERE"),
|
|
||||||
["quantity"] = new OpenApiInteger(1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ using System.Collections.Generic;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
|
||||||
namespace Webshop.Application.DTOs.categories
|
namespace Webshop.Application.DTOs.Categorie
|
||||||
{
|
{
|
||||||
public class CategorieDto
|
public class CategorieDto
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ using System.Collections.Generic;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
|
||||||
namespace Webshop.Application.DTOs.categories
|
namespace Webshop.Application.DTOs.Categorie
|
||||||
{
|
{
|
||||||
public class CreatecategorieDto
|
public class CreatecategorieDto
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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.categories;
|
using Webshop.Application.DTOs.Categorie;
|
||||||
|
|
||||||
|
|
||||||
namespace Webshop.Application.DTOs.Products
|
namespace Webshop.Application.DTOs.Products
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ using System;
|
|||||||
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.categories;
|
using Webshop.Application.DTOs.Categorie;
|
||||||
using Webshop.Domain.Entities;
|
using Webshop.Domain.Entities;
|
||||||
using Webshop.Domain.Interfaces;
|
using Webshop.Domain.Interfaces;
|
||||||
|
|
||||||
@@ -11,9 +11,9 @@ namespace Webshop.Application.Services.Admin
|
|||||||
{
|
{
|
||||||
public class AdminCategorieService : IAdminCategorieService
|
public class AdminCategorieService : IAdminCategorieService
|
||||||
{
|
{
|
||||||
private readonly IcategorieRepository _categorieRepository;
|
private readonly ICategorieRepository _categorieRepository;
|
||||||
|
|
||||||
public AdminCategorieService(IcategorieRepository categorieRepository)
|
public AdminCategorieService(ICategorieRepository categorieRepository)
|
||||||
{
|
{
|
||||||
_categorieRepository = categorieRepository;
|
_categorieRepository = categorieRepository;
|
||||||
}
|
}
|
||||||
@@ -60,7 +60,7 @@ namespace Webshop.Application.Services.Admin
|
|||||||
return (null, "Eine Kategorie mit diesem Slug existiert bereits.");
|
return (null, "Eine Kategorie mit diesem Slug existiert bereits.");
|
||||||
}
|
}
|
||||||
|
|
||||||
var categorie = new categorie
|
var categorie = new Categorie
|
||||||
{
|
{
|
||||||
Id = Guid.NewGuid(),
|
Id = Guid.NewGuid(),
|
||||||
Name = categorieDto.Name,
|
Name = categorieDto.Name,
|
||||||
|
|||||||
@@ -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.categories;
|
using Webshop.Application.DTOs.Categorie;
|
||||||
|
|
||||||
namespace Webshop.Application.Services.Admin
|
namespace Webshop.Application.Services.Admin
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,16 +2,16 @@
|
|||||||
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.categories;
|
using Webshop.Application.DTOs.Categorie;
|
||||||
using Webshop.Domain.Interfaces;
|
using Webshop.Domain.Interfaces;
|
||||||
|
|
||||||
namespace Webshop.Application.Services.Public
|
namespace Webshop.Application.Services.Public
|
||||||
{
|
{
|
||||||
public class CategorieService : ICategorieService
|
public class CategorieService : ICategorieService
|
||||||
{
|
{
|
||||||
private readonly IcategorieRepository _categorieRepository;
|
private readonly ICategorieRepository _categorieRepository;
|
||||||
|
|
||||||
public CategorieService(IcategorieRepository categorieRepository)
|
public CategorieService(ICategorieRepository categorieRepository)
|
||||||
{
|
{
|
||||||
_categorieRepository = categorieRepository;
|
_categorieRepository = categorieRepository;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// src/Webshop.Application/Services/Public/Icategorieservice.cs
|
// src/Webshop.Application/Services/Public/Icategorieservice.cs
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Webshop.Application.DTOs.categories;
|
using Webshop.Application.DTOs.Categorie;
|
||||||
|
|
||||||
namespace Webshop.Application.Services.Public
|
namespace Webshop.Application.Services.Public
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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.categories; // Für categorieDto
|
using Webshop.Application.DTOs.Categorie; // 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
|
||||||
|
|||||||
@@ -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 categorie
|
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
|
||||||
@@ -43,9 +43,9 @@ namespace Webshop.Domain.Entities
|
|||||||
// << ENDE NEUE EIGENSCHAFTEN >>
|
// << ENDE NEUE EIGENSCHAFTEN >>
|
||||||
|
|
||||||
// Navigation Properties
|
// Navigation Properties
|
||||||
public virtual categorie? Parentcategorie { get; set; }
|
public virtual Categorie? Parentcategorie { get; set; }
|
||||||
public virtual ICollection<categorie> Subcategories { get; set; } = new List<categorie>();
|
public virtual ICollection<Categorie> Subcategories { get; set; } = new List<Categorie>();
|
||||||
public virtual ICollection<Productcategorie> Productcategories { get; set; } = new List<Productcategorie>();
|
public virtual ICollection<Productcategorie> Productcategories { get; set; } = new List<Productcategorie>();
|
||||||
public virtual ICollection<categorieDiscount> categorieDiscounts { get; set; } = new List<categorieDiscount>();
|
public virtual ICollection<CategorieDiscount> categorieDiscounts { get; set; } = new List<CategorieDiscount>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,7 @@ namespace Webshop.Domain.Entities;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Verknüpfungstabelle für die Viele-zu-Viele-Beziehung zwischen categorie und Discount.
|
/// Verknüpfungstabelle für die Viele-zu-Viele-Beziehung zwischen categorie und Discount.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class categorieDiscount
|
public class CategorieDiscount
|
||||||
{
|
{
|
||||||
[Required]
|
[Required]
|
||||||
[ForeignKey(nameof(categorie))]
|
[ForeignKey(nameof(categorie))]
|
||||||
@@ -18,6 +18,6 @@ public class categorieDiscount
|
|||||||
public Guid DiscountId { get; set; }
|
public Guid DiscountId { get; set; }
|
||||||
|
|
||||||
// Navigation Properties
|
// Navigation Properties
|
||||||
public virtual categorie categorie { 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<categorieDiscount> categorieDiscounts { get; set; } = new List<categorieDiscount>();
|
public virtual ICollection<CategorieDiscount> categorieDiscounts { get; set; } = new List<CategorieDiscount>();
|
||||||
}
|
}
|
||||||
@@ -20,5 +20,5 @@ public class Productcategorie
|
|||||||
|
|
||||||
// Navigation Properties
|
// Navigation Properties
|
||||||
public virtual Product Product { get; set; }
|
public virtual Product Product { get; set; }
|
||||||
public virtual categorie categorie { get; set; }
|
public virtual Categorie categorie { get; set; }
|
||||||
}
|
}
|
||||||
@@ -6,13 +6,13 @@ using Webshop.Domain.Entities;
|
|||||||
|
|
||||||
namespace Webshop.Domain.Interfaces
|
namespace Webshop.Domain.Interfaces
|
||||||
{
|
{
|
||||||
public interface IcategorieRepository
|
public interface ICategorieRepository
|
||||||
{
|
{
|
||||||
Task<IEnumerable<categorie>> GetAllAsync();
|
Task<IEnumerable<Categorie>> GetAllAsync();
|
||||||
Task<categorie?> GetByIdAsync(Guid id);
|
Task<Categorie?> GetByIdAsync(Guid id);
|
||||||
Task<categorie?> GetBySlugAsync(string slug);
|
Task<Categorie?> GetBySlugAsync(string slug);
|
||||||
Task AddAsync(categorie categorie);
|
Task AddAsync(Categorie categorie);
|
||||||
Task UpdateAsync(categorie categorie);
|
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<categorie> categories { 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!;
|
||||||
@@ -28,7 +28,7 @@ namespace Webshop.Infrastructure.Data
|
|||||||
|
|
||||||
public DbSet<Productcategorie> Productcategories { 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<categorieDiscount> categorieDiscounts { get; set; } = default!;
|
public DbSet<CategorieDiscount> categorieDiscounts { get; set; } = default!;
|
||||||
|
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
@@ -47,11 +47,11 @@ namespace Webshop.Infrastructure.Data
|
|||||||
|
|
||||||
modelBuilder.Entity<Productcategorie>().HasKey(pc => new { pc.ProductId, pc.categorieId });
|
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<categorieDiscount>().HasKey(cd => new { cd.categorieId, 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<categorie>().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,7 +99,7 @@ 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<categorie>()
|
modelBuilder.Entity<Categorie>()
|
||||||
.HasOne(c => c.Parentcategorie)
|
.HasOne(c => c.Parentcategorie)
|
||||||
.WithMany(c => c.Subcategories)
|
.WithMany(c => c.Subcategories)
|
||||||
.HasForeignKey(c => c.ParentcategorieId)
|
.HasForeignKey(c => c.ParentcategorieId)
|
||||||
|
|||||||
@@ -9,37 +9,37 @@ using Webshop.Infrastructure.Data;
|
|||||||
|
|
||||||
namespace Webshop.Infrastructure.Repositories
|
namespace Webshop.Infrastructure.Repositories
|
||||||
{
|
{
|
||||||
public class categorieRepository : IcategorieRepository
|
public class CategorieRepository : ICategorieRepository
|
||||||
{
|
{
|
||||||
private readonly ApplicationDbContext _context;
|
private readonly ApplicationDbContext _context;
|
||||||
|
|
||||||
public categorieRepository(ApplicationDbContext context)
|
public CategorieRepository(ApplicationDbContext context)
|
||||||
{
|
{
|
||||||
_context = context;
|
_context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<categorie>> GetAllAsync()
|
public async Task<IEnumerable<Categorie>> GetAllAsync()
|
||||||
{
|
{
|
||||||
return await _context.categories.ToListAsync();
|
return await _context.categories.ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<categorie?> GetByIdAsync(Guid id)
|
public async Task<Categorie?> GetByIdAsync(Guid id)
|
||||||
{
|
{
|
||||||
return await _context.categories.FindAsync(id);
|
return await _context.categories.FindAsync(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<categorie?> GetBySlugAsync(string slug)
|
public async Task<Categorie?> GetBySlugAsync(string slug)
|
||||||
{
|
{
|
||||||
return await _context.categories.FirstOrDefaultAsync(c => c.Slug == slug);
|
return await _context.categories.FirstOrDefaultAsync(c => c.Slug == slug);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task AddAsync(categorie categorie)
|
public async Task AddAsync(Categorie categorie)
|
||||||
{
|
{
|
||||||
_context.categories.Add(categorie);
|
_context.categories.Add(categorie);
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task UpdateAsync(categorie categorie)
|
public async Task UpdateAsync(Categorie categorie)
|
||||||
{
|
{
|
||||||
_context.categories.Update(categorie);
|
_context.categories.Update(categorie);
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
|
|||||||
Reference in New Issue
Block a user