using Microsoft.EntityFrameworkCore; using PnvPanel.Application.Common.Interfaces; using PnvPanel.Application.Common.Messaging; using PnvPanel.Application.Common.Models; namespace PnvPanel.Application.Admin.Apps; public sealed class UpdateAppCommandHandler(IAppDbContext dbContext) : ICommandHandler> { public async Task> Handle(UpdateAppCommand command, CancellationToken cancellationToken) { var app = await dbContext.ClientApps.FirstOrDefaultAsync(a => a.Id == command.AppId, cancellationToken); if (app is null) return Result.Failure(AppErrors.NotFound); app.Update( command.Name, new Uri(command.DownloadUrl, UriKind.Absolute), command.OperatingSystem, command.Description, command.IconUrl, command.SortOrder, command.IsEnabled); return Result.Success(AdminAppDto.FromDomain(app)); } }