| 12345678910111213141516171819202122232425262728293031 |
- using Application.Abstractions.Messaging;
- using SharedKernel.Storage;
- using Application.Abstractions.Data;
- using Microsoft.EntityFrameworkCore;
- namespace Application.Features.Faq.Item.Update
- {
- public sealed class Handler(IAppDbContext db, IEditorImageService editorImage) : ICommandHandler<Command>
- {
- public async Task Handle(Command request, CancellationToken ct)
- {
- var item = await db.FaqItem.FirstOrDefaultAsync(c => c.ID == request.ID, ct);
- if (item is null)
- {
- throw new Exception("ÇØ´ç FAQ¸¦ ãÀ» ¼ö ¾ø½À´Ï´Ù.");
- }
- var path = new FileStoragePath(UploadTarget.Editor, UploadFolder.Faq, request.ID);
- item.Update(
- request.CategoryID,
- request.Question,
- await editorImage.UploadAsync(request.Answer, path, ct),
- request.Order,
- request.IsActive
- );
- await db.SaveChangesAsync(ct);
- }
- }
- }
|