Qr code with Company AffiliateId
This commit is contained in:
parent
0662bb77a7
commit
77704ad7cd
|
|
@ -1,9 +1,13 @@
|
|||
using AyCode.Services.Loggers;
|
||||
using DevExpress.Blazor;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Runtime.CompilerServices;
|
||||
using TIAM.Core.Enums;
|
||||
using TIAM.Entities.Products;
|
||||
using TIAM.Entities.ServiceProviders;
|
||||
using TIAM.Services;
|
||||
using TIAMWebApp.Shared.Application.Interfaces;
|
||||
using TIAMWebApp.Shared.Application.Models;
|
||||
|
|
@ -178,9 +182,47 @@ namespace TIAMSharedUI.Pages.User.Hotels
|
|||
s.Phone
|
||||
};
|
||||
});
|
||||
var productOwner = await adminSignalRClient.GetByIdAsync<List<Company>>(SignalRTags.GetCompaniesById, hotel.ServiceProviderId);
|
||||
if(productOwner!=null)
|
||||
{
|
||||
ImageSource = await ServiceProviderDataService.GetQRCodeByProductIdAsync(productOwner[0].AffiliateId);
|
||||
}
|
||||
else
|
||||
{
|
||||
int width = 128;
|
||||
int height = 128;
|
||||
string base64String = "";
|
||||
// Create a new bitmap
|
||||
using (Bitmap bitmap = new Bitmap(width, height))
|
||||
{
|
||||
// Set all pixels to black
|
||||
using (Graphics gfx = Graphics.FromImage(bitmap))
|
||||
{
|
||||
gfx.Clear(Color.Black);
|
||||
}
|
||||
|
||||
// Convert bitmap to Base64 string
|
||||
base64String = BitmapToBase64(bitmap);
|
||||
Console.WriteLine(base64String);
|
||||
}
|
||||
|
||||
ImageSource = base64String;
|
||||
}
|
||||
//SKBitmap bitmap = await ServiceProviderDataService.GetQRCodeByProductIdAsync(Guid.NewGuid());
|
||||
ImageSource = await ServiceProviderDataService.GetQRCodeByProductIdAsync(Id);
|
||||
|
||||
}
|
||||
|
||||
private string BitmapToBase64(Bitmap bitmap)
|
||||
{
|
||||
using (MemoryStream memoryStream = new MemoryStream())
|
||||
{
|
||||
// Save bitmap to memory stream
|
||||
bitmap.Save(memoryStream, ImageFormat.Png);
|
||||
|
||||
// Convert memory stream to Base64 string
|
||||
byte[] imageBytes = memoryStream.ToArray();
|
||||
return Convert.ToBase64String(imageBytes);
|
||||
}
|
||||
}
|
||||
|
||||
void Grid_CustomizeElement(GridCustomizeElementEventArgs e)
|
||||
|
|
|
|||
Loading…
Reference in New Issue