using Blazorise; using FoodsharingSiegen.Contracts.Entity; using FoodsharingSiegen.Server.BaseClasses; using FoodsharingSiegen.Server.Data.Service; using Microsoft.AspNetCore.Components; namespace FoodsharingSiegen.Server.Dialogs { public partial class ViewImagesDialog : FsBase { [Inject] public ProspectService ProspectService { get; set; } = null!; [Parameter] public Prospect? Prospect { get; set; } private bool _isLoading = true; private List _images = new(); private int? SelectedImageIndex { get; set; } protected override async Task OnInitializedAsync() { if (Prospect != null) { var result = await ProspectService.GetVerificationImagesAsync(Prospect.Id); if (result.Success && result.Data != null) { foreach (var image in result.Data) { var base64 = Convert.ToBase64String(image.ImageData); var imgSrc = $"data:{image.ContentType};base64,{base64}"; _images.Add(imgSrc); } } } _isLoading = false; } public static async Task ShowAsync(IModalService modalService, Prospect prospect) { var title = $"Bilder für {prospect.Name}"; var action = new Action>(b => { b.Add(nameof(Prospect), prospect); }); await modalService.Show(title, action, new ModalInstanceOptions { Size = ModalSize.ExtraLarge }); } } }