Esempio n. 1
0
        public void OrderReceived(OrderProductModel model)
        {
            using (var mappers = new ManagementDataMapperContainer())
            {
                var order = mappers.SupplierOrderMapper.Query().FirstOrDefault(
                    o => o.ProductId.Equals(model.ProductCode) && o.SupplierId.Equals(model.Supplier));

                if (order == null)
                    return;

                mappers.SupplierOrderMapper.Delete(order);

                var product = mappers.ProductMapper.Get(model.ProductCode);

                if (product == null)
                    return;

                product.AvailableAmount += order.OrderAmount;

                mappers.ProductMapper.Update(product);

            }
        }
Esempio n. 2
0
        public void OrderProduct(OrderProductModel model)
        {
            using (var mappers = new ManagementDataMapperContainer())
            {
                var supplierOrderMapper = mappers.SupplierOrderMapper;

                supplierOrderMapper.Create(new SupplierOrder
                {
                    ProductId = model.ProductCode,
                    SupplierId = model.Supplier,
                    OrderAmount = model.Quantity,
                    OrderDate = DateTime.Now
                });
            }
        }