Пример #1
0
        public async Task <int> AddProductAsync(AddProductRequest request)
        {
            ProductEntity product = new ProductEntity()
            {
                Name        = request.Name,
                Description = request.Description,
                Cost        = request.Cost,
                Size        = request.Size
            };
            await _db.Products.AddAsync(product);

            await _db.SaveChangesAsync();

            return(product.Id);
        }
Пример #2
0
        public async Task <int> AddOrderAsync(AddOrderRequest newOrder)
        {
            OrderEntity order = new OrderEntity()
            {
                Customer   = newOrder.Customer,
                Products   = newOrder.Products,
                OrderDate  = newOrder.OrderDate,
                Deadline   = newOrder.Deadline,
                TotalPrice = newOrder.TotalPrice,
                Success    = true
            };
            await _db.Orders.AddAsync(order);

            await _db.SaveChangesAsync();

            return(order.Id);
        }