Beispiel #1
0
        public ResponseView SubmitInStock(InventoryView inventory, string instockCount, string loginName)
        {
            var count   = instockCount.ConvertToInt();
            var person  = new TbmisUserAppl(loginName).GetUser().TbmisUserName;
            var inve    = _adapter.Adapt <Inventory>(inventory);
            var inveNew = new Inventory();
            //var inveNew = inve;
            var repo   = ServiceLocator.Current.GetInstance <IInventoryRepository>();
            var result = new ResponseView();

            //是否已存在库存
            if (inve.ID != null && inve.ID != Guid.Empty)
            {
                //取出库存
                inveNew = repo.First(t => t.ID == inve.ID);
                //更新架位号
                inveNew.ShelfNumber = inve.ShelfNumber;
            }
            else
            {
                inveNew = inve;
            }

            //修改库存数量
            inveNew.InventoryCount += count;
            //创建库存异动记录
            InventoryService.CreateStockRecord <InStockRecord>(inveNew, person, count);

            try
            {
                if (inveNew.ID == null || inve.ID == Guid.Empty)
                {
                    repo.Add(inveNew);
                }
                else
                {
                    repo.Modify(inveNew);
                }

                repo.Context.Commit();
                return(result);
            }
            catch (Exception e)
            {
                result.IsSuccess = false;
                result.Message   = "入库操作失败";
                return(result);
            }
        }