コード例 #1
0
        public async Task <ProductStock> AddAsync(int productId, int quantity)
        {
            var stock = new ProductStock
            {
                ProductId = productId,
                Quantity  = quantity
            };

            context.Stocks.Add(stock);

            await context.SaveChangesAsync();

            return(stock);
        }
コード例 #2
0
        public async Task <ProductPrice> AddAsync(int productId, int value)
        {
            var price = new ProductPrice
            {
                ProductId = productId,
                Value     = value
            };

            context.Prices.Add(price);

            await context.SaveChangesAsync();

            return(price);
        }
コード例 #3
0
        public async Task CreateAsync(string description, int price, int stock)
        {
            NewFeature();

            var product = new Product
            {
                Description = description,
                Price       = new ProductPrice
                {
                    Value = price
                },
                Stock = new ProductStock
                {
                    Quantity = stock
                }
            };

            context.Products.Add(product);

            await context.SaveChangesAsync();
        }