Пример #1
0
        public async Task <ProductDto> AddAsync(ProductDto productToAdd)
        {
            var product = _mapper.Map <Product>(productToAdd);

            _context.Products.Add(product);
            await _context.SaveChangesAsync(CancellationToken.None);

            return(_mapper.Map <ProductDto>(product));
        }
Пример #2
0
        public async Task <CategoryDto> UpdateImageAsync(CategoryDto category)
        {
            var categoryToUpdate =
                await _context.Categories.SingleOrDefaultAsync(c => c.CategoryId == category.CategoryId);

            categoryToUpdate.Picture = category.Picture;

            await _context.SaveChangesAsync(CancellationToken.None);

            return(_mapper.Map <CategoryDto>(categoryToUpdate));
        }