fixes, improvements
This commit is contained in:
parent
5839195469
commit
444c1a5ef0
|
|
@ -261,7 +261,7 @@ namespace TIAM.Database.Test
|
|||
Assert.IsTrue(product.UserProductMappings[0].Permissions == 2);
|
||||
|
||||
var addressId = product.Profile.AddressId;
|
||||
Assert.IsTrue(await Dal.RemoveProductAsync(product)); //mielőbb kitöröljük, h ne maradjon szemét a db-ben - J.
|
||||
Assert.IsTrue(await Dal.RemoveProductAsync(product.Id)); //mielőbb kitöröljük, h ne maradjon szemét a db-ben - J.
|
||||
|
||||
Assert.IsNull(await Dal.GetProfileByIdAsync(product.ProfileId));
|
||||
Assert.IsNull(await Dal.GetAddressByIdAsync(addressId));
|
||||
|
|
@ -383,7 +383,7 @@ namespace TIAM.Database.Test
|
|||
Assert.IsTrue(await Dal.UpdateCompanyAsync(company));
|
||||
|
||||
var addressId = company.Profile.AddressId;
|
||||
Assert.IsTrue(await Dal.RemoveCompanyAsync(company)); //mielőbb kitöröljük, h ne maradjon szemét a db-ben - J.
|
||||
Assert.IsTrue(await Dal.RemoveCompanyAsync(company.Id)); //mielőbb kitöröljük, h ne maradjon szemét a db-ben - J.
|
||||
|
||||
Assert.IsNull(await Dal.GetProfileByIdAsync(company.ProfileId));
|
||||
Assert.IsNull(await Dal.GetAddressByIdAsync(addressId));
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ namespace TIAM.Database.DataLayers.Admins
|
|||
public Task<bool> AddProductAsync(Product product) => TransactionAsync(ctx => ctx.AddProduct(product));
|
||||
|
||||
public Task<bool> UpdateProductAsync(Product product) => TransactionAsync(ctx => ctx.UpdateProduct(product));
|
||||
public Task<bool> RemoveProductAsync(Product product) => TransactionAsync(ctx => ctx.RemoveProduct(product));
|
||||
//public Task<bool> RemoveProductAsync(Product product) => TransactionAsync(ctx => ctx.RemoveProduct(product.Id));
|
||||
public Task<bool> RemoveProductAsync(Guid productId) => TransactionAsync(ctx => ctx.RemoveProduct(productId));
|
||||
|
||||
public UserProductMapping? GetUserProductMappingById(Guid userProductMappingId, bool autoInclude = true) => Session(ctx => ctx.GetUserProductMappingById(userProductMappingId, autoInclude));
|
||||
|
|
@ -252,7 +252,7 @@ namespace TIAM.Database.DataLayers.Admins
|
|||
//13. (IserviceProviderDataService) delete service provider
|
||||
public Task<bool> RemoveCompanyAsync(Guid companyId) => TransactionAsync(ctx => ctx.RemoveProductsByCompanyId(companyId) && ctx.RemoveCompany(companyId));
|
||||
|
||||
public Task<bool> RemoveCompanyAsync(Company company) => RemoveCompanyAsync(company.Id);
|
||||
//public Task<bool> RemoveCompanyAsync(Company company) => RemoveCompanyAsync(company.Id);
|
||||
#endregion
|
||||
|
||||
#region PermissionTypes
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ public static class ProductDbSetExtensions
|
|||
return ctx.Products.Update(product).State == EntityState.Modified;
|
||||
}
|
||||
|
||||
public static bool RemoveProduct(this IProductDbSet ctx, Product product)
|
||||
private static bool RemoveProduct(this IProductDbSet ctx, Product product)
|
||||
{
|
||||
ctx.RemoveProfile(product.ProfileId);
|
||||
ctx.RemoveUserProductMappingsByProductId(product.Id);
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ namespace TIAMWebApp.Server.Controllers
|
|||
case TrackingState.Update:
|
||||
return await adminDal.UpdateCompanyAsync(company);
|
||||
case TrackingState.Remove:
|
||||
return await adminDal.RemoveCompanyAsync(company);
|
||||
return await adminDal.RemoveCompanyAsync(company.Id);
|
||||
|
||||
case TrackingState.Get:
|
||||
case TrackingState.GetAll:
|
||||
|
|
@ -386,39 +386,31 @@ namespace TIAMWebApp.Server.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpPost]
|
||||
[Route(APIUrls.GetQrCodeByProductIdRouteName)]
|
||||
[Tags("In-Progress", "Product")]
|
||||
public async Task<IActionResult> GetQRCodeByProductId([FromBody] Guid productId)
|
||||
//[HttpPost]
|
||||
//[Route(APIUrls.AddProductRouteName)]
|
||||
//[Tags("In-Progress", "Product")]
|
||||
[SignalR(SignalRTags.UpdateProduct)]
|
||||
public async Task<Product> UpdateProduct([FromBody] Product product)
|
||||
{
|
||||
_logger.Info(@"GetQRCode called");
|
||||
_logger.Info(@"UpdateProduct called");
|
||||
|
||||
if (productId == Guid.Empty)
|
||||
{
|
||||
return BadRequest("Product is required");
|
||||
}
|
||||
else
|
||||
{
|
||||
//var result = _serviceProviderDal.GetQRCodeAsync(productId);
|
||||
|
||||
var qrGenerator = new QRCodeGenerator();
|
||||
var qrCodeData = qrGenerator.CreateQrCode($"https://touriam.com/{productId}", QRCodeGenerator.ECCLevel.Q);
|
||||
var qrCode = new QRCode(qrCodeData);
|
||||
//Bitmap qrCodeImage = qrCode.GetGraphic(20);
|
||||
var rootpath = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), "assets");
|
||||
var qrCodeImage = qrCode.GetGraphic(20, Color.DarkMagenta, Color.White, (Bitmap)Bitmap.FromFile(rootpath + "/myimage.png"));
|
||||
_logger.Info($@"qrCodeLogo: {rootpath}/myimage.png");
|
||||
var ms = new MemoryStream();
|
||||
qrCodeImage.Save(ms, ImageFormat.Jpeg);
|
||||
var byteImage = ms.ToArray();
|
||||
|
||||
var sigBase64 = Convert.ToBase64String(byteImage); // Get Base64
|
||||
|
||||
return Ok(sigBase64);
|
||||
}
|
||||
var result = await adminDal.UpdateProductAsync(product);
|
||||
return product;
|
||||
}
|
||||
|
||||
//[HttpPost]
|
||||
//[Route(APIUrls.AddProductRouteName)]
|
||||
//[Tags("In-Progress", "Product")]
|
||||
[SignalR(SignalRTags.RemoveProduct)]
|
||||
public async Task<Product> RemoveProduct([FromBody] Product product)
|
||||
{
|
||||
_logger.Info(@"RemoveProduct called");
|
||||
|
||||
var result = await adminDal.RemoveProductAsync(product.Id);
|
||||
return product;
|
||||
}
|
||||
|
||||
|
||||
[NonAction]
|
||||
[ApiExplorerSettings(IgnoreApi = true)]
|
||||
public async Task<string> GetProductsByOwnerId(Guid serviceProviderId)
|
||||
|
|
@ -484,5 +476,38 @@ namespace TIAMWebApp.Server.Controllers
|
|||
var product = await GetProductById(productId);
|
||||
return product == null ? [] : [product];
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpPost]
|
||||
[Route(APIUrls.GetQrCodeByProductIdRouteName)]
|
||||
[Tags("In-Progress", "Product")]
|
||||
public async Task<IActionResult> GetQRCodeByProductId([FromBody] Guid productId)
|
||||
{
|
||||
_logger.Info(@"GetQRCode called");
|
||||
|
||||
if (productId == Guid.Empty)
|
||||
{
|
||||
return BadRequest("Product is required");
|
||||
}
|
||||
else
|
||||
{
|
||||
//var result = _serviceProviderDal.GetQRCodeAsync(productId);
|
||||
|
||||
var qrGenerator = new QRCodeGenerator();
|
||||
var qrCodeData = qrGenerator.CreateQrCode($"https://touriam.com/{productId}", QRCodeGenerator.ECCLevel.Q);
|
||||
var qrCode = new QRCode(qrCodeData);
|
||||
//Bitmap qrCodeImage = qrCode.GetGraphic(20);
|
||||
var rootpath = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), "assets");
|
||||
var qrCodeImage = qrCode.GetGraphic(20, Color.DarkMagenta, Color.White, (Bitmap)Bitmap.FromFile(rootpath + "/myimage.png"));
|
||||
_logger.Info($@"qrCodeLogo: {rootpath}/myimage.png");
|
||||
var ms = new MemoryStream();
|
||||
qrCodeImage.Save(ms, ImageFormat.Jpeg);
|
||||
var byteImage = ms.ToArray();
|
||||
|
||||
var sigBase64 = Convert.ToBase64String(byteImage); // Get Base64
|
||||
|
||||
return Ok(sigBase64);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -44,7 +44,7 @@ builder.Services.AddScoped<MessageAPIController>();
|
|||
builder.Services.AddScoped<ProfileAPIController>();
|
||||
|
||||
|
||||
builder.Services.AddSignalR(options => options.MaximumReceiveMessageSize = 128 * 1024);//.AddMessagePackProtocol(options => options.SerializerOptions = MessagePackSerializerOptions.Standard.WithSecurity(MessagePackSecurity.UntrustedData));
|
||||
builder.Services.AddSignalR(options => options.MaximumReceiveMessageSize = 256 * 1024);//.AddMessagePackProtocol(options => options.SerializerOptions = MessagePackSerializerOptions.Standard.WithSecurity(MessagePackSecurity.UntrustedData));
|
||||
|
||||
builder.Services.AddCors(options =>
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue