Merge branch 'master' of http://git2.aycode.com/Adam/TourIAm
This commit is contained in:
commit
422a1c0bab
|
|
@ -261,7 +261,7 @@ namespace TIAM.Database.Test
|
||||||
Assert.IsTrue(product.UserProductMappings[0].Permissions == 2);
|
Assert.IsTrue(product.UserProductMappings[0].Permissions == 2);
|
||||||
|
|
||||||
var addressId = product.Profile.AddressId;
|
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.GetProfileByIdAsync(product.ProfileId));
|
||||||
Assert.IsNull(await Dal.GetAddressByIdAsync(addressId));
|
Assert.IsNull(await Dal.GetAddressByIdAsync(addressId));
|
||||||
|
|
@ -383,7 +383,7 @@ namespace TIAM.Database.Test
|
||||||
Assert.IsTrue(await Dal.UpdateCompanyAsync(company));
|
Assert.IsTrue(await Dal.UpdateCompanyAsync(company));
|
||||||
|
|
||||||
var addressId = company.Profile.AddressId;
|
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.GetProfileByIdAsync(company.ProfileId));
|
||||||
Assert.IsNull(await Dal.GetAddressByIdAsync(addressId));
|
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> AddProductAsync(Product product) => TransactionAsync(ctx => ctx.AddProduct(product));
|
||||||
|
|
||||||
public Task<bool> UpdateProductAsync(Product product) => TransactionAsync(ctx => ctx.UpdateProduct(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 Task<bool> RemoveProductAsync(Guid productId) => TransactionAsync(ctx => ctx.RemoveProduct(productId));
|
||||||
|
|
||||||
public UserProductMapping? GetUserProductMappingById(Guid userProductMappingId, bool autoInclude = true) => Session(ctx => ctx.GetUserProductMappingById(userProductMappingId, autoInclude));
|
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
|
//13. (IserviceProviderDataService) delete service provider
|
||||||
public Task<bool> RemoveCompanyAsync(Guid companyId) => TransactionAsync(ctx => ctx.RemoveProductsByCompanyId(companyId) && ctx.RemoveCompany(companyId));
|
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
|
#endregion
|
||||||
|
|
||||||
#region PermissionTypes
|
#region PermissionTypes
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ public static class ProductDbSetExtensions
|
||||||
return ctx.Products.Update(product).State == EntityState.Modified;
|
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.RemoveProfile(product.ProfileId);
|
||||||
ctx.RemoveUserProductMappingsByProductId(product.Id);
|
ctx.RemoveUserProductMappingsByProductId(product.Id);
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ namespace TIAMWebApp.Server.Controllers
|
||||||
case TrackingState.Update:
|
case TrackingState.Update:
|
||||||
return await adminDal.UpdateCompanyAsync(company);
|
return await adminDal.UpdateCompanyAsync(company);
|
||||||
case TrackingState.Remove:
|
case TrackingState.Remove:
|
||||||
return await adminDal.RemoveCompanyAsync(company);
|
return await adminDal.RemoveCompanyAsync(company.Id);
|
||||||
|
|
||||||
case TrackingState.Get:
|
case TrackingState.Get:
|
||||||
case TrackingState.GetAll:
|
case TrackingState.GetAll:
|
||||||
|
|
@ -386,39 +386,31 @@ namespace TIAMWebApp.Server.Controllers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[AllowAnonymous]
|
//[HttpPost]
|
||||||
[HttpPost]
|
//[Route(APIUrls.AddProductRouteName)]
|
||||||
[Route(APIUrls.GetQrCodeByProductIdRouteName)]
|
//[Tags("In-Progress", "Product")]
|
||||||
[Tags("In-Progress", "Product")]
|
[SignalR(SignalRTags.UpdateProduct)]
|
||||||
public async Task<IActionResult> GetQRCodeByProductId([FromBody] Guid productId)
|
public async Task<Product> UpdateProduct([FromBody] Product product)
|
||||||
{
|
{
|
||||||
_logger.Info(@"GetQRCode called");
|
_logger.Info(@"UpdateProduct called");
|
||||||
|
|
||||||
if (productId == Guid.Empty)
|
var result = await adminDal.UpdateProductAsync(product);
|
||||||
{
|
return product;
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//[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]
|
[NonAction]
|
||||||
[ApiExplorerSettings(IgnoreApi = true)]
|
[ApiExplorerSettings(IgnoreApi = true)]
|
||||||
public async Task<string> GetProductsByOwnerId(Guid serviceProviderId)
|
public async Task<string> GetProductsByOwnerId(Guid serviceProviderId)
|
||||||
|
|
@ -484,5 +476,38 @@ namespace TIAMWebApp.Server.Controllers
|
||||||
var product = await GetProductById(productId);
|
var product = await GetProductById(productId);
|
||||||
return product == null ? [] : [product];
|
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.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 =>
|
builder.Services.AddCors(options =>
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue