ttt
Some checks failed
Branch - test - Build and Push Backend API Docker Image / build-and-push (push) Failing after 19s

This commit is contained in:
Tizian.Breuch
2025-11-07 12:58:09 +01:00
parent 071e787014
commit 39a6800373
3 changed files with 9 additions and 1 deletions

View File

@@ -122,9 +122,11 @@ namespace Webshop.Application.Services.Admin
if (productDto.AdditionalImageFiles != null && productDto.AdditionalImageFiles.Any()) { int displayOrder = (existingProduct.Images.Any() ? existingProduct.Images.Max(i => i.DisplayOrder) : 0) + 1; foreach (var file in productDto.AdditionalImageFiles) { await using var stream = file.OpenReadStream(); var url = await _fileStorageService.SaveFileAsync(stream, file.FileName, file.ContentType); existingProduct.Images.Add(new ProductImage { Url = url, IsMainImage = false, DisplayOrder = displayOrder++ }); } } if (productDto.AdditionalImageFiles != null && productDto.AdditionalImageFiles.Any()) { int displayOrder = (existingProduct.Images.Any() ? existingProduct.Images.Max(i => i.DisplayOrder) : 0) + 1; foreach (var file in productDto.AdditionalImageFiles) { await using var stream = file.OpenReadStream(); var url = await _fileStorageService.SaveFileAsync(stream, file.FileName, file.ContentType); existingProduct.Images.Add(new ProductImage { Url = url, IsMainImage = false, DisplayOrder = displayOrder++ }); } }
existingProduct.Name = productDto.Name; existingProduct.Description = productDto.Description; existingProduct.SKU = productDto.SKU; existingProduct.Price = productDto.Price; existingProduct.IsActive = productDto.IsActive; existingProduct.StockQuantity = productDto.StockQuantity; existingProduct.Slug = productDto.Slug; existingProduct.Weight = productDto.Weight; existingProduct.OldPrice = productDto.OldPrice; existingProduct.SupplierId = productDto.SupplierId; existingProduct.PurchasePrice = productDto.PurchasePrice; existingProduct.LastModifiedDate = DateTimeOffset.UtcNow; existingProduct.IsFeatured = productDto.IsFeatured; existingProduct.FeaturedDisplayOrder = productDto.FeaturedDisplayOrder; existingProduct.Name = productDto.Name; existingProduct.Description = productDto.Description; existingProduct.SKU = productDto.SKU; existingProduct.Price = productDto.Price; existingProduct.IsActive = productDto.IsActive; existingProduct.StockQuantity = productDto.StockQuantity; existingProduct.Slug = productDto.Slug; existingProduct.Weight = productDto.Weight; existingProduct.OldPrice = productDto.OldPrice; existingProduct.SupplierId = productDto.SupplierId; existingProduct.PurchasePrice = productDto.PurchasePrice; existingProduct.LastModifiedDate = DateTimeOffset.UtcNow; existingProduct.IsFeatured = productDto.IsFeatured; existingProduct.FeaturedDisplayOrder = productDto.FeaturedDisplayOrder;
existingProduct.Productcategories.Clear(); if (productDto.CategorieIds != null) { foreach (var categorieId in productDto.CategorieIds) { existingProduct.Productcategories.Add(new Productcategorie { categorieId = categorieId }); } } existingProduct.Productcategories.Clear(); if (productDto.CategorieIds != null) { foreach (var categorieId in productDto.CategorieIds) { existingProduct.Productcategories.Add(new Productcategorie { categorieId = categorieId }); } }
await _productRepository.UpdateProductAsync(existingProduct); return ServiceResult.Ok(); await _productRepository.SaveChangesAsync(); return ServiceResult.Ok();
} }
public async Task<ServiceResult> DeleteAdminProductAsync(Guid id) public async Task<ServiceResult> DeleteAdminProductAsync(Guid id)
{ {
var product = await _productRepository.GetProductByIdAsync(id); var product = await _productRepository.GetProductByIdAsync(id);

View File

@@ -13,6 +13,7 @@ namespace Webshop.Domain.Interfaces
Task<Product?> GetBySlugAsync(string slug); Task<Product?> GetBySlugAsync(string slug);
Task AddProductAsync(Product product); Task AddProductAsync(Product product);
Task UpdateProductAsync(Product product); Task UpdateProductAsync(Product product);
Task SaveChangesAsync();
Task DeleteProductAsync(Guid id); Task DeleteProductAsync(Guid id);
} }
} }

View File

@@ -55,5 +55,10 @@ namespace Webshop.Infrastructure.Repositories
await _context.SaveChangesAsync(); await _context.SaveChangesAsync();
} }
} }
public async Task<int> SaveChangesAsync()
{
return await _context.SaveChangesAsync();
}
} }
} }