ttt
Some checks failed
Branch - test - Build and Push Backend API Docker Image / build-and-push (push) Failing after 19s
Some checks failed
Branch - test - Build and Push Backend API Docker Image / build-and-push (push) Failing after 19s
This commit is contained in:
@@ -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++ }); } }
|
||||
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 }); } }
|
||||
await _productRepository.UpdateProductAsync(existingProduct); return ServiceResult.Ok();
|
||||
await _productRepository.SaveChangesAsync(); return ServiceResult.Ok();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<ServiceResult> DeleteAdminProductAsync(Guid id)
|
||||
{
|
||||
var product = await _productRepository.GetProductByIdAsync(id);
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace Webshop.Domain.Interfaces
|
||||
Task<Product?> GetBySlugAsync(string slug);
|
||||
Task AddProductAsync(Product product);
|
||||
Task UpdateProductAsync(Product product);
|
||||
Task SaveChangesAsync();
|
||||
Task DeleteProductAsync(Guid id);
|
||||
}
|
||||
}
|
||||
@@ -55,5 +55,10 @@ namespace Webshop.Infrastructure.Repositories
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<int> SaveChangesAsync()
|
||||
{
|
||||
return await _context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user