public string GetImageName(CreateUpdateProductDto input) { if (input.Image == null) { return(""); } return(GuidGenerator.Create().ToString() + Path.GetExtension(input.Image.FileName)); }
public async Task StorageImageAsync(CreateUpdateProductDto input, string fileName) { var filePath = GetImagePath(fileName); using (var fileStream = new FileStream(filePath, FileMode.Create)) { await input.Image.CopyToAsync(fileStream); } }
public async Task UpdateProduct(Guid id, CreateUpdateProductDto input) { var fileName = GetImageName(input); //await StorageImageAsync(input, fileName); var product = new Product(id) { Name = input.Name, Price = input.Price, Image = fileName }; await productDomainService.UpdateProduct(id, product); }
public async Task CreateProduct(CreateUpdateProductDto input) { var fileName = GetImageName(input); //await StorageImageAsync(input, fileName); var product = new Product(guidGenerator.Create()) { Name = input.Name, Price = input.Price, Amount = input.Amount, Image = fileName, }; await productDomainService.CreateProduct(product); }