Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e6e0475db1 | |||
| be9c83c8a3 | |||
| 65687d231e |
+1
-1
@@ -41,7 +41,7 @@ steps:
|
|||||||
\"tag_name\": \"$VERSION\",
|
\"tag_name\": \"$VERSION\",
|
||||||
\"target_commitish\": \"${DRONE_COMMIT_SHA}\",
|
\"target_commitish\": \"${DRONE_COMMIT_SHA}\",
|
||||||
\"name\": \"Library Suite $VERSION\",
|
\"name\": \"Library Suite $VERSION\",
|
||||||
\"body\": \"### Published NuGet Packages\nAll packages versioned as **$VERSION**:\n* LiteCharms.Abstractions\n* LiteCharms.Features\n\n[View in Nexus](https://nexus.khongisa.co.za/repository/nuget-group/)\",
|
\"body\": \"### Published NuGet Packages\nAll packages versioned as **$VERSION**:\n* LiteCharms.Features\n\n[View in Nexus](https://nexus.khongisa.co.za/repository/nuget-group/)\",
|
||||||
\"draft\": false,
|
\"draft\": false,
|
||||||
\"prerelease\": false
|
\"prerelease\": false
|
||||||
}"
|
}"
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using LiteCharms.Features.Abstractions;
|
using LiteCharms.Features.Abstractions;
|
||||||
using LiteCharms.Features.Quartz.Abstractions;
|
using LiteCharms.Features.Quartz.Abstractions;
|
||||||
using static LiteCharms.Features.Extensions.Timezones;
|
|
||||||
|
|
||||||
namespace LiteCharms.Features.Quartz;
|
namespace LiteCharms.Features.Quartz;
|
||||||
|
|
||||||
@@ -47,12 +46,12 @@ public class JobOrchestrator(ISchedulerFactory schedulerFactory) : IJobOrchestra
|
|||||||
.StoreDurably()
|
.StoreDurably()
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
var now = SouthAfricanTimeZone.UtcNow();
|
var now = DateTime.UtcNow;
|
||||||
|
|
||||||
var trigger = global::Quartz.TriggerBuilder.Create()
|
var trigger = global::Quartz.TriggerBuilder.Create()
|
||||||
.WithIdentity(triggerKey)
|
.WithIdentity(triggerKey)
|
||||||
.WithDescription($"Scheduled via Main Job at {now:g}")
|
.WithDescription($"Scheduled via Main Job at {now:g} UTC")
|
||||||
.WithCronSchedule(cronExpression, cron => cron.InTimeZone(SouthAfricanTimeZone)
|
.WithCronSchedule(cronExpression, cron => cron
|
||||||
.WithMisfireHandlingInstructionFireAndProceed())
|
.WithMisfireHandlingInstructionFireAndProceed())
|
||||||
.StartAt(now)
|
.StartAt(now)
|
||||||
.Build();
|
.Build();
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using LiteCharms.Features.Abstractions;
|
using LiteCharms.Features.Abstractions;
|
||||||
|
using LiteCharms.Features.Mediator;
|
||||||
|
|
||||||
namespace LiteCharms.Features.Quartz;
|
namespace LiteCharms.Features.Quartz;
|
||||||
|
|
||||||
@@ -13,9 +14,12 @@ public class MediatorJob<TNotification>(IMediator mediator) : IJob where TNotifi
|
|||||||
|
|
||||||
var notification = JsonSerializer.Deserialize<TNotification>(data);
|
var notification = JsonSerializer.Deserialize<TNotification>(data);
|
||||||
|
|
||||||
if(notification is null) return;
|
if (notification is null) return;
|
||||||
|
|
||||||
if(notification is TNotification)
|
using var activity = MediatorTelemetry.Source.StartActivity($"Quartz: {typeof(TNotification).Name}");
|
||||||
await mediator.Publish(notification, context.CancellationToken);
|
|
||||||
|
activity?.SetTag("event.correlation_id", notification.CorrelationId);
|
||||||
|
|
||||||
|
await mediator.Publish(notification, context.CancellationToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,6 @@ public class PackageService(IDbContextFactory<ShopDbContext> contextFactory)
|
|||||||
|
|
||||||
var newPackage = context.Packages.Add(new Entities.Package
|
var newPackage = context.Packages.Add(new Entities.Package
|
||||||
{
|
{
|
||||||
UpdatedAt = null,
|
|
||||||
Name = name,
|
Name = name,
|
||||||
Summary = summary,
|
Summary = summary,
|
||||||
Description = description,
|
Description = description,
|
||||||
@@ -206,7 +205,7 @@ public class PackageService(IDbContextFactory<ShopDbContext> contextFactory)
|
|||||||
package.Summary = summary;
|
package.Summary = summary;
|
||||||
package.Description = description;
|
package.Description = description;
|
||||||
package.ImageUrl = ImageUrl;
|
package.ImageUrl = ImageUrl;
|
||||||
package.UpdatedAt = SouthAfricanTimeZone.UtcNow();
|
package.UpdatedAt = DateTime.UtcNow;
|
||||||
|
|
||||||
return await context.SaveChangesAsync(cancellationToken) > 0
|
return await context.SaveChangesAsync(cancellationToken) > 0
|
||||||
? Result.Ok()
|
? Result.Ok()
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ public class LeadService(IDbContextFactory<ShopDbContext> contextFactory)
|
|||||||
return Result.Fail(new Error($"Lead with ID {leadId} not found."));
|
return Result.Fail(new Error($"Lead with ID {leadId} not found."));
|
||||||
|
|
||||||
lead.Status = status;
|
lead.Status = status;
|
||||||
|
lead.UpdatedAt = DateTime.UtcNow;
|
||||||
|
|
||||||
return await context.SaveChangesAsync(cancellationToken) > 0
|
return await context.SaveChangesAsync(cancellationToken) > 0
|
||||||
? Result.Ok()
|
? Result.Ok()
|
||||||
|
|||||||
+4
-5
@@ -1,7 +1,6 @@
|
|||||||
using LiteCharms.Features.Email;
|
using LiteCharms.Features.Email;
|
||||||
using LiteCharms.Features.Shop.Notifications.Entities;
|
using LiteCharms.Features.Shop.Notifications.Models;
|
||||||
using LiteCharms.Features.Shop.Postgres;
|
using LiteCharms.Features.Shop.Postgres;
|
||||||
using static LiteCharms.Features.Extensions.Timezones;
|
|
||||||
|
|
||||||
namespace LiteCharms.Features.Shop.Notifications.Events.Handlers;
|
namespace LiteCharms.Features.Shop.Notifications.Events.Handlers;
|
||||||
|
|
||||||
@@ -17,8 +16,8 @@ public class ProcessEmailNotificationsEventHandler(IDbContextFactory<ShopDbConte
|
|||||||
using var context = await contextFactory.CreateDbContextAsync(cancellationToken);
|
using var context = await contextFactory.CreateDbContextAsync(cancellationToken);
|
||||||
|
|
||||||
var notifications = await context.Notifications
|
var notifications = await context.Notifications
|
||||||
.OrderByDescending(o => o.Priority)
|
.OrderByDescending(o => o.CreatedAt)
|
||||||
.ThenBy(o => o.CreatedAt)
|
.ThenBy(o => o.Priority)
|
||||||
.Where(n => n.CorrelationIdType == CorrelationIdTypes.Email)
|
.Where(n => n.CorrelationIdType == CorrelationIdTypes.Email)
|
||||||
.Where(n => n.Direction == NotificationDirection.Outgoing)
|
.Where(n => n.Direction == NotificationDirection.Outgoing)
|
||||||
.Take(message.MaxRecords)
|
.Take(message.MaxRecords)
|
||||||
@@ -44,7 +43,7 @@ public class ProcessEmailNotificationsEventHandler(IDbContextFactory<ShopDbConte
|
|||||||
}
|
}
|
||||||
|
|
||||||
notification.Processed = true;
|
notification.Processed = true;
|
||||||
notification.UpdatedAt = SouthAfricanTimeZone.UtcNow();
|
notification.UpdatedAt = DateTime.UtcNow;
|
||||||
}
|
}
|
||||||
|
|
||||||
await context.SaveChangesAsync(cancellationToken);
|
await context.SaveChangesAsync(cancellationToken);
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
using LiteCharms.Features.Models;
|
using LiteCharms.Features.Models;
|
||||||
using LiteCharms.Features.Shop.Orders.Models;
|
using LiteCharms.Features.Shop.Orders.Models;
|
||||||
using LiteCharms.Features.Shop.Postgres;
|
using LiteCharms.Features.Shop.Postgres;
|
||||||
using static LiteCharms.Features.Extensions.Timezones;
|
|
||||||
|
|
||||||
namespace LiteCharms.Features.Shop.Orders;
|
namespace LiteCharms.Features.Shop.Orders;
|
||||||
|
|
||||||
@@ -241,7 +240,7 @@ public class OrderService(IDbContextFactory<ShopDbContext> contextFactory)
|
|||||||
return Result.Fail(new Error($"Order {request.OrderId} not found"));
|
return Result.Fail(new Error($"Order {request.OrderId} not found"));
|
||||||
|
|
||||||
order.Status = request.Status;
|
order.Status = request.Status;
|
||||||
order.UpdatedAt = SouthAfricanTimeZone.UtcNow();
|
order.UpdatedAt = DateTime.UtcNow;
|
||||||
|
|
||||||
if(!string.IsNullOrWhiteSpace(request.InvoiceUrl)) order.InvoiceUrl = request.InvoiceUrl;
|
if(!string.IsNullOrWhiteSpace(request.InvoiceUrl)) order.InvoiceUrl = request.InvoiceUrl;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
using LiteCharms.Features.Extensions;
|
using LiteCharms.Features.Extensions;
|
||||||
using LiteCharms.Features.Shop.Postgres;
|
using LiteCharms.Features.Shop.Postgres;
|
||||||
using LiteCharms.Features.Shop.Products.Models;
|
using LiteCharms.Features.Shop.Products.Models;
|
||||||
using static LiteCharms.Features.Extensions.Timezones;
|
|
||||||
|
|
||||||
namespace LiteCharms.Features.Shop.Products;
|
namespace LiteCharms.Features.Shop.Products;
|
||||||
|
|
||||||
@@ -19,7 +18,7 @@ public class ProductService(IDbContextFactory<ShopDbContext> contextFactory)
|
|||||||
return Result.Fail($"Could not find product price with ID {productPriceId}");
|
return Result.Fail($"Could not find product price with ID {productPriceId}");
|
||||||
|
|
||||||
price.Active = active;
|
price.Active = active;
|
||||||
price.UpdatedAt = SouthAfricanTimeZone.UtcNow();
|
price.UpdatedAt = DateTime.UtcNow;
|
||||||
|
|
||||||
return await context.SaveChangesAsync(cancellationToken) > 0
|
return await context.SaveChangesAsync(cancellationToken) > 0
|
||||||
? Result.Ok()
|
? Result.Ok()
|
||||||
@@ -200,7 +199,7 @@ public class ProductService(IDbContextFactory<ShopDbContext> contextFactory)
|
|||||||
return Result.Fail($"Could not find product price with ID {productPriceId}");
|
return Result.Fail($"Could not find product price with ID {productPriceId}");
|
||||||
|
|
||||||
existingPrice.Active = false;
|
existingPrice.Active = false;
|
||||||
existingPrice.UpdatedAt = SouthAfricanTimeZone.UtcNow();
|
existingPrice.UpdatedAt = DateTime.UtcNow;
|
||||||
|
|
||||||
if (!(await context.SaveChangesAsync(cancellationToken) > 0))
|
if (!(await context.SaveChangesAsync(cancellationToken) > 0))
|
||||||
return Result.Fail<Guid>($"Failed to deactivate existing price of ID {productPriceId}, try again later");
|
return Result.Fail<Guid>($"Failed to deactivate existing price of ID {productPriceId}, try again later");
|
||||||
@@ -212,7 +211,7 @@ public class ProductService(IDbContextFactory<ShopDbContext> contextFactory)
|
|||||||
var deactivatedPrice = await context.ProductPrices.FirstOrDefaultAsync(p => p.Id == productPriceId, cancellationToken);
|
var deactivatedPrice = await context.ProductPrices.FirstOrDefaultAsync(p => p.Id == productPriceId, cancellationToken);
|
||||||
|
|
||||||
existingPrice.Active = true;
|
existingPrice.Active = true;
|
||||||
existingPrice.UpdatedAt = SouthAfricanTimeZone.UtcNow();
|
existingPrice.UpdatedAt = DateTime.UtcNow;
|
||||||
|
|
||||||
return await context.SaveChangesAsync(cancellationToken) > 0
|
return await context.SaveChangesAsync(cancellationToken) > 0
|
||||||
? Result.Fail<Guid>("Reverted to old price, creation of new price failed")
|
? Result.Fail<Guid>("Reverted to old price, creation of new price failed")
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
using LiteCharms.Features.Models;
|
using LiteCharms.Features.Models;
|
||||||
using LiteCharms.Features.Shop.Postgres;
|
using LiteCharms.Features.Shop.Postgres;
|
||||||
using LiteCharms.Features.Shop.Quotes.Models;
|
using LiteCharms.Features.Shop.Quotes.Models;
|
||||||
using static LiteCharms.Features.Extensions.Timezones;
|
|
||||||
|
|
||||||
namespace LiteCharms.Features.Shop.Quotes;
|
namespace LiteCharms.Features.Shop.Quotes;
|
||||||
|
|
||||||
@@ -26,6 +25,7 @@ public class QuoteService(IDbContextFactory<ShopDbContext> contextFactory)
|
|||||||
return Result.Fail(new Error($"Quote with id {quoteId} is already assigned to order with id {orderId}"));
|
return Result.Fail(new Error($"Quote with id {quoteId} is already assigned to order with id {orderId}"));
|
||||||
|
|
||||||
quote.OrderId = orderId;
|
quote.OrderId = orderId;
|
||||||
|
quote.UpdatedAt = DateTime.UtcNow;
|
||||||
|
|
||||||
return await context.SaveChangesAsync(cancellationToken) > 0
|
return await context.SaveChangesAsync(cancellationToken) > 0
|
||||||
? Result.Ok()
|
? Result.Ok()
|
||||||
@@ -52,6 +52,7 @@ public class QuoteService(IDbContextFactory<ShopDbContext> contextFactory)
|
|||||||
return Result.Fail(new Error($"Shopping Cart with id {shoppingCartId} not found"));
|
return Result.Fail(new Error($"Shopping Cart with id {shoppingCartId} not found"));
|
||||||
|
|
||||||
quote.ShoppingCartId = shoppingCartId;
|
quote.ShoppingCartId = shoppingCartId;
|
||||||
|
quote.UpdatedAt = DateTime.UtcNow;
|
||||||
|
|
||||||
return await context.SaveChangesAsync(cancellationToken) > 0
|
return await context.SaveChangesAsync(cancellationToken) > 0
|
||||||
? Result.Ok()
|
? Result.Ok()
|
||||||
@@ -140,7 +141,7 @@ public class QuoteService(IDbContextFactory<ShopDbContext> contextFactory)
|
|||||||
return Result.Fail(new Error("Quote not found."));
|
return Result.Fail(new Error("Quote not found."));
|
||||||
|
|
||||||
quote.Status = status;
|
quote.Status = status;
|
||||||
quote.UpdatedAt = SouthAfricanTimeZone.UtcNow();
|
quote.UpdatedAt = DateTime.UtcNow;
|
||||||
|
|
||||||
return await context.SaveChangesAsync(cancellationToken) > 0
|
return await context.SaveChangesAsync(cancellationToken) > 0
|
||||||
? Result.Ok()
|
? Result.Ok()
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
using LiteCharms.Features.Extensions;
|
using LiteCharms.Features.Extensions;
|
||||||
using LiteCharms.Features.Shop.Postgres;
|
using LiteCharms.Features.Shop.Postgres;
|
||||||
using LiteCharms.Features.Shop.ShoppingCarts.Models;
|
using LiteCharms.Features.Shop.ShoppingCarts.Models;
|
||||||
using static LiteCharms.Features.Extensions.Timezones;
|
|
||||||
|
|
||||||
namespace LiteCharms.Features.Shop.ShoppingCarts;
|
namespace LiteCharms.Features.Shop.ShoppingCarts;
|
||||||
|
|
||||||
@@ -284,7 +283,7 @@ public class ShoppingCartService(IDbContextFactory<ShopDbContext> contextFactory
|
|||||||
return Result.Fail($"Shopping cart item could not be found with id {shoppingCartItemId}");
|
return Result.Fail($"Shopping cart item could not be found with id {shoppingCartItemId}");
|
||||||
|
|
||||||
item.Quantity = quantity;
|
item.Quantity = quantity;
|
||||||
item.UpdatedAt = SouthAfricanTimeZone.UtcNow();
|
item.UpdatedAt = DateTime.UtcNow;
|
||||||
|
|
||||||
return await context.SaveChangesAsync(cancellationToken) > 0
|
return await context.SaveChangesAsync(cancellationToken) > 0
|
||||||
? Result.Ok()
|
? Result.Ok()
|
||||||
|
|||||||
Reference in New Issue
Block a user