Add migration for DiscountProductImages table
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 1m53s
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 1m53s
- Created a new table `DiscountProductImages` in the CMS schema. - Added columns for image details including `Title`, `AltText`, `ImagePath`, `ThumbnailPath`, `SortOrder`, `IsActive`, `Created`, `CreatedBy`, `LastModified`, `LastModifiedBy`, and `IsDeleted`. - Established a foreign key relationship with the `DiscountProducts` table. - Created indexes on `DiscountProductId` and a composite index on `DiscountProductId` and `SortOrder`.
This commit is contained in:
+13
@@ -0,0 +1,13 @@
|
||||
using MediatR;
|
||||
|
||||
namespace CMSMicroservice.Application.DiscountShopCQ.Commands.UpdateDiscountProductImage;
|
||||
|
||||
public class UpdateDiscountProductImageCommand : IRequest<bool>
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public string ImagePath { get; set; } = string.Empty;
|
||||
public string ThumbnailPath { get; set; } = string.Empty;
|
||||
public string? Title { get; set; }
|
||||
public string? AltText { get; set; }
|
||||
public bool IsActive { get; set; }
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
using CMSMicroservice.Application.Common.Interfaces;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace CMSMicroservice.Application.DiscountShopCQ.Commands.UpdateDiscountProductImage;
|
||||
|
||||
public class UpdateDiscountProductImageCommandHandler : IRequestHandler<UpdateDiscountProductImageCommand, bool>
|
||||
{
|
||||
private readonly IApplicationDbContext _context;
|
||||
|
||||
public UpdateDiscountProductImageCommandHandler(IApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<bool> Handle(UpdateDiscountProductImageCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var image = await _context.DiscountProductImages
|
||||
.FirstOrDefaultAsync(i => i.Id == request.Id, cancellationToken);
|
||||
|
||||
if (image == null)
|
||||
return false;
|
||||
|
||||
image.ImagePath = request.ImagePath;
|
||||
image.ThumbnailPath = request.ThumbnailPath;
|
||||
image.Title = request.Title;
|
||||
image.AltText = request.AltText;
|
||||
image.IsActive = request.IsActive;
|
||||
|
||||
await _context.SaveChangesAsync(cancellationToken);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user