Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1977b6b301 | |||
| 18d1640808 | |||
| e40c958066 | |||
| 0ab14d8b63 | |||
| 2db3b3d293 | |||
| 50eee03dbe |
@@ -5,4 +5,10 @@ public class CdnSettings
|
|||||||
public string? BaseCdn { get; set; }
|
public string? BaseCdn { get; set; }
|
||||||
|
|
||||||
public string[]? BookCovers { get; set; }
|
public string[]? BookCovers { get; set; }
|
||||||
|
|
||||||
|
public string[]? Authors { get; set; }
|
||||||
|
|
||||||
|
public string[]? AuthorThumbnails { get; set; }
|
||||||
|
|
||||||
|
public string[]? BookThumbnails { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,275 @@
|
|||||||
|
using LiteCharms.Features.MidrandBooks.Customers;
|
||||||
|
using LiteCharms.Features.MidrandBooks.Customers.Models;
|
||||||
|
using LiteCharms.Features.MidrandBooks.Orders;
|
||||||
|
using LiteCharms.Features.MidrandBooks.Orders.Models;
|
||||||
|
|
||||||
|
namespace LiteCharms.Features.MidrandBooks.Seed;
|
||||||
|
|
||||||
|
public class CustomerSeederService(CustomerService customerService, OrderService orderService, IFeatureManager features,
|
||||||
|
ILogger<CustomerSeederService> logger) : BackgroundService
|
||||||
|
{
|
||||||
|
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||||
|
{
|
||||||
|
if (!await features.IsEnabledAsync("CustomerSeederService")) return;
|
||||||
|
|
||||||
|
logger.LogInformation("Customer Seeding started");
|
||||||
|
|
||||||
|
// 1: Add shipping providers (shippingProvider IDs will be created in sequence: 1, 2, 3)
|
||||||
|
await orderService.CreateShippingProviderAsync(new CreateShippingProvider(ShippingProviderTypes.FastWay, "FastWay Couriers", 39, "https://www.fastway.co.za/our-services/track-your-parcel"), stoppingToken);
|
||||||
|
await orderService.CreateShippingProviderAsync(new CreateShippingProvider(ShippingProviderTypes.DHL, "DHL Couriers", 60, "https://www.dhl.com/za-en/home/tracking.html"), stoppingToken);
|
||||||
|
await orderService.CreateShippingProviderAsync(new CreateShippingProvider(ShippingProviderTypes.PostNet, "Postnet Overnight Mail", 45, "https://www.postnet.co.za/tracker"), stoppingToken);
|
||||||
|
|
||||||
|
// Initialize Bogus Faker engine
|
||||||
|
var faker = new Faker();
|
||||||
|
var culture = CultureInfo.InvariantCulture;
|
||||||
|
|
||||||
|
// Ensure repeatable datasets across executions
|
||||||
|
Randomizer.Seed = new Random(84);
|
||||||
|
|
||||||
|
// South African Provinces array lookup helper
|
||||||
|
var southAfricanProvinces = new[]
|
||||||
|
{
|
||||||
|
"Gauteng", "Western Cape", "KwaZulu-Natal", "Eastern Cape",
|
||||||
|
"Free State", "Limpopo", "Mpumalanga", "North West", "Northern Cape"
|
||||||
|
};
|
||||||
|
|
||||||
|
// South African major towns matching geographic boundaries roughly
|
||||||
|
var southAfricanCities = new[] { "Midrand", "Johannesburg", "Pretoria", "Cape Town", "Durban", "Gqeberha", "Polokwane", "Nelspruit", "Bloemfontein" };
|
||||||
|
|
||||||
|
// Tracks sequential Address IDs added globally to the system across all loops
|
||||||
|
long addressSequenceCounter = 0;
|
||||||
|
|
||||||
|
// 2: Create 15 customers with resources sequentially
|
||||||
|
for (int c = 0; c < 15; c++)
|
||||||
|
{
|
||||||
|
if (stoppingToken.IsCancellationRequested) break;
|
||||||
|
|
||||||
|
// Determine if this specific iteration represents a Corporate Client or an Individual Consumer
|
||||||
|
bool isCompanyCustomer = faker.Random.Bool(0.4f); // 40% chance of seeding a corporate entity
|
||||||
|
|
||||||
|
string customerFirstName = faker.Name.FirstName();
|
||||||
|
string customerLastName = faker.Name.LastName();
|
||||||
|
|
||||||
|
string companyName = isCompanyCustomer ? faker.Company.CompanyName() : "";
|
||||||
|
string companySuffix = isCompanyCustomer ? faker.Company.CompanySuffix() : "";
|
||||||
|
string fullCompanyName = isCompanyCustomer ? $"{companyName} {companySuffix}" : "";
|
||||||
|
|
||||||
|
string customerEmail = isCompanyCustomer
|
||||||
|
? faker.Internet.Email(firstName: companyName, provider: "co.za").ToLower(culture)
|
||||||
|
: faker.Internet.Email(customerFirstName, customerLastName).ToLower(culture);
|
||||||
|
|
||||||
|
string customerPhone = faker.Phone.PhoneNumber("087#######"); // Corporate VOIP / Personal South African cell line format
|
||||||
|
string customerWebsite = isCompanyCustomer ? faker.Internet.Url().Replace("www.", $"www.{companyName.ToLower(culture)}.") : "";
|
||||||
|
string customerVat = isCompanyCustomer ? faker.Phone.PhoneNumber("4#########") : ""; // SA VAT registration starts with a 4
|
||||||
|
|
||||||
|
// Randomly select distinct Social Media channels
|
||||||
|
var chosenSocialType = faker.PickRandom<SocialMediaTypes>();
|
||||||
|
string socialMediaUrl = chosenSocialType switch
|
||||||
|
{
|
||||||
|
SocialMediaTypes.LinkedIn => isCompanyCustomer ? $"https://linkedin.com/company/{companyName.ToLower(culture)}" : $"https://linkedin.com/in/{customerFirstName.ToLower(culture)}-{customerLastName.ToLower(culture)}",
|
||||||
|
SocialMediaTypes.GitHub => $"https://github.com/{(isCompanyCustomer ? "orgs/" + companyName.ToLower(culture) : customerFirstName.ToLower(culture))}",
|
||||||
|
_ => $"https://x.com/{(isCompanyCustomer ? companyName.ToLower(culture) : customerFirstName.ToLower(culture))}"
|
||||||
|
};
|
||||||
|
|
||||||
|
// 3: Create customer
|
||||||
|
var createCustomerResult = await customerService.CreateCustomerAsync(new CreateCustomer
|
||||||
|
{
|
||||||
|
Company = fullCompanyName,
|
||||||
|
Email = customerEmail,
|
||||||
|
Phone = customerPhone,
|
||||||
|
Website = customerWebsite,
|
||||||
|
SocialMedia =
|
||||||
|
[
|
||||||
|
new Models.SocialMedia
|
||||||
|
{
|
||||||
|
Name = chosenSocialType.ToString(),
|
||||||
|
Type = chosenSocialType,
|
||||||
|
ImageUrl = $"https://cdn.example.com/icons/{chosenSocialType.ToString().ToLower(culture)}.png",
|
||||||
|
Url = socialMediaUrl
|
||||||
|
}
|
||||||
|
],
|
||||||
|
VatNumber = customerVat
|
||||||
|
}, stoppingToken);
|
||||||
|
|
||||||
|
if (createCustomerResult.IsFailed)
|
||||||
|
{
|
||||||
|
logger.LogError("Failed to create customer record at index {Index}: {Error}", c, createCustomerResult.Errors[0].Message);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
var assignedCustomerId = createCustomerResult.Value;
|
||||||
|
|
||||||
|
// 4: Create customer contact (only if customer is a company entity)
|
||||||
|
if (isCompanyCustomer)
|
||||||
|
{
|
||||||
|
var contactFirstName = faker.Name.FirstName();
|
||||||
|
var contactLastName = faker.Name.LastName();
|
||||||
|
|
||||||
|
var createContactResult = await customerService.CreateCustomerContactAsync(assignedCustomerId, new CreateCustomerContact
|
||||||
|
{
|
||||||
|
Name = contactFirstName,
|
||||||
|
LastName = contactLastName,
|
||||||
|
Phone = faker.Phone.PhoneNumber("082#######"), // Typical South African mobile prefix format
|
||||||
|
Email = faker.Internet.Email(contactFirstName, contactLastName, provider: "company.co.za").ToLower(culture),
|
||||||
|
Type = ContactTypes.Business
|
||||||
|
}, stoppingToken);
|
||||||
|
|
||||||
|
if (createContactResult.IsFailed)
|
||||||
|
{
|
||||||
|
logger.LogError("Failed to create company customer contact relation: {Error}", createContactResult.Errors[0].Message);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Shared Randomizations for Regional Postal/Building details
|
||||||
|
var primaryState = faker.PickRandom(southAfricanProvinces);
|
||||||
|
var primaryCity = faker.PickRandom(southAfricanCities);
|
||||||
|
var shippingPostalCode = faker.Random.Replace("####");
|
||||||
|
|
||||||
|
var billingState = faker.PickRandom(southAfricanProvinces);
|
||||||
|
var billingCity = faker.PickRandom(southAfricanCities);
|
||||||
|
var billingPostalCode = faker.Random.Replace("####");
|
||||||
|
|
||||||
|
// 5: Create customer address - SHIPPING
|
||||||
|
var createShippingAddressResult = await customerService.CreateCustomerAddressAsync(assignedCustomerId, new CreateCustomerAddress
|
||||||
|
{
|
||||||
|
Name = isCompanyCustomer ? "Head Office Distribution" : "My Home Residence",
|
||||||
|
BuildingType = faker.PickRandom<AddressBuildingTypes>(),
|
||||||
|
Type = AddressType.Shipping,
|
||||||
|
Street = $"{faker.Address.BuildingNumber()} {faker.Address.StreetName()} Street",
|
||||||
|
City = primaryCity,
|
||||||
|
State = primaryState,
|
||||||
|
Country = "South Africa",
|
||||||
|
IsPrimary = true,
|
||||||
|
Enabled = true,
|
||||||
|
PostalCode = shippingPostalCode
|
||||||
|
}, stoppingToken);
|
||||||
|
|
||||||
|
long currentCustomerShippingAddressId = 0;
|
||||||
|
if (createShippingAddressResult.IsSuccess)
|
||||||
|
{
|
||||||
|
addressSequenceCounter++;
|
||||||
|
currentCustomerShippingAddressId = addressSequenceCounter;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
logger.LogWarning("Failed to attach Shipping address profile: {Error}", createShippingAddressResult.Errors[0].Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 6: Create customer address - BILLING
|
||||||
|
var createBillingAddressResult = await customerService.CreateCustomerAddressAsync(assignedCustomerId, new CreateCustomerAddress
|
||||||
|
{
|
||||||
|
Name = isCompanyCustomer ? "Accounts Payable Department" : "Billing Address",
|
||||||
|
BuildingType = faker.PickRandom<AddressBuildingTypes>(),
|
||||||
|
Type = AddressType.Billing,
|
||||||
|
Street = isCompanyCustomer ? $"{faker.Address.BuildingNumber()} {faker.Address.StreetName()} Boulevard" : $"{faker.Address.BuildingNumber()} {faker.Address.StreetName()} Street",
|
||||||
|
City = billingCity,
|
||||||
|
State = billingState,
|
||||||
|
Country = "South Africa",
|
||||||
|
IsPrimary = false,
|
||||||
|
Enabled = true,
|
||||||
|
PostalCode = billingPostalCode
|
||||||
|
}, stoppingToken);
|
||||||
|
|
||||||
|
long currentCustomerBillingAddressId = 0;
|
||||||
|
if (createBillingAddressResult.IsSuccess)
|
||||||
|
{
|
||||||
|
addressSequenceCounter++;
|
||||||
|
currentCustomerBillingAddressId = addressSequenceCounter;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
logger.LogError("Failed to attach Billing address profile: {Error}", createBillingAddressResult.Errors[0].Message);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 7: Challenge Extrapolation — Create a random number of orders (0 to 4 orders) per customer
|
||||||
|
int ordersToGenerate = faker.Random.Number(0, 4);
|
||||||
|
for (int o = 0; o < ordersToGenerate; o++)
|
||||||
|
{
|
||||||
|
var deliveryInstructions = faker.PickRandom(
|
||||||
|
"Leave at reception desk",
|
||||||
|
"Please call before delivery",
|
||||||
|
"At the intercom, dial 1 then option 2",
|
||||||
|
"Leave with security guard at front gate",
|
||||||
|
"Deliver to back delivery bay"
|
||||||
|
);
|
||||||
|
|
||||||
|
// Use the calculated sequential Billing Address Id for order creation
|
||||||
|
var orderResult = await orderService.CreateOrderAsync(
|
||||||
|
assignedCustomerId,
|
||||||
|
new CreateOrder(currentCustomerBillingAddressId, deliveryInstructions),
|
||||||
|
stoppingToken
|
||||||
|
);
|
||||||
|
|
||||||
|
if (orderResult.IsFailed)
|
||||||
|
{
|
||||||
|
logger.LogWarning("Failed to create purchase order shell context: {Error}", orderResult.Errors[0].Message);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
long seededOrderId = orderResult.Value;
|
||||||
|
|
||||||
|
// Build a varying array of items using valid product bounds (IDs: 0 to 21)
|
||||||
|
int lineItemsCount = faker.Random.Number(1, 5);
|
||||||
|
var itemsList = new List<CreateOrderItem>();
|
||||||
|
|
||||||
|
for (int i = 0; i < lineItemsCount; i++)
|
||||||
|
{
|
||||||
|
long randomProductId = faker.Random.Number(0, 21);
|
||||||
|
long randomProductPriceId = faker.Random.Number(0, 21);
|
||||||
|
int itemQuantity = faker.Random.Number(1, 3);
|
||||||
|
|
||||||
|
itemsList.Add(new CreateOrderItem(randomProductId, randomProductPriceId, itemQuantity));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Push bulk items payload into order via matching test framework signatures
|
||||||
|
var addItemsResult = await orderService.AddItemsToOrderAsync(seededOrderId, [.. itemsList], stoppingToken);
|
||||||
|
if (addItemsResult.IsFailed)
|
||||||
|
{
|
||||||
|
logger.LogWarning("Failed to link item collections to Order Id {Id}", seededOrderId);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Randomly select an order status matrix pathing
|
||||||
|
var targetedOrderStatus = faker.PickRandom<OrderStatus>();
|
||||||
|
await orderService.UpdateOrderStatusAsync(seededOrderId, targetedOrderStatus, stoppingToken);
|
||||||
|
|
||||||
|
// Check lifecycle workflow criteria: Attach dynamic shipping if status warrants it
|
||||||
|
if (targetedOrderStatus != OrderStatus.Pending &&
|
||||||
|
targetedOrderStatus != OrderStatus.Cancelled &&
|
||||||
|
targetedOrderStatus != OrderStatus.Failed &&
|
||||||
|
currentCustomerShippingAddressId > 0)
|
||||||
|
{
|
||||||
|
// Select from seeded Shipping Providers in step 1 (IDs: 1, 2, or 3)
|
||||||
|
long randomShippingProviderId = faker.Random.Number(1, 3);
|
||||||
|
|
||||||
|
var addShippingResult = await orderService.AddShippingToOrderAsync(
|
||||||
|
seededOrderId,
|
||||||
|
new CreateShipping(currentCustomerShippingAddressId, randomShippingProviderId),
|
||||||
|
stoppingToken
|
||||||
|
);
|
||||||
|
|
||||||
|
if (addShippingResult.IsSuccess)
|
||||||
|
{
|
||||||
|
long assignedShippingId = addShippingResult.Value;
|
||||||
|
|
||||||
|
// Transition logistics flags matching delivery metrics
|
||||||
|
var shippingStatus = faker.PickRandom<ShippingStatuses>();
|
||||||
|
await orderService.UpdateShippingStatusAsync(seededOrderId, shippingStatus, stoppingToken);
|
||||||
|
|
||||||
|
if (shippingStatus == ShippingStatuses.Shipped || shippingStatus == ShippingStatuses.Delivered)
|
||||||
|
{
|
||||||
|
string rawTrackingCode = $"ZA{faker.Random.Replace("#########")}NV";
|
||||||
|
await orderService.UpdateShippingTrackingNumberAsync(seededOrderId, assignedShippingId, rawTrackingCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.LogInformation("Successfully seeded customer profile #{Index}: {Name} alongside {Count} orders.", c, isCompanyCustomer ? fullCompanyName : $"{customerFirstName} {customerLastName}", ordersToGenerate);
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.LogInformation("Customer Seeding completed successfully.");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,10 +11,11 @@
|
|||||||
<!-- Quartz Scheduler-->
|
<!-- Quartz Scheduler-->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Bogus" Version="35.6.5" />
|
<PackageReference Include="Bogus" Version="35.6.5" />
|
||||||
<PackageReference Include="Meziantou.Analyzer" Version="3.0.96">
|
<PackageReference Include="Meziantou.Analyzer" Version="3.0.98">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.FeatureManagement.AspNetCore" Version="4.5.0" />
|
||||||
<PackageReference Include="OpenTelemetry" Version="1.15.3" />
|
<PackageReference Include="OpenTelemetry" Version="1.15.3" />
|
||||||
<PackageReference Include="Quartz" Version="3.18.1" />
|
<PackageReference Include="Quartz" Version="3.18.1" />
|
||||||
<PackageReference Include="Quartz.Plugins" Version="3.18.1" />
|
<PackageReference Include="Quartz.Plugins" Version="3.18.1" />
|
||||||
@@ -84,7 +85,7 @@
|
|||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.0.1" />
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.0.2" />
|
||||||
|
|
||||||
<!-- Global Usings -->
|
<!-- Global Usings -->
|
||||||
<Using Include="Npgsql" />
|
<Using Include="Npgsql" />
|
||||||
@@ -95,8 +96,8 @@
|
|||||||
|
|
||||||
<!-- Email -->
|
<!-- Email -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="MailKit" Version="4.16.0" />
|
<PackageReference Include="MailKit" Version="4.17.0" />
|
||||||
<PackageReference Include="MimeKit" Version="4.16.0" />
|
<PackageReference Include="MimeKit" Version="4.17.0" />
|
||||||
|
|
||||||
<!-- Global Usings-->
|
<!-- Global Usings-->
|
||||||
<Using Include="MimeKit" />
|
<Using Include="MimeKit" />
|
||||||
@@ -128,6 +129,7 @@
|
|||||||
<!-- Shared Usings -->
|
<!-- Shared Usings -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Using Include="Bogus" />
|
<Using Include="Bogus" />
|
||||||
|
<Using Include="Microsoft.FeatureManagement" />
|
||||||
<Using Include="System.Globalization" />
|
<Using Include="System.Globalization" />
|
||||||
<Using Include="System.Reflection" />
|
<Using Include="System.Reflection" />
|
||||||
<Using Include="Microsoft.AspNetCore.Builder" />
|
<Using Include="Microsoft.AspNetCore.Builder" />
|
||||||
|
|||||||
@@ -6,12 +6,14 @@ using LiteCharms.Features.MidrandBooks.Seed.Configuration;
|
|||||||
namespace LiteCharms.Features.MidrandBooks.Seed;
|
namespace LiteCharms.Features.MidrandBooks.Seed;
|
||||||
|
|
||||||
public class ProductsSeederService(ProductService productService, AuthorService authorService, BooksService booksService,
|
public class ProductsSeederService(ProductService productService, AuthorService authorService, BooksService booksService,
|
||||||
IOptions<CdnSettings> options, ILogger<ProductsSeederService> logger) : BackgroundService
|
IFeatureManager features, IOptions<CdnSettings> options, ILogger<ProductsSeederService> logger) : BackgroundService
|
||||||
{
|
{
|
||||||
private readonly CdnSettings cdnSettings = options.Value;
|
private readonly CdnSettings cdnSettings = options.Value;
|
||||||
|
|
||||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||||
{
|
{
|
||||||
|
if (await features.IsEnabledAsync("ProductsSeederService") is not true) return;
|
||||||
|
|
||||||
logger.LogInformation("Product Seeding started");
|
logger.LogInformation("Product Seeding started");
|
||||||
|
|
||||||
if (cdnSettings.BookCovers is null || cdnSettings.BookCovers.Length == 0)
|
if (cdnSettings.BookCovers is null || cdnSettings.BookCovers.Length == 0)
|
||||||
@@ -65,8 +67,19 @@ public class ProductsSeederService(ProductService productService, AuthorService
|
|||||||
"Unlocking Creative Flow Under Pressure"
|
"Unlocking Creative Flow Under Pressure"
|
||||||
);
|
);
|
||||||
|
|
||||||
// Defensive Length Processing to avoid Entity Framework / Postgres string truncation crashes
|
// Dynamic raw title generation formulas executed via random function picker
|
||||||
var rawTitle = $"{faker.Company.CatchPhrase()} with {bookTopic}";
|
var titlePatterns = new Func<string>[]
|
||||||
|
{
|
||||||
|
() => $"{faker.Company.CatchPhrase()} with {bookTopic}",
|
||||||
|
() => $"The {faker.Commerce.ProductAdjective()} Guide to {bookTopic}",
|
||||||
|
() => $"Mastering {bookTopic}: A {faker.Company.Bs()} Blueprint",
|
||||||
|
() => $"{bookTopic} for the Modern {faker.Name.JobTitle()}",
|
||||||
|
() => $"Advanced {bookTopic}: Demystifying the {faker.Company.CatchPhrase()}",
|
||||||
|
() => $"{faker.Random.Replace("###")} Blueprints for {bookTopic}"
|
||||||
|
};
|
||||||
|
|
||||||
|
// Pick a format template and resolve it down to raw string text
|
||||||
|
var rawTitle = faker.PickRandom(titlePatterns)();
|
||||||
var bookTitle = rawTitle.Length > 255 ? rawTitle[..252] + "..." : rawTitle;
|
var bookTitle = rawTitle.Length > 255 ? rawTitle[..252] + "..." : rawTitle;
|
||||||
|
|
||||||
var rawSummary = $"A comprehensive guide to mastering {bookTopic}. Learn modern implementation techniques through real-world software engineering paradigms.";
|
var rawSummary = $"A comprehensive guide to mastering {bookTopic}. Learn modern implementation techniques through real-world software engineering paradigms.";
|
||||||
@@ -80,6 +93,21 @@ public class ProductsSeederService(ProductService productService, AuthorService
|
|||||||
var authorLastName = faker.Name.LastName();
|
var authorLastName = faker.Name.LastName();
|
||||||
var publisherCompany = faker.Company.CompanyName();
|
var publisherCompany = faker.Company.CompanyName();
|
||||||
|
|
||||||
|
// Safe bounded random picking for book thumbnails
|
||||||
|
string? pickedBookThumbnail = null;
|
||||||
|
string? pickedBookThumbnail1 = null;
|
||||||
|
string? pickedBookThumbnail2 = null;
|
||||||
|
string? pickedBookThumbnail3 = null;
|
||||||
|
string? pickedBookThumbnail4 = null;
|
||||||
|
if (cdnSettings.BookThumbnails is not null && cdnSettings.BookThumbnails.Length > 0)
|
||||||
|
{
|
||||||
|
pickedBookThumbnail = $"{cdnSettings.BaseCdn}{faker.PickRandom(cdnSettings.BookThumbnails)}";
|
||||||
|
pickedBookThumbnail1 = $"{cdnSettings.BaseCdn}{faker.PickRandom(cdnSettings.BookThumbnails)}";
|
||||||
|
pickedBookThumbnail2 = $"{cdnSettings.BaseCdn}{faker.PickRandom(cdnSettings.BookThumbnails)}";
|
||||||
|
pickedBookThumbnail3 = $"{cdnSettings.BaseCdn}{faker.PickRandom(cdnSettings.BookThumbnails)}";
|
||||||
|
pickedBookThumbnail4 = $"{cdnSettings.BaseCdn}{faker.PickRandom(cdnSettings.BookThumbnails)}";
|
||||||
|
}
|
||||||
|
|
||||||
// Step 1: Add Product
|
// Step 1: Add Product
|
||||||
var productCreateResult = await productService.CreateProductAsync(new Products.Models.CreateProduct
|
var productCreateResult = await productService.CreateProductAsync(new Products.Models.CreateProduct
|
||||||
{
|
{
|
||||||
@@ -95,7 +123,8 @@ public class ProductsSeederService(ProductService productService, AuthorService
|
|||||||
Manufacturer = $"{authorFirstName} {authorLastName} / {publisherCompany}",
|
Manufacturer = $"{authorFirstName} {authorLastName} / {publisherCompany}",
|
||||||
SerialNumber = faker.Phone.PhoneNumber("978-##########")
|
SerialNumber = faker.Phone.PhoneNumber("978-##########")
|
||||||
},
|
},
|
||||||
Categories = ["Coding", "Computers", "IT"]
|
Categories = ["Coding", "Computers", "IT"],
|
||||||
|
ThumbnailUrls = pickedBookThumbnail is not null ? [pickedBookThumbnail, pickedBookThumbnail1!, pickedBookThumbnail2!, pickedBookThumbnail3!, pickedBookThumbnail4!] : null
|
||||||
}, stoppingToken);
|
}, stoppingToken);
|
||||||
|
|
||||||
if (productCreateResult.IsFailed)
|
if (productCreateResult.IsFailed)
|
||||||
@@ -116,7 +145,6 @@ public class ProductsSeederService(ProductService productService, AuthorService
|
|||||||
// Step 3: Create Product Price
|
// Step 3: Create Product Price
|
||||||
var productPriceCreateResult = await productService.CreateProductPriceAsync(productId: productCreateResult.Value, request: new Products.Models.CreateProductPrice
|
var productPriceCreateResult = await productService.CreateProductPriceAsync(productId: productCreateResult.Value, request: new Products.Models.CreateProductPrice
|
||||||
{
|
{
|
||||||
// Generates fair, dynamic prices in Rands between R150 and R650, snapped neatly to integers
|
|
||||||
Amount = Math.Round(faker.Random.Decimal(150m, 650m), 2),
|
Amount = Math.Round(faker.Random.Decimal(150m, 650m), 2),
|
||||||
Discount = 0.0m
|
Discount = 0.0m
|
||||||
}, stoppingToken);
|
}, stoppingToken);
|
||||||
@@ -127,6 +155,34 @@ public class ProductsSeederService(ProductService productService, AuthorService
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Safe bounded picking for Authors (Real Avatars)
|
||||||
|
string authorAvatarUrl = faker.Internet.Avatar(); // Fallback
|
||||||
|
if (cdnSettings.Authors is not null && cdnSettings.Authors.Length > 0)
|
||||||
|
{
|
||||||
|
authorAvatarUrl = $"{cdnSettings.BaseCdn}{faker.PickRandom(cdnSettings.Authors)}";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Safe bounded picking for Author Thumbnails (Cartoon Avatars)
|
||||||
|
string? authorThumbnailUrl = null;
|
||||||
|
if (cdnSettings.AuthorThumbnails is not null && cdnSettings.AuthorThumbnails.Length > 0)
|
||||||
|
{
|
||||||
|
var selectedThumb = faker.PickRandom(cdnSettings.AuthorThumbnails);
|
||||||
|
authorThumbnailUrl = $"{cdnSettings.BaseCdn}{selectedThumb}.jpg";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Synthesize a highly dynamic, organic opening bio statement
|
||||||
|
var professionalBackgrounds = new[]
|
||||||
|
{
|
||||||
|
$"{authorFirstName} {authorLastName} is an award-winning {faker.Name.JobDescriptor()} {faker.Name.JobTitle()} with over {faker.Random.Number(5, 25)} years of core engineering domain expertise.",
|
||||||
|
$"As a veteran systems consultant and practicing {faker.Name.JobTitle()}, {authorFirstName} has spent decades leading digital infrastructure transformations and managing complex topologies.",
|
||||||
|
$"Operating from modern innovation hubs, {authorFirstName} {authorLastName} specializes in global product strategies and serves as an authority in {faker.Name.JobDescriptor()} computing.",
|
||||||
|
$"With a rich professional background as a principal {faker.Name.JobTitle()} at {publisherCompany}, {authorFirstName} has spent a lifetime refining the system workflows highlighted here."
|
||||||
|
};
|
||||||
|
|
||||||
|
// Pick a randomized context hook and append a 2-paragraph contextual narrative block
|
||||||
|
var biographyPrefix = faker.PickRandom(professionalBackgrounds);
|
||||||
|
var authorBiography = $"{biographyPrefix} {faker.Lorem.Paragraph(2)}";
|
||||||
|
|
||||||
// Step 4: Create Author
|
// Step 4: Create Author
|
||||||
var authorCreateResult = await authorService.CreateAuthorAsync(request: new Authors.Models.CreateAuthor
|
var authorCreateResult = await authorService.CreateAuthorAsync(request: new Authors.Models.CreateAuthor
|
||||||
{
|
{
|
||||||
@@ -137,7 +193,7 @@ public class ProductsSeederService(ProductService productService, AuthorService
|
|||||||
PublisherType = faker.PickRandom<PublisherTypes>(),
|
PublisherType = faker.PickRandom<PublisherTypes>(),
|
||||||
Email = faker.Internet.Email(authorFirstName, authorLastName),
|
Email = faker.Internet.Email(authorFirstName, authorLastName),
|
||||||
Website = faker.Internet.Url(),
|
Website = faker.Internet.Url(),
|
||||||
ImageUrl = faker.Internet.Avatar(),
|
ImageUrl = authorAvatarUrl,
|
||||||
SocialMedia =
|
SocialMedia =
|
||||||
[
|
[
|
||||||
new Models.SocialMedia
|
new Models.SocialMedia
|
||||||
@@ -155,8 +211,8 @@ public class ProductsSeederService(ProductService productService, AuthorService
|
|||||||
Url = $"https://github.com/tech-{authorFirstName.ToLower(culture)}"
|
Url = $"https://github.com/tech-{authorFirstName.ToLower(culture)}"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
Biography = $"{authorFirstName} {authorLastName} is a veteran technologist and systems architect with over a decade of domain expertise. " + faker.Lorem.Paragraph(2),
|
Biography = authorBiography,
|
||||||
ThumbnailImageUrl = null
|
ThumbnailImageUrl = authorThumbnailUrl
|
||||||
}, stoppingToken);
|
}, stoppingToken);
|
||||||
|
|
||||||
if (authorCreateResult.IsFailed)
|
if (authorCreateResult.IsFailed)
|
||||||
|
|||||||
@@ -5,13 +5,18 @@ using LiteCharms.Features.MidrandBooks.Seed.Configuration;
|
|||||||
var builder = Host.CreateApplicationBuilder(args);
|
var builder = Host.CreateApplicationBuilder(args);
|
||||||
|
|
||||||
builder.Configuration
|
builder.Configuration
|
||||||
.AddJsonFile("appsettings.json")
|
.AddCommandLine(args)
|
||||||
.AddUserSecrets(typeof(Program).Assembly);
|
.AddUserSecrets(typeof(Program).Assembly)
|
||||||
|
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
|
||||||
|
.AddEnvironmentVariables();
|
||||||
|
|
||||||
|
builder.Services.AddScopedFeatureManagement();
|
||||||
|
|
||||||
builder.Services
|
builder.Services
|
||||||
.AddLogging()
|
.AddLogging()
|
||||||
.AddShopServices()
|
.AddShopServices()
|
||||||
.AddHostedService<ProductsSeederService>()
|
.AddHostedService<ProductsSeederService>()
|
||||||
|
.AddHostedService<CustomerSeederService>()
|
||||||
.AddMidrandShopDatabase(builder.Configuration);
|
.AddMidrandShopDatabase(builder.Configuration);
|
||||||
|
|
||||||
builder.Services.Configure<CdnSettings>(options => builder.Configuration.GetSection(nameof(CdnSettings)).Bind(options));
|
builder.Services.Configure<CdnSettings>(options => builder.Configuration.GetSection(nameof(CdnSettings)).Bind(options));
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
{
|
{
|
||||||
|
"FeatureManagement": {
|
||||||
|
"CustomerSeederService": false,
|
||||||
|
"ProductsSeederService": false
|
||||||
|
},
|
||||||
"CdnSettings": {
|
"CdnSettings": {
|
||||||
"BaseCdn": "https://bookshop.cdn.khongisa.co.za/design/",
|
"BaseCdn": "https://bookshop.cdn.khongisa.co.za/design/",
|
||||||
"BookCovers": [
|
"BookCovers": [
|
||||||
@@ -23,6 +27,239 @@
|
|||||||
"d44a3c04-f124-4f0b-8301-3841ae2fd439_1764780121224.webp",
|
"d44a3c04-f124-4f0b-8301-3841ae2fd439_1764780121224.webp",
|
||||||
"e6ba52f208914285bcdf1966cfb08f6f.jpg",
|
"e6ba52f208914285bcdf1966cfb08f6f.jpg",
|
||||||
"fa9cbbe6-f947-4f83-8e98-61d2661f43e0_1764841636705.webp"
|
"fa9cbbe6-f947-4f83-8e98-61d2661f43e0_1764841636705.webp"
|
||||||
|
],
|
||||||
|
"Authors": [
|
||||||
|
"authors/uifaces-human-avatar.jpg",
|
||||||
|
"authors/uifaces-human-avatar-1.jpg",
|
||||||
|
"authors/uifaces-human-avatar-2.jpg",
|
||||||
|
"authors/uifaces-human-avatar-3.jpg",
|
||||||
|
"authors/uifaces-human-avatar-4.jpg",
|
||||||
|
"authors/uifaces-human-avatar-5.jpg",
|
||||||
|
"authors/uifaces-human-avatar-6.jpg",
|
||||||
|
"authors/uifaces-human-avatar-7.jpg",
|
||||||
|
"authors/uifaces-human-avatar-8.jpg",
|
||||||
|
"authors/uifaces-human-avatar-9.jpg",
|
||||||
|
"authors/uifaces-human-avatar-10.jpg",
|
||||||
|
"authors/uifaces-human-avatar-11.jpg",
|
||||||
|
"authors/uifaces-human-avatar-12.jpg",
|
||||||
|
"authors/uifaces-human-avatar-13.jpg",
|
||||||
|
"authors/uifaces-human-avatar-14.jpg",
|
||||||
|
"authors/uifaces-human-avatar-15.jpg",
|
||||||
|
"authors/uifaces-human-avatar-16.jpg"
|
||||||
|
],
|
||||||
|
"AuthorThumbnails": [
|
||||||
|
"authors/thumbnails/uifaces-cartoon-avatar-1",
|
||||||
|
"authors/thumbnails/uifaces-cartoon-avatar-2",
|
||||||
|
"authors/thumbnails/uifaces-cartoon-avatar-3",
|
||||||
|
"authors/thumbnails/uifaces-cartoon-avatar-4",
|
||||||
|
"authors/thumbnails/uifaces-cartoon-avatar-5",
|
||||||
|
"authors/thumbnails/uifaces-cartoon-avatar-6",
|
||||||
|
"authors/thumbnails/uifaces-cartoon-avatar-7",
|
||||||
|
"authors/thumbnails/uifaces-cartoon-avatar-8",
|
||||||
|
"authors/thumbnails/uifaces-cartoon-avatar-9",
|
||||||
|
"authors/thumbnails/uifaces-cartoon-avatar-10"
|
||||||
|
],
|
||||||
|
"BookThumbnails": [
|
||||||
|
"thumbnails/book_thumbnail_001.jpg",
|
||||||
|
"thumbnails/book_thumbnail_002.jpg",
|
||||||
|
"thumbnails/book_thumbnail_003.jpg",
|
||||||
|
"thumbnails/book_thumbnail_004.jpg",
|
||||||
|
"thumbnails/book_thumbnail_005.jpg",
|
||||||
|
"thumbnails/book_thumbnail_006.jpg",
|
||||||
|
"thumbnails/book_thumbnail_007.jpg",
|
||||||
|
"thumbnails/book_thumbnail_008.jpg",
|
||||||
|
"thumbnails/book_thumbnail_009.jpg",
|
||||||
|
"thumbnails/book_thumbnail_010.jpg",
|
||||||
|
"thumbnails/book_thumbnail_011.jpg",
|
||||||
|
"thumbnails/book_thumbnail_012.jpg",
|
||||||
|
"thumbnails/book_thumbnail_013.jpg",
|
||||||
|
"thumbnails/book_thumbnail_014.jpg",
|
||||||
|
"thumbnails/book_thumbnail_015.jpg",
|
||||||
|
"thumbnails/book_thumbnail_016.jpg",
|
||||||
|
"thumbnails/book_thumbnail_017.jpg",
|
||||||
|
"thumbnails/book_thumbnail_018.jpg",
|
||||||
|
"thumbnails/book_thumbnail_019.jpg",
|
||||||
|
"thumbnails/book_thumbnail_020.jpg",
|
||||||
|
"thumbnails/book_thumbnail_021.jpg",
|
||||||
|
"thumbnails/book_thumbnail_022.jpg",
|
||||||
|
"thumbnails/book_thumbnail_023.jpg",
|
||||||
|
"thumbnails/book_thumbnail_024.jpg",
|
||||||
|
"thumbnails/book_thumbnail_025.jpg",
|
||||||
|
"thumbnails/book_thumbnail_026.jpg",
|
||||||
|
"thumbnails/book_thumbnail_027.jpg",
|
||||||
|
"thumbnails/book_thumbnail_028.jpg",
|
||||||
|
"thumbnails/book_thumbnail_029.jpg",
|
||||||
|
"thumbnails/book_thumbnail_030.jpg",
|
||||||
|
"thumbnails/book_thumbnail_031.jpg",
|
||||||
|
"thumbnails/book_thumbnail_032.jpg",
|
||||||
|
"thumbnails/book_thumbnail_033.jpg",
|
||||||
|
"thumbnails/book_thumbnail_034.jpg",
|
||||||
|
"thumbnails/book_thumbnail_035.jpg",
|
||||||
|
"thumbnails/book_thumbnail_036.jpg",
|
||||||
|
"thumbnails/book_thumbnail_037.jpg",
|
||||||
|
"thumbnails/book_thumbnail_038.jpg",
|
||||||
|
"thumbnails/book_thumbnail_039.jpg",
|
||||||
|
"thumbnails/book_thumbnail_040.jpg",
|
||||||
|
"thumbnails/book_thumbnail_041.jpg",
|
||||||
|
"thumbnails/book_thumbnail_042.jpg",
|
||||||
|
"thumbnails/book_thumbnail_043.jpg",
|
||||||
|
"thumbnails/book_thumbnail_044.jpg",
|
||||||
|
"thumbnails/book_thumbnail_045.jpg",
|
||||||
|
"thumbnails/book_thumbnail_046.jpg",
|
||||||
|
"thumbnails/book_thumbnail_047.jpg",
|
||||||
|
"thumbnails/book_thumbnail_048.jpg",
|
||||||
|
"thumbnails/book_thumbnail_049.jpg",
|
||||||
|
"thumbnails/book_thumbnail_050.jpg",
|
||||||
|
"thumbnails/book_thumbnail_051.jpg",
|
||||||
|
"thumbnails/book_thumbnail_052.jpg",
|
||||||
|
"thumbnails/book_thumbnail_053.jpg",
|
||||||
|
"thumbnails/book_thumbnail_054.jpg",
|
||||||
|
"thumbnails/book_thumbnail_055.jpg",
|
||||||
|
"thumbnails/book_thumbnail_056.jpg",
|
||||||
|
"thumbnails/book_thumbnail_057.jpg",
|
||||||
|
"thumbnails/book_thumbnail_058.jpg",
|
||||||
|
"thumbnails/book_thumbnail_059.jpg",
|
||||||
|
"thumbnails/book_thumbnail_060.jpg",
|
||||||
|
"thumbnails/book_thumbnail_061.jpg",
|
||||||
|
"thumbnails/book_thumbnail_062.jpg",
|
||||||
|
"thumbnails/book_thumbnail_063.jpg",
|
||||||
|
"thumbnails/book_thumbnail_064.jpg",
|
||||||
|
"thumbnails/book_thumbnail_065.jpg",
|
||||||
|
"thumbnails/book_thumbnail_066.jpg",
|
||||||
|
"thumbnails/book_thumbnail_067.jpg",
|
||||||
|
"thumbnails/book_thumbnail_068.jpg",
|
||||||
|
"thumbnails/book_thumbnail_069.jpg",
|
||||||
|
"thumbnails/book_thumbnail_070.jpg",
|
||||||
|
"thumbnails/book_thumbnail_071.jpg",
|
||||||
|
"thumbnails/book_thumbnail_072.jpg",
|
||||||
|
"thumbnails/book_thumbnail_073.jpg",
|
||||||
|
"thumbnails/book_thumbnail_074.jpg",
|
||||||
|
"thumbnails/book_thumbnail_075.jpg",
|
||||||
|
"thumbnails/book_thumbnail_076.jpg",
|
||||||
|
"thumbnails/book_thumbnail_077.jpg",
|
||||||
|
"thumbnails/book_thumbnail_078.jpg",
|
||||||
|
"thumbnails/book_thumbnail_079.jpg",
|
||||||
|
"thumbnails/book_thumbnail_080.jpg",
|
||||||
|
"thumbnails/book_thumbnail_081.jpg",
|
||||||
|
"thumbnails/book_thumbnail_082.jpg",
|
||||||
|
"thumbnails/book_thumbnail_083.jpg",
|
||||||
|
"thumbnails/book_thumbnail_084.jpg",
|
||||||
|
"thumbnails/book_thumbnail_085.jpg",
|
||||||
|
"thumbnails/book_thumbnail_086.jpg",
|
||||||
|
"thumbnails/book_thumbnail_087.jpg",
|
||||||
|
"thumbnails/book_thumbnail_088.jpg",
|
||||||
|
"thumbnails/book_thumbnail_089.jpg",
|
||||||
|
"thumbnails/book_thumbnail_090.jpg",
|
||||||
|
"thumbnails/book_thumbnail_091.jpg",
|
||||||
|
"thumbnails/book_thumbnail_092.jpg",
|
||||||
|
"thumbnails/book_thumbnail_093.jpg",
|
||||||
|
"thumbnails/book_thumbnail_094.jpg",
|
||||||
|
"thumbnails/book_thumbnail_095.jpg",
|
||||||
|
"thumbnails/book_thumbnail_096.jpg",
|
||||||
|
"thumbnails/book_thumbnail_097.jpg",
|
||||||
|
"thumbnails/book_thumbnail_098.jpg",
|
||||||
|
"thumbnails/book_thumbnail_099.jpg",
|
||||||
|
"thumbnails/book_thumbnail_100.jpg",
|
||||||
|
"thumbnails/book_thumbnail_101.jpg",
|
||||||
|
"thumbnails/book_thumbnail_102.jpg",
|
||||||
|
"thumbnails/book_thumbnail_103.jpg",
|
||||||
|
"thumbnails/book_thumbnail_104.jpg",
|
||||||
|
"thumbnails/book_thumbnail_105.jpg",
|
||||||
|
"thumbnails/book_thumbnail_106.jpg",
|
||||||
|
"thumbnails/book_thumbnail_107.jpg",
|
||||||
|
"thumbnails/book_thumbnail_108.jpg",
|
||||||
|
"thumbnails/book_thumbnail_109.jpg",
|
||||||
|
"thumbnails/book_thumbnail_110.jpg",
|
||||||
|
"thumbnails/book_thumbnail_111.jpg",
|
||||||
|
"thumbnails/book_thumbnail_112.jpg",
|
||||||
|
"thumbnails/book_thumbnail_113.jpg",
|
||||||
|
"thumbnails/book_thumbnail_114.jpg",
|
||||||
|
"thumbnails/book_thumbnail_115.jpg",
|
||||||
|
"thumbnails/book_thumbnail_116.jpg",
|
||||||
|
"thumbnails/book_thumbnail_117.jpg",
|
||||||
|
"thumbnails/book_thumbnail_118.jpg",
|
||||||
|
"thumbnails/book_thumbnail_119.jpg",
|
||||||
|
"thumbnails/book_thumbnail_120.jpg",
|
||||||
|
"thumbnails/book_thumbnail_121.jpg",
|
||||||
|
"thumbnails/book_thumbnail_122.jpg",
|
||||||
|
"thumbnails/book_thumbnail_123.jpg",
|
||||||
|
"thumbnails/book_thumbnail_124.jpg",
|
||||||
|
"thumbnails/book_thumbnail_125.jpg",
|
||||||
|
"thumbnails/book_thumbnail_126.jpg",
|
||||||
|
"thumbnails/book_thumbnail_127.jpg",
|
||||||
|
"thumbnails/book_thumbnail_128.jpg",
|
||||||
|
"thumbnails/book_thumbnail_129.jpg",
|
||||||
|
"thumbnails/book_thumbnail_130.jpg",
|
||||||
|
"thumbnails/book_thumbnail_131.jpg",
|
||||||
|
"thumbnails/book_thumbnail_132.jpg",
|
||||||
|
"thumbnails/book_thumbnail_133.jpg",
|
||||||
|
"thumbnails/book_thumbnail_134.jpg",
|
||||||
|
"thumbnails/book_thumbnail_135.jpg",
|
||||||
|
"thumbnails/book_thumbnail_136.jpg",
|
||||||
|
"thumbnails/book_thumbnail_137.jpg",
|
||||||
|
"thumbnails/book_thumbnail_138.jpg",
|
||||||
|
"thumbnails/book_thumbnail_139.jpg",
|
||||||
|
"thumbnails/book_thumbnail_140.jpg",
|
||||||
|
"thumbnails/book_thumbnail_141.jpg",
|
||||||
|
"thumbnails/book_thumbnail_142.jpg",
|
||||||
|
"thumbnails/book_thumbnail_143.jpg",
|
||||||
|
"thumbnails/book_thumbnail_144.jpg",
|
||||||
|
"thumbnails/book_thumbnail_145.jpg",
|
||||||
|
"thumbnails/book_thumbnail_146.jpg",
|
||||||
|
"thumbnails/book_thumbnail_147.jpg",
|
||||||
|
"thumbnails/book_thumbnail_148.jpg",
|
||||||
|
"thumbnails/book_thumbnail_149.jpg",
|
||||||
|
"thumbnails/book_thumbnail_150.jpg",
|
||||||
|
"thumbnails/book_thumbnail_151.jpg",
|
||||||
|
"thumbnails/book_thumbnail_152.jpg",
|
||||||
|
"thumbnails/book_thumbnail_153.jpg",
|
||||||
|
"thumbnails/book_thumbnail_154.jpg",
|
||||||
|
"thumbnails/book_thumbnail_155.jpg",
|
||||||
|
"thumbnails/book_thumbnail_156.jpg",
|
||||||
|
"thumbnails/book_thumbnail_157.jpg",
|
||||||
|
"thumbnails/book_thumbnail_158.jpg",
|
||||||
|
"thumbnails/book_thumbnail_159.jpg",
|
||||||
|
"thumbnails/book_thumbnail_160.jpg",
|
||||||
|
"thumbnails/book_thumbnail_161.jpg",
|
||||||
|
"thumbnails/book_thumbnail_162.jpg",
|
||||||
|
"thumbnails/book_thumbnail_163.jpg",
|
||||||
|
"thumbnails/book_thumbnail_164.jpg",
|
||||||
|
"thumbnails/book_thumbnail_165.jpg",
|
||||||
|
"thumbnails/book_thumbnail_166.jpg",
|
||||||
|
"thumbnails/book_thumbnail_167.jpg",
|
||||||
|
"thumbnails/book_thumbnail_168.jpg",
|
||||||
|
"thumbnails/book_thumbnail_169.jpg",
|
||||||
|
"thumbnails/book_thumbnail_170.jpg",
|
||||||
|
"thumbnails/book_thumbnail_171.jpg",
|
||||||
|
"thumbnails/book_thumbnail_172.jpg",
|
||||||
|
"thumbnails/book_thumbnail_173.jpg",
|
||||||
|
"thumbnails/book_thumbnail_174.jpg",
|
||||||
|
"thumbnails/book_thumbnail_175.jpg",
|
||||||
|
"thumbnails/book_thumbnail_176.jpg",
|
||||||
|
"thumbnails/book_thumbnail_177.jpg",
|
||||||
|
"thumbnails/book_thumbnail_178.jpg",
|
||||||
|
"thumbnails/book_thumbnail_179.jpg",
|
||||||
|
"thumbnails/book_thumbnail_180.jpg",
|
||||||
|
"thumbnails/book_thumbnail_181.jpg",
|
||||||
|
"thumbnails/book_thumbnail_182.jpg",
|
||||||
|
"thumbnails/book_thumbnail_183.jpg",
|
||||||
|
"thumbnails/book_thumbnail_184.jpg",
|
||||||
|
"thumbnails/book_thumbnail_185.jpg",
|
||||||
|
"thumbnails/book_thumbnail_186.jpg",
|
||||||
|
"thumbnails/book_thumbnail_187.jpg",
|
||||||
|
"thumbnails/book_thumbnail_188.jpg",
|
||||||
|
"thumbnails/book_thumbnail_189.jpg",
|
||||||
|
"thumbnails/book_thumbnail_190.jpg",
|
||||||
|
"thumbnails/book_thumbnail_191.jpg",
|
||||||
|
"thumbnails/book_thumbnail_192.jpg",
|
||||||
|
"thumbnails/book_thumbnail_193.jpg",
|
||||||
|
"thumbnails/book_thumbnail_194.jpg",
|
||||||
|
"thumbnails/book_thumbnail_195.jpg",
|
||||||
|
"thumbnails/book_thumbnail_196.jpg",
|
||||||
|
"thumbnails/book_thumbnail_197.jpg",
|
||||||
|
"thumbnails/book_thumbnail_198.jpg",
|
||||||
|
"thumbnails/book_thumbnail_199.jpg",
|
||||||
|
"thumbnails/book_thumbnail_200.jpg"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
using LiteCharms.Features.MidrandBooks.Categories;
|
||||||
|
using LiteCharms.Features.MidrandBooks.Tests.Common;
|
||||||
|
|
||||||
|
namespace LiteCharms.Features.MidrandBooks.Tests;
|
||||||
|
|
||||||
|
public class CategoryServiceFeatureTests(Fixture fixture) : IClassFixture<Fixture>
|
||||||
|
{
|
||||||
|
private readonly CategoryService categoryService = fixture.Services.GetRequiredService<CategoryService>();
|
||||||
|
|
||||||
|
[IntegrationFact]
|
||||||
|
public async Task UpdateCategoryStatusAsync_ShouldReturn_ResultWithSuccess()
|
||||||
|
{
|
||||||
|
var result = await categoryService.UpdateCategoryStatusAsync(3, false, false, fixture.CancellationToken);
|
||||||
|
|
||||||
|
Assert.True(result.IsSuccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
[IntegrationFact]
|
||||||
|
public async Task GetCategoryAsync_ShouldReturn_ResultWithCategory()
|
||||||
|
{
|
||||||
|
var result = await categoryService.GetCategoryAsync(3, fixture.CancellationToken);
|
||||||
|
|
||||||
|
Assert.True(result.IsSuccess);
|
||||||
|
Assert.NotNull(result.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
[IntegrationFact]
|
||||||
|
public async Task GetCategoriesAsync_ShouldReturn_All_ResultWithCategoryList()
|
||||||
|
{
|
||||||
|
var result = await categoryService.GetCategoriesAsync(isMain: null,fixture.CancellationToken);
|
||||||
|
|
||||||
|
Assert.True(result.IsSuccess);
|
||||||
|
Assert.NotEmpty(result.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
[IntegrationFact]
|
||||||
|
public async Task GetCategoriesAsync_ShouldReturn_MainCategory_ResultWithCategoryList()
|
||||||
|
{
|
||||||
|
var result = await categoryService.GetCategoriesAsync(true, fixture.CancellationToken);
|
||||||
|
|
||||||
|
Assert.True(result.IsSuccess);
|
||||||
|
Assert.NotEmpty(result.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
[IntegrationFact]
|
||||||
|
public async Task GetCategoriesAsync_ShouldReturn_SubMainCategory_ResultWithCategoryList()
|
||||||
|
{
|
||||||
|
var result = await categoryService.GetCategoriesAsync(false, fixture.CancellationToken);
|
||||||
|
|
||||||
|
Assert.True(result.IsSuccess);
|
||||||
|
Assert.NotEmpty(result.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
[IntegrationFact]
|
||||||
|
public async Task CreateCategoriesAsync_ShouldReturn_ResultWithSuccess()
|
||||||
|
{
|
||||||
|
var result = await categoryService.CreateCategoriesAsync(fixture.CancellationToken, "Test", "Test 1", "Test 2");
|
||||||
|
|
||||||
|
Assert.True(result.IsSuccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
[IntegrationFact]
|
||||||
|
public async Task CreateCategoryAsync_ShouldReturn_ResultWithCategoryId()
|
||||||
|
{
|
||||||
|
var result = await categoryService.CreateCategoryAsync("Test", true, fixture.CancellationToken);
|
||||||
|
|
||||||
|
Assert.True(result.IsSuccess);
|
||||||
|
Assert.True(result.Value > 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,7 +10,40 @@ public class ProductServiceFeatureTests(Fixture fixture, ITestOutputHelper outpu
|
|||||||
private readonly ProductService productService = fixture.Services.GetRequiredService<ProductService>();
|
private readonly ProductService productService = fixture.Services.GetRequiredService<ProductService>();
|
||||||
|
|
||||||
[IntegrationFact]
|
[IntegrationFact]
|
||||||
public async Task GetProductPriceAsync_ShouldReturn_RetultOneProductPrice()
|
public async Task AddProductCategoryAsync_ShouldReturn_ResultWithId()
|
||||||
|
{
|
||||||
|
var result = await productService.AddProductCategoryAsync(1, 2, fixture.CancellationToken);
|
||||||
|
|
||||||
|
Assert.True(result.IsSuccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
[IntegrationFact]
|
||||||
|
public async Task GetProductCategoriesAsync_ShouldReturn_ResultWithCategoryList()
|
||||||
|
{
|
||||||
|
var result = await productService.GetProductCategoriesAsync(1, fixture.CancellationToken);
|
||||||
|
|
||||||
|
Assert.True(result.IsSuccess);
|
||||||
|
Assert.NotEmpty(result.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
[IntegrationFact]
|
||||||
|
public async Task DeleteProductCategoryAsync_ShouldReturn_ResultWithSuccess()
|
||||||
|
{
|
||||||
|
var result = await productService.DeleteProductCategoryAsync(1, 1, fixture.CancellationToken);
|
||||||
|
|
||||||
|
Assert.True(result.IsSuccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
[IntegrationFact]
|
||||||
|
public async Task DeleteAllProductCategoriesAsync_ShouldReturn_ResultWithSuccess()
|
||||||
|
{
|
||||||
|
var result = await productService.DeleteAllProductCategoriesAsync(1, fixture.CancellationToken);
|
||||||
|
|
||||||
|
Assert.True(result.IsSuccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
[IntegrationFact]
|
||||||
|
public async Task GetProductPriceAsync_ShouldReturn_ResultOneProductPrice()
|
||||||
{
|
{
|
||||||
var result = await productService.GetProductPriceAsync(2, fixture.CancellationToken);
|
var result = await productService.GetProductPriceAsync(2, fixture.CancellationToken);
|
||||||
|
|
||||||
@@ -21,7 +54,7 @@ public class ProductServiceFeatureTests(Fixture fixture, ITestOutputHelper outpu
|
|||||||
}
|
}
|
||||||
|
|
||||||
[IntegrationFact]
|
[IntegrationFact]
|
||||||
public async Task GetProductPricesAsync_ShouldReturn_RetultProductPriceList()
|
public async Task GetProductPricesAsync_ShouldReturn_ResultProductPriceList()
|
||||||
{
|
{
|
||||||
var result = await productService.GetProductPricesAsync(2, fixture.CancellationToken);
|
var result = await productService.GetProductPricesAsync(2, fixture.CancellationToken);
|
||||||
|
|
||||||
@@ -32,7 +65,7 @@ public class ProductServiceFeatureTests(Fixture fixture, ITestOutputHelper outpu
|
|||||||
}
|
}
|
||||||
|
|
||||||
[IntegrationFact]
|
[IntegrationFact]
|
||||||
public async Task SearchProductsAsync_ShouldReturn_RetultMatchingProducts()
|
public async Task SearchProductsAsync_ShouldReturn_ResultMatchingProducts()
|
||||||
{
|
{
|
||||||
var filter = new ProductFilter
|
var filter = new ProductFilter
|
||||||
{
|
{
|
||||||
@@ -52,7 +85,7 @@ public class ProductServiceFeatureTests(Fixture fixture, ITestOutputHelper outpu
|
|||||||
}
|
}
|
||||||
|
|
||||||
[IntegrationFact]
|
[IntegrationFact]
|
||||||
public async Task GetProductAsync_ShouldReturn_RetultOneProduct()
|
public async Task GetProductAsync_ShouldReturn_ResultOneProduct()
|
||||||
{
|
{
|
||||||
var result = await productService.GetProductAsync(2, fixture.CancellationToken);
|
var result = await productService.GetProductAsync(2, fixture.CancellationToken);
|
||||||
|
|
||||||
@@ -63,7 +96,7 @@ public class ProductServiceFeatureTests(Fixture fixture, ITestOutputHelper outpu
|
|||||||
}
|
}
|
||||||
|
|
||||||
[IntegrationFact]
|
[IntegrationFact]
|
||||||
public async Task GetProductsAsync_ShouldReturn_RetultProducts()
|
public async Task GetProductsAsync_ShouldReturn_ResultProducts()
|
||||||
{
|
{
|
||||||
var range = new DateRange
|
var range = new DateRange
|
||||||
{
|
{
|
||||||
@@ -81,7 +114,7 @@ public class ProductServiceFeatureTests(Fixture fixture, ITestOutputHelper outpu
|
|||||||
}
|
}
|
||||||
|
|
||||||
[IntegrationFact]
|
[IntegrationFact]
|
||||||
public async Task UpdateProductStatusAsync_ShouldReturn_ResultTrue()
|
public async Task UpdateProductStatusAsync_ShouldResurn_ResultTrue()
|
||||||
{
|
{
|
||||||
var result = await productService.UpdateProductStatusAsync(2, true, fixture.CancellationToken);
|
var result = await productService.UpdateProductStatusAsync(2, true, fixture.CancellationToken);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,132 @@
|
|||||||
|
using LiteCharms.Features.MidrandBooks.Abstractions;
|
||||||
|
using LiteCharms.Features.MidrandBooks.Categories.Models;
|
||||||
|
using LiteCharms.Features.MidrandBooks.Extensions;
|
||||||
|
using LiteCharms.Features.MidrandBooks.Postgres;
|
||||||
|
|
||||||
|
namespace LiteCharms.Features.MidrandBooks.Categories;
|
||||||
|
|
||||||
|
public sealed class CategoryService(IDbContextFactory<MidrandBooksDbContext> contextFactory) : IService
|
||||||
|
{
|
||||||
|
public async ValueTask<Result> UpdateCategoryStatusAsync(long categoryId, bool enabled, bool isMain, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await using var context = await contextFactory.CreateDbContextAsync(cancellationToken);
|
||||||
|
|
||||||
|
var rowsUpdated = await context.Categories
|
||||||
|
.Where(c => c.Id == categoryId && c.Enabled)
|
||||||
|
.ExecuteUpdateAsync(setters => setters
|
||||||
|
.SetProperty(c => c.Enabled, enabled)
|
||||||
|
.SetProperty(c => c.IsMain, isMain), cancellationToken);
|
||||||
|
|
||||||
|
return rowsUpdated > 0
|
||||||
|
? Result.Ok()
|
||||||
|
: Result.Fail(new Error($"Failed to update category"));
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return Result.Fail(new Error(ex.Message).CausedBy(ex));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask<Result<Category>> GetCategoryAsync(long categoryId, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await using var context = await contextFactory.CreateDbContextAsync(cancellationToken);
|
||||||
|
|
||||||
|
var category = await context.Categories.AsNoTracking().FirstOrDefaultAsync(c => c.Id == categoryId, cancellationToken);
|
||||||
|
|
||||||
|
return category is not null
|
||||||
|
? Result.Ok(category.ToModel())
|
||||||
|
: Result.Fail<Category>("Failed to create new category");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return Result.Fail<Category>(new Error(ex.Message).CausedBy(ex));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask<Result<Category[]>> GetCategoriesAsync(bool? isMain = null, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await using var context = await contextFactory.CreateDbContextAsync(cancellationToken);
|
||||||
|
|
||||||
|
var query = context.Categories.AsNoTracking()
|
||||||
|
.OrderByDescending(o => o.IsMain)
|
||||||
|
.ThenByDescending(o => o.Id)
|
||||||
|
.ThenBy(o => o.Name)
|
||||||
|
.AsQueryable();
|
||||||
|
|
||||||
|
query = isMain is null
|
||||||
|
? query.Where(c => c.Enabled).AsQueryable()
|
||||||
|
: query.Where(c => c.Enabled && c.IsMain == isMain.Value);
|
||||||
|
|
||||||
|
var categories = await query.ToListAsync(cancellationToken);
|
||||||
|
|
||||||
|
return categories?.Count > 0
|
||||||
|
? Result.Ok(categories.Select(c => c.ToModel()).ToArray())
|
||||||
|
: Result.Fail<Category[]>("No categories found");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return Result.Fail<Category[]>(new Error(ex.Message).CausedBy(ex));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask<Result> CreateCategoriesAsync(CancellationToken cancellationToken = default, params string[] categories)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await using var context = await contextFactory.CreateDbContextAsync(cancellationToken);
|
||||||
|
|
||||||
|
foreach (var category in categories)
|
||||||
|
{
|
||||||
|
if (await context.Categories.AnyAsync(c => EF.Functions.ILike(c.Name!, category!), cancellationToken))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
context.Categories.Add(new Entities.Category
|
||||||
|
{
|
||||||
|
Name = category.Humanize(LetterCasing.Title),
|
||||||
|
IsMain = false,
|
||||||
|
Enabled = true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return await context.SaveChangesAsync(cancellationToken) > 0
|
||||||
|
? Result.Ok()
|
||||||
|
: Result.Fail("Failed to add any category in the list");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return Result.Fail(new Error(ex.Message).CausedBy(ex));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask<Result<long>> CreateCategoryAsync(string category, bool isMain, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await using var context = await contextFactory.CreateDbContextAsync(cancellationToken);
|
||||||
|
|
||||||
|
if (await context.Categories.AnyAsync(c => EF.Functions.ILike(c.Name!, category!), cancellationToken))
|
||||||
|
return Result.Fail($"Category '{category}' already exists");
|
||||||
|
|
||||||
|
var newCategory = context.Categories.Add(new Entities.Category
|
||||||
|
{
|
||||||
|
Name = StringHumanizeExtensions.Humanize(category, LetterCasing.Title),
|
||||||
|
IsMain = isMain,
|
||||||
|
Enabled = true,
|
||||||
|
});
|
||||||
|
|
||||||
|
return await context.SaveChangesAsync(cancellationToken) > 0
|
||||||
|
? Result.Ok(newCategory.Entity.Id)
|
||||||
|
: Result.Fail("Failed to create new category");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return Result.Fail(new Error(ex.Message).CausedBy(ex));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
namespace LiteCharms.Features.MidrandBooks.Categories.Entities;
|
||||||
|
|
||||||
|
[EntityTypeConfiguration<CategoryConfiguration, Category>]
|
||||||
|
public sealed class Category : Models.Category;
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
namespace LiteCharms.Features.MidrandBooks.Categories.Entities;
|
||||||
|
|
||||||
|
public sealed class CategoryConfiguration : IEntityTypeConfiguration<Category>
|
||||||
|
{
|
||||||
|
public void Configure(EntityTypeBuilder<Category> builder)
|
||||||
|
{
|
||||||
|
builder.ToTable("Categories");
|
||||||
|
|
||||||
|
builder.HasKey(c => c.Id);
|
||||||
|
builder.Property(c => c.Name).IsRequired().HasMaxLength(15);
|
||||||
|
builder.Property(c => c.IsMain).HasDefaultValue(false);
|
||||||
|
builder.Property(c => c.Enabled).HasDefaultValue(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
namespace LiteCharms.Features.MidrandBooks.Categories.Models;
|
||||||
|
|
||||||
|
public class Category
|
||||||
|
{
|
||||||
|
public long Id { get; set; }
|
||||||
|
|
||||||
|
public string? Name { get; set; }
|
||||||
|
|
||||||
|
public bool IsMain { get; set; }
|
||||||
|
|
||||||
|
public bool Enabled { get; set; }
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using LiteCharms.Features.MidrandBooks.AuthorBooks.Models;
|
using LiteCharms.Features.MidrandBooks.AuthorBooks.Models;
|
||||||
using LiteCharms.Features.MidrandBooks.Authors.Models;
|
using LiteCharms.Features.MidrandBooks.Authors.Models;
|
||||||
|
using LiteCharms.Features.MidrandBooks.Categories.Models;
|
||||||
using LiteCharms.Features.MidrandBooks.Customers.Models;
|
using LiteCharms.Features.MidrandBooks.Customers.Models;
|
||||||
using LiteCharms.Features.MidrandBooks.Orders.Models;
|
using LiteCharms.Features.MidrandBooks.Orders.Models;
|
||||||
using LiteCharms.Features.MidrandBooks.Pages.Models;
|
using LiteCharms.Features.MidrandBooks.Pages.Models;
|
||||||
@@ -9,6 +10,14 @@ namespace LiteCharms.Features.MidrandBooks.Extensions;
|
|||||||
|
|
||||||
public static class Mappers
|
public static class Mappers
|
||||||
{
|
{
|
||||||
|
public static Category ToModel(this Categories.Entities.Category entity) => new()
|
||||||
|
{
|
||||||
|
Id = entity.Id,
|
||||||
|
Name = entity.Name,
|
||||||
|
IsMain = entity.IsMain,
|
||||||
|
Enabled = entity.Enabled,
|
||||||
|
};
|
||||||
|
|
||||||
public static ShippingProvider ToModel(this Orders.Entities.ShippingProvider entity) => new()
|
public static ShippingProvider ToModel(this Orders.Entities.ShippingProvider entity) => new()
|
||||||
{
|
{
|
||||||
Id = entity.Id,
|
Id = entity.Id,
|
||||||
@@ -138,25 +147,21 @@ public static class Mappers
|
|||||||
Enabled = entity.Enabled
|
Enabled = entity.Enabled
|
||||||
};
|
};
|
||||||
|
|
||||||
public static Product ToModel(this Products.Entities.Product entity)
|
public static Product ToModel(this Products.Entities.Product entity) => new Product
|
||||||
{
|
{
|
||||||
return new Product
|
Id = entity.Id,
|
||||||
{
|
CreatedAt = entity.CreatedAt,
|
||||||
Id = entity.Id,
|
UpdatedAt = entity.UpdatedAt,
|
||||||
CreatedAt = entity.CreatedAt,
|
Name = entity.Name,
|
||||||
UpdatedAt = entity.UpdatedAt,
|
Summary = entity.Summary,
|
||||||
Name = entity.Name,
|
Description = entity.Description,
|
||||||
Summary = entity.Summary,
|
Type = entity.Type,
|
||||||
Description = entity.Description,
|
ImageUrl = entity.ImageUrl,
|
||||||
Type = entity.Type,
|
ThumbnailUrls = entity.ThumbnailUrls,
|
||||||
ImageUrl = entity.ImageUrl,
|
Metadata = entity.Metadata,
|
||||||
ThumbnailUrls = entity.ThumbnailUrls,
|
Enabled = entity.Enabled,
|
||||||
Metadata = entity.Metadata,
|
Price = entity.Prices?.FirstOrDefault(p => p.Enabled)?.ToModel() ?? null,
|
||||||
Categories = entity.Categories,
|
};
|
||||||
Enabled = entity.Enabled,
|
|
||||||
Price = entity.Prices?.FirstOrDefault(p => p.Enabled)?.ToModel() ?? null,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Author ToModel(this Authors.Entities.Author entity) => new()
|
public static Author ToModel(this Authors.Entities.Author entity) => new()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -31,7 +31,8 @@
|
|||||||
|
|
||||||
<!-- Quartz Scheduler-->
|
<!-- Quartz Scheduler-->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Meziantou.Analyzer" Version="3.0.96">
|
<PackageReference Include="Humanizer" Version="3.0.10" />
|
||||||
|
<PackageReference Include="Meziantou.Analyzer" Version="3.0.98">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
@@ -104,7 +105,7 @@
|
|||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.0.1" />
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.0.2" />
|
||||||
|
|
||||||
<!-- Global Usings -->
|
<!-- Global Usings -->
|
||||||
<Using Include="Npgsql" />
|
<Using Include="Npgsql" />
|
||||||
@@ -115,8 +116,8 @@
|
|||||||
|
|
||||||
<!-- Email -->
|
<!-- Email -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="MailKit" Version="4.16.0" />
|
<PackageReference Include="MailKit" Version="4.17.0" />
|
||||||
<PackageReference Include="MimeKit" Version="4.16.0" />
|
<PackageReference Include="MimeKit" Version="4.17.0" />
|
||||||
|
|
||||||
<!-- Global Usings-->
|
<!-- Global Usings-->
|
||||||
<Using Include="MimeKit" />
|
<Using Include="MimeKit" />
|
||||||
@@ -147,6 +148,7 @@
|
|||||||
|
|
||||||
<!-- Shared Usings -->
|
<!-- Shared Usings -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Using Include="Humanizer" />
|
||||||
<Using Include="System.Globalization" />
|
<Using Include="System.Globalization" />
|
||||||
<Using Include="System.Reflection" />
|
<Using Include="System.Reflection" />
|
||||||
<Using Include="Microsoft.AspNetCore.Builder" />
|
<Using Include="Microsoft.AspNetCore.Builder" />
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using LiteCharms.Features.MidrandBooks.AuthorBooks.Entities;
|
using LiteCharms.Features.MidrandBooks.AuthorBooks.Entities;
|
||||||
using LiteCharms.Features.MidrandBooks.Authors.Entities;
|
using LiteCharms.Features.MidrandBooks.Authors.Entities;
|
||||||
|
using LiteCharms.Features.MidrandBooks.Categories.Entities;
|
||||||
using LiteCharms.Features.MidrandBooks.Customers.Entities;
|
using LiteCharms.Features.MidrandBooks.Customers.Entities;
|
||||||
using LiteCharms.Features.MidrandBooks.Orders.Entities;
|
using LiteCharms.Features.MidrandBooks.Orders.Entities;
|
||||||
using LiteCharms.Features.MidrandBooks.Pages.Entities;
|
using LiteCharms.Features.MidrandBooks.Pages.Entities;
|
||||||
@@ -35,4 +36,8 @@ public sealed class MidrandBooksDbContext(DbContextOptions<MidrandBooksDbContext
|
|||||||
public DbSet<Shipping> Shippings => Set<Shipping>();
|
public DbSet<Shipping> Shippings => Set<Shipping>();
|
||||||
|
|
||||||
public DbSet<ShippingProvider> ShippingProviders => Set<ShippingProvider>();
|
public DbSet<ShippingProvider> ShippingProviders => Set<ShippingProvider>();
|
||||||
|
|
||||||
|
public DbSet<Category> Categories => Set<Category>();
|
||||||
|
|
||||||
|
public DbSet<ProductCategory> ProductCategories => Set<ProductCategory>();
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+966
@@ -0,0 +1,966 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using LiteCharms.Features.MidrandBooks.Postgres;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace LiteCharms.Features.MidrandBooks.Postgres.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(MidrandBooksDbContext))]
|
||||||
|
[Migration("20260530104851_AddedCategories")]
|
||||||
|
partial class AddedCategories
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "10.0.8")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.AuthorBooks.Entities.AuthorBook", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<long>("AuthorId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<bool>("Enabled")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<long>("ProductId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<int>("Ranking")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("Rating")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("UpdatedAt")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("AuthorId");
|
||||||
|
|
||||||
|
b.HasIndex("ProductId");
|
||||||
|
|
||||||
|
b.ToTable("Books");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.Authors.Entities.Author", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Biography")
|
||||||
|
.HasMaxLength(2048)
|
||||||
|
.HasColumnType("character varying(2048)");
|
||||||
|
|
||||||
|
b.Property<string>("Company")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasDefaultValueSql("now()");
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(512)
|
||||||
|
.HasColumnType("character varying(512)");
|
||||||
|
|
||||||
|
b.Property<bool>("Enabled")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("boolean")
|
||||||
|
.HasDefaultValue(true);
|
||||||
|
|
||||||
|
b.Property<string>("ImageUrl")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(2048)
|
||||||
|
.HasColumnType("character varying(2048)");
|
||||||
|
|
||||||
|
b.Property<string>("LastName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(255)
|
||||||
|
.HasColumnType("character varying(255)");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(255)
|
||||||
|
.HasColumnType("character varying(255)");
|
||||||
|
|
||||||
|
b.Property<int>("PublisherType")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<string>("ThumbnailImageUrl")
|
||||||
|
.HasMaxLength(2048)
|
||||||
|
.HasColumnType("character varying(2048)");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("UpdatedAt")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasDefaultValueSql("now()");
|
||||||
|
|
||||||
|
b.Property<string>("VatNumber")
|
||||||
|
.HasMaxLength(255)
|
||||||
|
.HasColumnType("character varying(255)");
|
||||||
|
|
||||||
|
b.Property<string>("Website")
|
||||||
|
.HasMaxLength(1024)
|
||||||
|
.HasColumnType("character varying(1024)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Authors", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.Categories.Entities.Category", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<bool>("Enabled")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("boolean")
|
||||||
|
.HasDefaultValue(true);
|
||||||
|
|
||||||
|
b.Property<bool>("IsMain")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("boolean")
|
||||||
|
.HasDefaultValue(false);
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(15)
|
||||||
|
.HasColumnType("character varying(15)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Categories", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.Customers.Entities.Address", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("BuildingType")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<string>("City")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Country")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasDefaultValueSql("now()");
|
||||||
|
|
||||||
|
b.Property<long>("CustomerId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<bool>("Enabled")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("boolean")
|
||||||
|
.HasDefaultValue(true);
|
||||||
|
|
||||||
|
b.Property<bool>("IsPrimary")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("boolean")
|
||||||
|
.HasDefaultValue(false);
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("PostalCode")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("State")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Street")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("Type")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("UpdatedAt")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasDefaultValueSql("now()");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("CustomerId");
|
||||||
|
|
||||||
|
b.ToTable("Addresses", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.Customers.Entities.Contact", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasDefaultValueSql("now()");
|
||||||
|
|
||||||
|
b.Property<long>("CustomerId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("Enabled")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("boolean")
|
||||||
|
.HasDefaultValue(true);
|
||||||
|
|
||||||
|
b.Property<bool>("IsPrimary")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("boolean")
|
||||||
|
.HasDefaultValue(false);
|
||||||
|
|
||||||
|
b.Property<string>("LastName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Phone")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("Type")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("UpdatedAt")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasDefaultValueSql("now()");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("CustomerId");
|
||||||
|
|
||||||
|
b.ToTable("Contacts", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.Customers.Entities.Customer", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Company")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasDefaultValueSql("now()");
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("Enabled")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("boolean")
|
||||||
|
.HasDefaultValue(true);
|
||||||
|
|
||||||
|
b.Property<string>("Phone")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("UpdatedAt")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasDefaultValueSql("now()");
|
||||||
|
|
||||||
|
b.Property<string>("VatNumber")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Website")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Customers", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.Orders.Entities.Order", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasDefaultValueSql("now()");
|
||||||
|
|
||||||
|
b.Property<long>("CustomerId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<string>("InvoiceUrl")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Notes")
|
||||||
|
.HasMaxLength(1000)
|
||||||
|
.HasColumnType("character varying(1000)");
|
||||||
|
|
||||||
|
b.Property<int>("Status")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<decimal>("Total")
|
||||||
|
.HasPrecision(18, 2)
|
||||||
|
.HasColumnType("numeric(18,2)");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("UpdatedAt")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasDefaultValueSql("now()");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Orders", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.Orders.Entities.OrderItem", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<long>("AuthorBookId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasDefaultValueSql("now()");
|
||||||
|
|
||||||
|
b.Property<long>("OrderId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<long>("ProductPriceId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<int>("Quantity")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("AuthorBookId");
|
||||||
|
|
||||||
|
b.HasIndex("OrderId");
|
||||||
|
|
||||||
|
b.HasIndex("ProductPriceId");
|
||||||
|
|
||||||
|
b.ToTable("OrderItems", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.Orders.Entities.Shipping", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<long>("AddressId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasDefaultValueSql("now()");
|
||||||
|
|
||||||
|
b.Property<long>("OrderId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<long>("ShippingProviderId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<int>("Status")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<string>("TrackingNumber")
|
||||||
|
.HasMaxLength(255)
|
||||||
|
.HasColumnType("character varying(255)");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("UpdatedAt")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasDefaultValueSql("now()");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("AddressId");
|
||||||
|
|
||||||
|
b.HasIndex("OrderId")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.HasIndex("ShippingProviderId");
|
||||||
|
|
||||||
|
b.ToTable("Shippings", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.Orders.Entities.ShippingProvider", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<bool>("Enabled")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<decimal?>("Price")
|
||||||
|
.HasColumnType("numeric");
|
||||||
|
|
||||||
|
b.Property<string>("TrackingUrl")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("Type")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("UpdatedAt")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("ShippingProviders");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.Pages.Entities.BookPage", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<long>("AuthorBookId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<byte[]>("Content")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("bytea");
|
||||||
|
|
||||||
|
b.Property<int>("ContentType")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasDefaultValueSql("now()");
|
||||||
|
|
||||||
|
b.Property<bool>("Enabled")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("boolean")
|
||||||
|
.HasDefaultValue(true);
|
||||||
|
|
||||||
|
b.PrimitiveCollection<string[]>("Notes")
|
||||||
|
.HasColumnType("text[]");
|
||||||
|
|
||||||
|
b.Property<int>("Number")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasDefaultValue(0);
|
||||||
|
|
||||||
|
b.Property<int>("Type")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("UpdatedAt")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasDefaultValueSql("now()");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("AuthorBookId");
|
||||||
|
|
||||||
|
b.ToTable("BookPages", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.Payments.Entities.Refund", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<decimal>("Amount")
|
||||||
|
.HasPrecision(18, 2)
|
||||||
|
.HasColumnType("numeric(18,2)");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasDefaultValueSql("now()");
|
||||||
|
|
||||||
|
b.Property<long>("OrderId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<string>("Reason")
|
||||||
|
.HasMaxLength(1000)
|
||||||
|
.HasColumnType("character varying(1000)");
|
||||||
|
|
||||||
|
b.Property<int>("Status")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("Type")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("UpdatedAt")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasDefaultValueSql("now()");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("OrderId");
|
||||||
|
|
||||||
|
b.ToTable("Refunds", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.Products.Entities.Product", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.PrimitiveCollection<string[]>("Categories")
|
||||||
|
.HasColumnType("text[]");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasDefaultValueSql("now()");
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.HasMaxLength(1024)
|
||||||
|
.HasColumnType("character varying(1024)");
|
||||||
|
|
||||||
|
b.Property<bool>("Enabled")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("boolean")
|
||||||
|
.HasDefaultValue(false);
|
||||||
|
|
||||||
|
b.Property<string>("ImageUrl")
|
||||||
|
.HasMaxLength(1024)
|
||||||
|
.HasColumnType("character varying(1024)");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(255)
|
||||||
|
.HasColumnType("character varying(255)");
|
||||||
|
|
||||||
|
b.Property<string>("Summary")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(512)
|
||||||
|
.HasColumnType("character varying(512)");
|
||||||
|
|
||||||
|
b.PrimitiveCollection<string[]>("ThumbnailUrls")
|
||||||
|
.HasColumnType("text[]");
|
||||||
|
|
||||||
|
b.Property<int>("Type")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("UpdatedAt")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasDefaultValueSql("now()");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Products", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.Products.Entities.ProductPrice", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<decimal>("Amount")
|
||||||
|
.HasPrecision(18, 2)
|
||||||
|
.HasColumnType("numeric(18,2)");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasDefaultValueSql("now()");
|
||||||
|
|
||||||
|
b.Property<decimal>("Discount")
|
||||||
|
.HasPrecision(18, 2)
|
||||||
|
.HasColumnType("numeric(18,2)");
|
||||||
|
|
||||||
|
b.Property<bool>("Enabled")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("boolean")
|
||||||
|
.HasDefaultValue(false);
|
||||||
|
|
||||||
|
b.Property<long>("ProductId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("UpdatedAt")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasDefaultValueSql("now()");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ProductId");
|
||||||
|
|
||||||
|
b.ToTable("Prices", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.AuthorBooks.Entities.AuthorBook", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("LiteCharms.Features.MidrandBooks.Authors.Entities.Author", "Author")
|
||||||
|
.WithMany("Books")
|
||||||
|
.HasForeignKey("AuthorId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("LiteCharms.Features.MidrandBooks.Products.Entities.Product", "Product")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ProductId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Author");
|
||||||
|
|
||||||
|
b.Navigation("Product");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.Authors.Entities.Author", b =>
|
||||||
|
{
|
||||||
|
b.OwnsMany("LiteCharms.Features.Models.SocialMedia", "SocialMedia", b1 =>
|
||||||
|
{
|
||||||
|
b1.Property<long>("AuthorId");
|
||||||
|
|
||||||
|
b1.Property<int>("__synthesizedOrdinal")
|
||||||
|
.ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
b1.Property<string>("ImageUrl");
|
||||||
|
|
||||||
|
b1.Property<string>("Name");
|
||||||
|
|
||||||
|
b1.Property<int>("Type");
|
||||||
|
|
||||||
|
b1.Property<string>("Url");
|
||||||
|
|
||||||
|
b1.HasKey("AuthorId", "__synthesizedOrdinal");
|
||||||
|
|
||||||
|
b1.ToTable("Authors");
|
||||||
|
|
||||||
|
b1
|
||||||
|
.ToJson("SocialMedia")
|
||||||
|
.HasColumnType("jsonb");
|
||||||
|
|
||||||
|
b1.WithOwner()
|
||||||
|
.HasForeignKey("AuthorId");
|
||||||
|
});
|
||||||
|
|
||||||
|
b.Navigation("SocialMedia");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.Customers.Entities.Address", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("LiteCharms.Features.MidrandBooks.Customers.Entities.Customer", "Customer")
|
||||||
|
.WithMany("Addresses")
|
||||||
|
.HasForeignKey("CustomerId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Customer");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.Customers.Entities.Contact", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("LiteCharms.Features.MidrandBooks.Customers.Entities.Customer", "Customer")
|
||||||
|
.WithMany("Contacts")
|
||||||
|
.HasForeignKey("CustomerId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Customer");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.Customers.Entities.Customer", b =>
|
||||||
|
{
|
||||||
|
b.OwnsMany("LiteCharms.Features.Models.SocialMedia", "SocialMedia", b1 =>
|
||||||
|
{
|
||||||
|
b1.Property<long>("CustomerId");
|
||||||
|
|
||||||
|
b1.Property<int>("__synthesizedOrdinal")
|
||||||
|
.ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
b1.Property<string>("ImageUrl");
|
||||||
|
|
||||||
|
b1.Property<string>("Name");
|
||||||
|
|
||||||
|
b1.Property<int>("Type");
|
||||||
|
|
||||||
|
b1.Property<string>("Url");
|
||||||
|
|
||||||
|
b1.HasKey("CustomerId", "__synthesizedOrdinal");
|
||||||
|
|
||||||
|
b1.ToTable("Customers");
|
||||||
|
|
||||||
|
b1
|
||||||
|
.ToJson("SocialMedia")
|
||||||
|
.HasColumnType("jsonb");
|
||||||
|
|
||||||
|
b1.WithOwner()
|
||||||
|
.HasForeignKey("CustomerId");
|
||||||
|
});
|
||||||
|
|
||||||
|
b.Navigation("SocialMedia");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.Orders.Entities.OrderItem", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("LiteCharms.Features.MidrandBooks.AuthorBooks.Entities.AuthorBook", "AuthorBook")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("AuthorBookId")
|
||||||
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("LiteCharms.Features.MidrandBooks.Orders.Entities.Order", "Order")
|
||||||
|
.WithMany("OrderItems")
|
||||||
|
.HasForeignKey("OrderId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("LiteCharms.Features.MidrandBooks.Products.Entities.ProductPrice", "ProductPrice")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ProductPriceId")
|
||||||
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("AuthorBook");
|
||||||
|
|
||||||
|
b.Navigation("Order");
|
||||||
|
|
||||||
|
b.Navigation("ProductPrice");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.Orders.Entities.Shipping", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("LiteCharms.Features.MidrandBooks.Customers.Entities.Address", "Address")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("AddressId")
|
||||||
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("LiteCharms.Features.MidrandBooks.Orders.Entities.Order", "Order")
|
||||||
|
.WithOne("Shipping")
|
||||||
|
.HasForeignKey("LiteCharms.Features.MidrandBooks.Orders.Entities.Shipping", "OrderId")
|
||||||
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("LiteCharms.Features.MidrandBooks.Orders.Entities.ShippingProvider", "ShippingProvider")
|
||||||
|
.WithMany("Shippings")
|
||||||
|
.HasForeignKey("ShippingProviderId")
|
||||||
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Address");
|
||||||
|
|
||||||
|
b.Navigation("Order");
|
||||||
|
|
||||||
|
b.Navigation("ShippingProvider");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.Pages.Entities.BookPage", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("LiteCharms.Features.MidrandBooks.AuthorBooks.Entities.AuthorBook", "Book")
|
||||||
|
.WithMany("Pages")
|
||||||
|
.HasForeignKey("AuthorBookId")
|
||||||
|
.OnDelete(DeleteBehavior.NoAction)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.OwnsMany("LiteCharms.Features.Models.PageReference", "References", b1 =>
|
||||||
|
{
|
||||||
|
b1.Property<long>("BookPageId");
|
||||||
|
|
||||||
|
b1.Property<int>("__synthesizedOrdinal")
|
||||||
|
.ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
b1.Property<string>("Description");
|
||||||
|
|
||||||
|
b1.Property<string>("Tag");
|
||||||
|
|
||||||
|
b1.Property<string>("Url");
|
||||||
|
|
||||||
|
b1.HasKey("BookPageId", "__synthesizedOrdinal");
|
||||||
|
|
||||||
|
b1.ToTable("BookPages");
|
||||||
|
|
||||||
|
b1
|
||||||
|
.ToJson("References")
|
||||||
|
.HasColumnType("jsonb");
|
||||||
|
|
||||||
|
b1.WithOwner()
|
||||||
|
.HasForeignKey("BookPageId");
|
||||||
|
});
|
||||||
|
|
||||||
|
b.Navigation("Book");
|
||||||
|
|
||||||
|
b.Navigation("References");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.Payments.Entities.Refund", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("LiteCharms.Features.MidrandBooks.Orders.Entities.Order", "Order")
|
||||||
|
.WithMany("Refunds")
|
||||||
|
.HasForeignKey("OrderId")
|
||||||
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Order");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.Products.Entities.Product", b =>
|
||||||
|
{
|
||||||
|
b.OwnsOne("LiteCharms.Features.Models.ProductMetadata", "Metadata", b1 =>
|
||||||
|
{
|
||||||
|
b1.Property<long>("ProductId");
|
||||||
|
|
||||||
|
b1.Property<string>("CopyrightInfo");
|
||||||
|
|
||||||
|
b1.Property<string>("ManufactureDate");
|
||||||
|
|
||||||
|
b1.Property<string>("Manufacturer");
|
||||||
|
|
||||||
|
b1.Property<string>("SerialNumber");
|
||||||
|
|
||||||
|
b1.HasKey("ProductId");
|
||||||
|
|
||||||
|
b1.ToTable("Products");
|
||||||
|
|
||||||
|
b1
|
||||||
|
.ToJson("Metadata")
|
||||||
|
.HasColumnType("jsonb");
|
||||||
|
|
||||||
|
b1.WithOwner()
|
||||||
|
.HasForeignKey("ProductId");
|
||||||
|
});
|
||||||
|
|
||||||
|
b.Navigation("Metadata");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.Products.Entities.ProductPrice", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("LiteCharms.Features.MidrandBooks.Products.Entities.Product", "Product")
|
||||||
|
.WithMany("Prices")
|
||||||
|
.HasForeignKey("ProductId")
|
||||||
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Product");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.AuthorBooks.Entities.AuthorBook", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Pages");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.Authors.Entities.Author", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Books");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.Customers.Entities.Customer", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Addresses");
|
||||||
|
|
||||||
|
b.Navigation("Contacts");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.Orders.Entities.Order", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("OrderItems");
|
||||||
|
|
||||||
|
b.Navigation("Refunds");
|
||||||
|
|
||||||
|
b.Navigation("Shipping");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.Orders.Entities.ShippingProvider", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Shippings");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.Products.Entities.Product", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Prices");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+37
@@ -0,0 +1,37 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace LiteCharms.Features.MidrandBooks.Postgres.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class AddedCategories : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Categories",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<long>(type: "bigint", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
Name = table.Column<string>(type: "character varying(15)", maxLength: 15, nullable: false),
|
||||||
|
IsMain = table.Column<bool>(type: "boolean", nullable: false, defaultValue: false),
|
||||||
|
Enabled = table.Column<bool>(type: "boolean", nullable: false, defaultValue: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Categories", x => x.Id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Categories");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+1007
File diff suppressed because it is too large
Load Diff
+68
@@ -0,0 +1,68 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace LiteCharms.Features.MidrandBooks.Postgres.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class AddedProductCategories : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Categories",
|
||||||
|
table: "Products");
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "ProductCategories",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<long>(type: "bigint", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
ProductId = table.Column<long>(type: "bigint", nullable: false),
|
||||||
|
CategoryId = table.Column<long>(type: "bigint", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_ProductCategories", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_ProductCategories_Categories_CategoryId",
|
||||||
|
column: x => x.CategoryId,
|
||||||
|
principalTable: "Categories",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_ProductCategories_Products_ProductId",
|
||||||
|
column: x => x.ProductId,
|
||||||
|
principalTable: "Products",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_ProductCategories_CategoryId",
|
||||||
|
table: "ProductCategories",
|
||||||
|
column: "CategoryId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_ProductCategories_ProductId",
|
||||||
|
table: "ProductCategories",
|
||||||
|
column: "ProductId");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "ProductCategories");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string[]>(
|
||||||
|
name: "Categories",
|
||||||
|
table: "Products",
|
||||||
|
type: "text[]",
|
||||||
|
nullable: true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+72
-3
@@ -130,6 +130,34 @@ namespace LiteCharms.Features.MidrandBooks.Postgres.Migrations
|
|||||||
b.ToTable("Authors", (string)null);
|
b.ToTable("Authors", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.Categories.Entities.Category", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<bool>("Enabled")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("boolean")
|
||||||
|
.HasDefaultValue(true);
|
||||||
|
|
||||||
|
b.Property<bool>("IsMain")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("boolean")
|
||||||
|
.HasDefaultValue(false);
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(15)
|
||||||
|
.HasColumnType("character varying(15)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Categories", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.Customers.Entities.Address", b =>
|
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.Customers.Entities.Address", b =>
|
||||||
{
|
{
|
||||||
b.Property<long>("Id")
|
b.Property<long>("Id")
|
||||||
@@ -558,9 +586,6 @@ namespace LiteCharms.Features.MidrandBooks.Postgres.Migrations
|
|||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
b.PrimitiveCollection<string[]>("Categories")
|
|
||||||
.HasColumnType("text[]");
|
|
||||||
|
|
||||||
b.Property<DateTime>("CreatedAt")
|
b.Property<DateTime>("CreatedAt")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("timestamp with time zone")
|
.HasColumnType("timestamp with time zone")
|
||||||
@@ -605,6 +630,29 @@ namespace LiteCharms.Features.MidrandBooks.Postgres.Migrations
|
|||||||
b.ToTable("Products", (string)null);
|
b.ToTable("Products", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.Products.Entities.ProductCategory", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||||
|
|
||||||
|
b.Property<long>("CategoryId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<long>("ProductId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("CategoryId");
|
||||||
|
|
||||||
|
b.HasIndex("ProductId");
|
||||||
|
|
||||||
|
b.ToTable("ProductCategories", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.Products.Entities.ProductPrice", b =>
|
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.Products.Entities.ProductPrice", b =>
|
||||||
{
|
{
|
||||||
b.Property<long>("Id")
|
b.Property<long>("Id")
|
||||||
@@ -883,6 +931,25 @@ namespace LiteCharms.Features.MidrandBooks.Postgres.Migrations
|
|||||||
b.Navigation("Metadata");
|
b.Navigation("Metadata");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.Products.Entities.ProductCategory", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("LiteCharms.Features.MidrandBooks.Categories.Entities.Category", "Category")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("CategoryId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("LiteCharms.Features.MidrandBooks.Products.Entities.Product", "Product")
|
||||||
|
.WithMany("Categories")
|
||||||
|
.HasForeignKey("ProductId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Category");
|
||||||
|
|
||||||
|
b.Navigation("Product");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.Products.Entities.ProductPrice", b =>
|
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.Products.Entities.ProductPrice", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("LiteCharms.Features.MidrandBooks.Products.Entities.Product", "Product")
|
b.HasOne("LiteCharms.Features.MidrandBooks.Products.Entities.Product", "Product")
|
||||||
@@ -927,6 +994,8 @@ namespace LiteCharms.Features.MidrandBooks.Postgres.Migrations
|
|||||||
|
|
||||||
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.Products.Entities.Product", b =>
|
modelBuilder.Entity("LiteCharms.Features.MidrandBooks.Products.Entities.Product", b =>
|
||||||
{
|
{
|
||||||
|
b.Navigation("Categories");
|
||||||
|
|
||||||
b.Navigation("Prices");
|
b.Navigation("Prices");
|
||||||
});
|
});
|
||||||
#pragma warning restore 612, 618
|
#pragma warning restore 612, 618
|
||||||
|
|||||||
@@ -3,5 +3,7 @@
|
|||||||
[EntityTypeConfiguration<ProductConfiguration, Product>]
|
[EntityTypeConfiguration<ProductConfiguration, Product>]
|
||||||
public class Product : Models.Product
|
public class Product : Models.Product
|
||||||
{
|
{
|
||||||
|
public virtual ICollection<ProductCategory> Categories { get; set; } = [];
|
||||||
|
|
||||||
public virtual ICollection<ProductPrice> Prices { get; set; } = [];
|
public virtual ICollection<ProductPrice> Prices { get; set; } = [];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
using LiteCharms.Features.MidrandBooks.Categories.Entities;
|
||||||
|
|
||||||
|
namespace LiteCharms.Features.MidrandBooks.Products.Entities;
|
||||||
|
|
||||||
|
[EntityTypeConfiguration<ProductCategoryConfiguration, ProductCategory>]
|
||||||
|
public class ProductCategory : Models.ProductCategory
|
||||||
|
{
|
||||||
|
public virtual Product? Product { get; set; }
|
||||||
|
|
||||||
|
public virtual Category? Category { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
namespace LiteCharms.Features.MidrandBooks.Products.Entities;
|
||||||
|
|
||||||
|
public sealed class ProductCategoryConfiguration : IEntityTypeConfiguration<ProductCategory>
|
||||||
|
{
|
||||||
|
public void Configure(EntityTypeBuilder<ProductCategory> builder)
|
||||||
|
{
|
||||||
|
builder.ToTable("ProductCategories");
|
||||||
|
|
||||||
|
builder.HasKey(p => p.Id);
|
||||||
|
builder.Property(p => p.ProductId).IsRequired();
|
||||||
|
builder.Property(p => p.CategoryId).IsRequired();
|
||||||
|
|
||||||
|
builder.HasOne(p => p.Product)
|
||||||
|
.WithMany(p => p.Categories)
|
||||||
|
.HasForeignKey(p => p.ProductId)
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
|
builder.HasOne(c => c.Category)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(c => c.CategoryId)
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,7 +17,6 @@ public sealed class ProductConfiguration : IEntityTypeConfiguration<Product>
|
|||||||
builder.Property(f => f.Description).HasMaxLength(1024);
|
builder.Property(f => f.Description).HasMaxLength(1024);
|
||||||
builder.Property(f => f.ImageUrl).HasMaxLength(1024);
|
builder.Property(f => f.ImageUrl).HasMaxLength(1024);
|
||||||
builder.Property(f => f.Enabled).HasDefaultValue(false);
|
builder.Property(f => f.Enabled).HasDefaultValue(false);
|
||||||
builder.Property(f => f.Categories).IsRequired(false);
|
|
||||||
builder.Property(f => f.ThumbnailUrls).IsRequired(false);
|
builder.Property(f => f.ThumbnailUrls).IsRequired(false);
|
||||||
|
|
||||||
builder.OwnsOne(f => f.Metadata, b => { b.ToJson(); });
|
builder.OwnsOne(f => f.Metadata, b => { b.ToJson(); });
|
||||||
|
|||||||
@@ -22,8 +22,6 @@ public class Product
|
|||||||
|
|
||||||
public string[]? ThumbnailUrls { get; set; }
|
public string[]? ThumbnailUrls { get; set; }
|
||||||
|
|
||||||
public string[]? Categories { get; set; }
|
|
||||||
|
|
||||||
public ProductMetadata? Metadata { get; set; }
|
public ProductMetadata? Metadata { get; set; }
|
||||||
|
|
||||||
public ProductPrice? Price { get; set; }
|
public ProductPrice? Price { get; set; }
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
namespace LiteCharms.Features.MidrandBooks.Products.Models;
|
||||||
|
|
||||||
|
public class ProductCategory
|
||||||
|
{
|
||||||
|
public long Id { get; set; }
|
||||||
|
|
||||||
|
public long ProductId { get; set; }
|
||||||
|
|
||||||
|
public long CategoryId { get; set; }
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using LiteCharms.Features.MidrandBooks.Abstractions;
|
using LiteCharms.Features.MidrandBooks.Abstractions;
|
||||||
|
using LiteCharms.Features.MidrandBooks.Categories.Models;
|
||||||
using LiteCharms.Features.MidrandBooks.Extensions;
|
using LiteCharms.Features.MidrandBooks.Extensions;
|
||||||
using LiteCharms.Features.MidrandBooks.Postgres;
|
using LiteCharms.Features.MidrandBooks.Postgres;
|
||||||
using LiteCharms.Features.MidrandBooks.Products.Models;
|
using LiteCharms.Features.MidrandBooks.Products.Models;
|
||||||
@@ -8,6 +9,100 @@ namespace LiteCharms.Features.MidrandBooks.Products;
|
|||||||
|
|
||||||
public sealed class ProductService(IDbContextFactory<MidrandBooksDbContext> contextFactory) : IService
|
public sealed class ProductService(IDbContextFactory<MidrandBooksDbContext> contextFactory) : IService
|
||||||
{
|
{
|
||||||
|
public async ValueTask<Result> AddProductCategoryAsync(long productId, long categoryId, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await using var context = await contextFactory.CreateDbContextAsync(cancellationToken);
|
||||||
|
|
||||||
|
if (!await context.Products.AnyAsync(p => p.Id == productId && p.Enabled, cancellationToken))
|
||||||
|
return Result.Fail("Product does not exist");
|
||||||
|
|
||||||
|
if (!await context.Categories.AnyAsync(c => c.Id == categoryId && c.Enabled, cancellationToken))
|
||||||
|
return Result.Fail("Category does not exist");
|
||||||
|
|
||||||
|
if (await context.ProductCategories.AnyAsync(c => c.ProductId == productId && c.CategoryId == categoryId, cancellationToken))
|
||||||
|
return Result.Fail("Category already assigned to product");
|
||||||
|
|
||||||
|
context.ProductCategories.Add(new Entities.ProductCategory
|
||||||
|
{
|
||||||
|
ProductId = productId,
|
||||||
|
CategoryId = categoryId,
|
||||||
|
});
|
||||||
|
|
||||||
|
return await context.SaveChangesAsync(cancellationToken) > 0
|
||||||
|
? Result.Ok()
|
||||||
|
: Result.Fail("Could not add category to product");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return Result.Fail(new Error(ex.Message).CausedBy(ex));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask<Result<Category[]>> GetProductCategoriesAsync(long productId, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await using var context = await contextFactory.CreateDbContextAsync(cancellationToken);
|
||||||
|
|
||||||
|
var categories = await context.ProductCategories.AsNoTracking()
|
||||||
|
.Where(p => p.ProductId == productId)
|
||||||
|
.OrderByDescending(o => o.Id)
|
||||||
|
.Select(p => p.Category)
|
||||||
|
.ToArrayAsync(cancellationToken);
|
||||||
|
|
||||||
|
return categories?.Length > 0
|
||||||
|
? Result.Ok(categories.Select(c => c!.ToModel()).ToArray())
|
||||||
|
: Result.Fail<Category[]>("Failed to get product categories");
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return Result.Fail(new Error(ex.Message).CausedBy(ex));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask<Result> DeleteProductCategoryAsync(long productId, long categoryId, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await using var context = await contextFactory.CreateDbContextAsync(cancellationToken);
|
||||||
|
|
||||||
|
var rowsDeleted = await context.ProductCategories
|
||||||
|
.Where(p => p.ProductId == productId && p.CategoryId == categoryId)
|
||||||
|
.ExecuteDeleteAsync(cancellationToken);
|
||||||
|
|
||||||
|
return rowsDeleted > 0
|
||||||
|
? Result.Ok()
|
||||||
|
: Result.Fail("No product categories were deleted");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return Result.Fail(new Error(ex.Message).CausedBy(ex));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask<Result> DeleteAllProductCategoriesAsync(long productId, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await using var context = await contextFactory.CreateDbContextAsync(cancellationToken);
|
||||||
|
|
||||||
|
var rowsDeleted = await context.ProductCategories
|
||||||
|
.Where(p => p.ProductId == productId)
|
||||||
|
.ExecuteDeleteAsync(cancellationToken);
|
||||||
|
|
||||||
|
return rowsDeleted > 0
|
||||||
|
? Result.Ok()
|
||||||
|
: Result.Fail("No product categories were deleted");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return Result.Fail(new Error(ex.Message).CausedBy(ex));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public async ValueTask<Result> UpdateProductPriceStatusAsync(long productPriceId, bool isEnabled, CancellationToken cancellationToken = default)
|
public async ValueTask<Result> UpdateProductPriceStatusAsync(long productPriceId, bool isEnabled, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -68,9 +163,6 @@ public sealed class ProductService(IDbContextFactory<MidrandBooksDbContext> cont
|
|||||||
if (!string.IsNullOrWhiteSpace(filter.Title))
|
if (!string.IsNullOrWhiteSpace(filter.Title))
|
||||||
query = query.Where(p => EF.Functions.ILike(p.Name!, $"%{filter.Title}%"));
|
query = query.Where(p => EF.Functions.ILike(p.Name!, $"%{filter.Title}%"));
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(filter.Category))
|
|
||||||
query = query.Where(p => p.Categories.Contains(filter.Category));
|
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(filter.Manufacturer))
|
if (!string.IsNullOrWhiteSpace(filter.Manufacturer))
|
||||||
query = query.Where(p => EF.Functions.ILike(p.Metadata!.Manufacturer!, $"%{filter.Manufacturer}%"));
|
query = query.Where(p => EF.Functions.ILike(p.Metadata!.Manufacturer!, $"%{filter.Manufacturer}%"));
|
||||||
|
|
||||||
@@ -152,7 +244,6 @@ public sealed class ProductService(IDbContextFactory<MidrandBooksDbContext> cont
|
|||||||
ImageUrl = request.ImageUrl,
|
ImageUrl = request.ImageUrl,
|
||||||
ThumbnailUrls = request.ThumbnailUrls,
|
ThumbnailUrls = request.ThumbnailUrls,
|
||||||
Metadata = request.Metadata,
|
Metadata = request.Metadata,
|
||||||
Categories = request.Categories,
|
|
||||||
Enabled = true
|
Enabled = true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,6 @@ public sealed class ProductFilter
|
|||||||
|
|
||||||
public string? Title { get; set; }
|
public string? Title { get; set; }
|
||||||
|
|
||||||
public string? Category { get; set; }
|
|
||||||
|
|
||||||
public string? Manufacturer { get; set; }
|
public string? Manufacturer { get; set; }
|
||||||
|
|
||||||
public string? SerialNumber { get; set; }
|
public string? SerialNumber { get; set; }
|
||||||
|
|||||||
Reference in New Issue
Block a user