Migrated database changes after refactoring the Notification model
This commit is contained in:
+3
-2
@@ -1,6 +1,7 @@
|
||||
using LiteCharms.Models.Configuraton.Email;
|
||||
using LiteCharms.Features.Email.Commands;
|
||||
using LiteCharms.Models.Configuraton.Email;
|
||||
|
||||
namespace LiteCharms.Features.Utilities.Commands.Handlers;
|
||||
namespace LiteCharms.Features.Email.Commands.Handlers;
|
||||
|
||||
public class SendEmailCommandHandler(IOptions<SmtpSettings> smtpOptions) : IRequestHandler<SendEmailCommand, Result>
|
||||
{
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
namespace LiteCharms.Features.Utilities.Commands;
|
||||
namespace LiteCharms.Features.Email.Commands;
|
||||
|
||||
public class SendEmailCommand : IRequest<Result>
|
||||
{
|
||||
@@ -1,4 +1,4 @@
|
||||
using LiteCharms.Features.Utilities.Commands;
|
||||
using LiteCharms.Features.Utilities.Hash.Commands;
|
||||
using LiteCharms.Infrastructure.Database;
|
||||
|
||||
namespace LiteCharms.Features.Leads.Commands.Handlers;
|
||||
|
||||
@@ -61,4 +61,8 @@
|
||||
<ProjectReference Include="..\LiteCharms.Infrastructure\LiteCharms.Infrastructure.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Email\Notifications\Handlers\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
+6
@@ -17,6 +17,12 @@ public class UpdateNotificationCommandHandler(IDbContextFactory<ShopDbContext> c
|
||||
|
||||
notification.Processed = request.Processed;
|
||||
|
||||
if (request.HasError)
|
||||
{
|
||||
notification.HasError = request.HasError;
|
||||
notification.Errors = request.Errors;
|
||||
}
|
||||
|
||||
return await context.SaveChangesAsync(cancellationToken) > 0
|
||||
? Result.Ok()
|
||||
: Result.Fail(new Error($"Failed to update notification with id {request.NotificationId}."));
|
||||
|
||||
@@ -6,13 +6,19 @@ public class UpdateNotificationCommand : IRequest<Result>
|
||||
|
||||
public bool Processed { get; set; }
|
||||
|
||||
private UpdateNotificationCommand(Guid notificationId, bool processed)
|
||||
public bool HasError { get; set; }
|
||||
|
||||
public string[]? Errors { get; set; }
|
||||
|
||||
private UpdateNotificationCommand(Guid notificationId, bool processed, bool hasError = false, string[]? errors = null)
|
||||
{
|
||||
NotificationId = notificationId;
|
||||
Processed = processed;
|
||||
HasError = hasError;
|
||||
Errors = errors;
|
||||
}
|
||||
|
||||
public static UpdateNotificationCommand Create(Guid notificationId, bool processed)
|
||||
public static UpdateNotificationCommand Create(Guid notificationId, bool processed, bool hasError = false, string[]? errors = null)
|
||||
{
|
||||
if(notificationId == Guid.Empty)
|
||||
throw new ArgumentException("Notification ID cannot be empty.", nameof(notificationId));
|
||||
|
||||
@@ -8,14 +8,26 @@ public class CreateOrderCommand : IRequest<Result<Guid>>
|
||||
|
||||
public Guid? QuoteId { get; set; }
|
||||
|
||||
private CreateOrderCommand(Guid customerId, Guid shoppingCartId, Guid? quoteId = null)
|
||||
public string[]? Requirements { get; set; }
|
||||
|
||||
public string[]? Notes { get; set; }
|
||||
|
||||
public string[]? Terms { get; set; }
|
||||
|
||||
public bool DepositRequired { get; set; }
|
||||
|
||||
private CreateOrderCommand(Guid customerId, Guid shoppingCartId, bool depositRequired, Guid? quoteId = null, string[]? requirements = null, string[]? notes = null, string[]? terms = null)
|
||||
{
|
||||
CustomerId = customerId;
|
||||
ShoppingCartId = shoppingCartId;
|
||||
DepositRequired = depositRequired;
|
||||
QuoteId = quoteId;
|
||||
Requirements = requirements;
|
||||
Notes = notes;
|
||||
Terms = terms;
|
||||
}
|
||||
|
||||
public static CreateOrderCommand Create(Guid customerId, Guid shoppingCartId, Guid? quoteId = null)
|
||||
public static CreateOrderCommand Create(Guid customerId, Guid shoppingCartId, bool depositRequired, Guid? quoteId = null, string[]? requirements = null, string[]? notes = null, string[]? terms = null)
|
||||
{
|
||||
if (customerId == Guid.Empty)
|
||||
throw new ArgumentException("CustomerId is required.", nameof(customerId));
|
||||
@@ -23,6 +35,6 @@ public class CreateOrderCommand : IRequest<Result<Guid>>
|
||||
if (shoppingCartId == Guid.Empty)
|
||||
throw new ArgumentException("ShoppingCartId is required.", nameof(shoppingCartId));
|
||||
|
||||
return new(customerId, shoppingCartId, quoteId);
|
||||
return new(customerId, shoppingCartId, depositRequired, quoteId, requirements, notes, terms);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using LiteCharms.Infrastructure.Database;
|
||||
using LiteCharms.Models;
|
||||
|
||||
namespace LiteCharms.Features.Orders.Commands.Handlers;
|
||||
|
||||
@@ -21,10 +22,15 @@ public class CreateOrderCommandHandler(IDbContextFactory<ShopDbContext> contextF
|
||||
|
||||
var newOrder = context.Orders.Add(new Entities.Order
|
||||
{
|
||||
CreatedAt = DateTime.UtcNow,
|
||||
Status = OrderStatus.Pending,
|
||||
CustomerId = request.CustomerId,
|
||||
ShoppingCartId = request.ShoppingCartId,
|
||||
QuoteId = request.QuoteId,
|
||||
CreatedAt = DateTime.UtcNow
|
||||
ShoppingCartId = request.ShoppingCartId,
|
||||
DepositRequired = request.DepositRequired,
|
||||
Requirements = request.Requirements,
|
||||
Notes = request.Notes,
|
||||
Terms = request.Terms
|
||||
});
|
||||
|
||||
return await context.SaveChangesAsync(cancellationToken) > 0
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
namespace LiteCharms.Features.Utilities.Commands;
|
||||
namespace LiteCharms.Features.Utilities.Hash.Commands;
|
||||
|
||||
public class ComputeHashCommand : IRequest<Result<string>>
|
||||
{
|
||||
+3
-1
@@ -1,4 +1,6 @@
|
||||
namespace LiteCharms.Features.Utilities.Commands.Handlers;
|
||||
using LiteCharms.Features.Utilities.Hash.Commands;
|
||||
|
||||
namespace LiteCharms.Features.Utilities.Hash.Commands.Handlers;
|
||||
|
||||
public class ComputeHashCommandHandler : IRequestHandler<ComputeHashCommand, Result<string>>
|
||||
{
|
||||
Reference in New Issue
Block a user