コード例 #1
0
        public Merchandise Save()
        {
            Merchandise merchandise = null;

            var session = NHibernateSessionManager.GetLocalSession();

            session.DoTransactional(sess =>
            {
                merchandise = new Merchandise(
                    _form.MerchandiseCode,
                    _form.SelectedInventory,
                    _form.MerchandisePointCost,
                    _form.MerchandiseVolume,
                    _form.MerchandiseName,
                    _form.MerchandiseDescription
                    );

                merchandise = _merchandiseRepository.Insert(merchandise);
            });

            return(merchandise);
        }
コード例 #2
0
        public Inventory Save()
        {
            Inventory inventory = null;
            var       session   = NHibernateSessionManager.GetLocalSession();

            session.DoTransactional(sess =>
            {
                inventory = _inventoryRepository.Insert(
                    new Inventory(
                        _form.Code,
                        _form.InventoryName,
                        _form.Description,
                        _form.BuyPrice,
                        _form.UnitOfMeasurement
                        )
                    );

                if (_form.InventoryStorageDto.Count > 0)
                {
                    var stockMovement = new StockMovement(
                        StockMovementType.INITIALBALANCE,
                        @"CREATED AUTOMATICALLY FROM ADD NEW INVENTORY");

                    foreach (var inventoryStorageDto in _form.InventoryStorageDto)
                    {
                        stockMovement.AddMovementItem(inventory, inventoryStorageDto.Storage, inventoryStorageDto.Quantity);

                        _storageRepository.Update(inventoryStorageDto.Storage);
                    }

                    _stockMovementRepository.Insert(stockMovement);
                }

                if (_form.AddAsProduct)
                {
                    var product = new Product(
                        _form.ProductCode,
                        inventory,
                        _form.ProductCategory,
                        _form.SellPrice
                        )
                    {
                        Volume = _form.Volume
                    };

                    _productRepository.Insert(product);
                }

                if (_form.AddAsMerchandise)
                {
                    var merchandise = new Merchandise(
                        _form.MerchandiseCode,
                        inventory,
                        _form.MerchandisePoint,
                        1,
                        inventory.Name,
                        inventory.Description
                        );

                    _merchandiseRepository.Insert(merchandise);
                }
            });

            return(inventory);
        }