Exemple #1
0
 public string GetImageName(CreateUpdateProductDto input)
 {
     if (input.Image == null)
     {
         return("");
     }
     return(GuidGenerator.Create().ToString() + Path.GetExtension(input.Image.FileName));
 }
Exemple #2
0
        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);
            }
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        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);
        }