Пример #1
0
        public int Update(GetGoodsStorageDetailDto getGoodsStorageDetailDto)
        {
            Goods goods = new Goods()
            {
                Id            = getGoodsStorageDetailDto.GoodsId,
                Weight        = getGoodsStorageDetailDto.Weight,
                TypeId        = getGoodsStorageDetailDto.TypeId,
                UserId        = getGoodsStorageDetailDto.UserId,
                Name          = getGoodsStorageDetailDto.GoodsName,
                Remarks       = getGoodsStorageDetailDto.GoodsRemarks,
                IsWarehousing = 1
            };

            if (!_goodsService.Update(goods))
            {
                throw new BusinessException("修改货物信息失败");
            }

            StorageRegion storageRegion = new StorageRegion()
            {
                StorageId = getGoodsStorageDetailDto.StorageId,
                RegionId  = getGoodsStorageDetailDto.RegionId
            };

            if (_goodsStorageService.GetCountByStorageRegion(storageRegion) >= _storageRegionService.Find(c => c.StorageId == getGoodsStorageDetailDto.StorageId && c.RegionId == getGoodsStorageDetailDto.RegionId).Capacity)
            {
                return(2);
            }
            GoodsStorage goodsStorage = _goodsStorageService.Find(getGoodsStorageDetailDto.GoodsStorageId);

            goodsStorage.GoodsId   = getGoodsStorageDetailDto.GoodsId;
            goodsStorage.StorageId = getGoodsStorageDetailDto.StorageId;
            goodsStorage.RegionId  = getGoodsStorageDetailDto.RegionId;
            return(_goodsStorageService.Update(goodsStorage) ? 0 : 1);
        }
Пример #2
0
        public bool Leave(int id)
        {
            if (id <= 0)
            {
                return(false);
            }
            GoodsStorage goodsStorage = _goodsStorageService.Find(id);

            if (goodsStorage == null)
            {
                return(false);
            }

            goodsStorage.State = 1;
            _goodsStorageService.Update(goodsStorage);

            GoodsLeave goodsLeave = new GoodsLeave()
            {
                GoodsId   = goodsStorage.GoodsId,
                RegionId  = goodsStorage.RegionId,
                StorageId = goodsStorage.StorageId
            };

            _repository.Add(goodsLeave);
            return(_unitOfWork.Commit() > 0);
        }
Пример #3
0
        public void TestStoreTheProduct()
        {
            Product      myProduct = new Product("Biscuits", "Tuc", 1, 2);
            GoodsStorage storage   = new GoodsStorage();

            storage.StoreTheProduct(myProduct);
            Assert.IsTrue(storage.listOfProducts.Contains(myProduct));
        }
Пример #4
0
 public bool Add(GoodsStorage goodsStorage)
 {
     if (goodsStorage.GoodsId == 0 || goodsStorage.StorageId == 0 || goodsStorage.RegionId == 0)
     {
         return(false);
     }
     _repository.Add(goodsStorage);
     return(_unitOfWork.Commit() > 0);
 }
Пример #5
0
        public void TestCountAllCommand()
        {
            Product      firstProduct  = new Product("Biscuits", "Tuc", 1, 2);
            Product      secondProduct = new Product("Biscuits", "Oreo", 3, 3);
            Product      thirdProduct  = new Product("Chocolate", "Red riding hood", 5, 2.5);
            GoodsStorage storage       = new GoodsStorage();

            storage.StoreTheProduct(firstProduct);
            storage.StoreTheProduct(secondProduct);
            storage.StoreTheProduct(thirdProduct);
            ICommand productsCounter = new CountAllCommand(storage.listOfProducts);

            Assert.AreEqual(productsCounter.Count(), 9);
        }
Пример #6
0
        public bool UpdateGoodsStorage(int wareHouseId, int goodsId, int quantity)
        {
            if (quantity < 0)
            {
                return(false);
            }
            GoodsStorage goodsStorage = wareHouseRespository.GoodsStorage.Where(p => p.GoodsId == goodsId && p.WareHouseId == wareHouseId).FirstOrDefault();

            if (goodsStorage != null)
            {
                goodsStorage.Quantity = quantity;
                wareHouseRespository.SaveChanges();
                return(true);
            }
            return(false);
        }
Пример #7
0
        public int Join(GetJoinDto getJoinDto)
        {
            Goods goods = new Goods()
            {
                Weight        = getJoinDto.Weight,
                TypeId        = getJoinDto.TypeId,
                UserId        = getJoinDto.UserId,
                Name          = getJoinDto.Name,
                Remarks       = getJoinDto.Remarks,
                IsWarehousing = 1
            };

            _goodsService.Add(goods);
            int goodsId = _goodsService.GetId(goods);

            if (_goodsStorageService.Find(c => c.GoodsId == goodsId && c.RegionId == getJoinDto.RegionId && c.StorageId == getJoinDto.StorageId && c.State == 0) != null)
            {
                return(3);
            }

            StorageRegion storageRegion = new StorageRegion()
            {
                StorageId = getJoinDto.StorageId,
                RegionId  = getJoinDto.RegionId
            };

            //判断仓库中的货物数量是否超出最大容量
            if (_goodsStorageService.GetCountByStorageRegion(storageRegion) >= _storageRegionService.Find(c => c.StorageId == getJoinDto.StorageId && c.RegionId == getJoinDto.RegionId).Capacity)
            {
                return(2);
            }

            GoodsStorage goodsStorage = new GoodsStorage()
            {
                GoodsId   = goodsId,
                StorageId = getJoinDto.StorageId,
                RegionId  = getJoinDto.RegionId,
                State     = 0
            };

            return(_goodsStorageService.Add(goodsStorage) ? 0 : 1);
        }
Пример #8
0
        public bool Update(GoodsStorage goodsStorage)
        {
            if (goodsStorage.Id <= 0)
            {
                return(false);
            }

            GoodsStorage tempGoodsStorage = _repository.Find(goodsStorage.Id);

            if (tempGoodsStorage == null)
            {
                return(false);
            }

            tempGoodsStorage.GoodsId   = goodsStorage.GoodsId;
            tempGoodsStorage.RegionId  = goodsStorage.RegionId;
            tempGoodsStorage.StorageId = goodsStorage.StorageId;

            _repository.Update(tempGoodsStorage);
            return(_unitOfWork.Commit() > 0);
        }
Пример #9
0
        public GoodsStorageDetailModel Find(int id)
        {
            GoodsStorage            goodsStorage            = _goodsStorageService.Find(id);
            Goods                   goods                   = _goodsService.Find(goodsStorage.GoodsId);
            GoodsStorageDetailModel goodsStorageDetailModel = new GoodsStorageDetailModel()
            {
                GoodsStorageId = goodsStorage.Id,
                GoodsId        = goods.Id,
                GoodsName      = goods.Name,
                GoodsRemarks   = goods.Remarks,
                Weight         = goods.Weight,
                TypeId         = goods.TypeId,
                TypeName       = _goodsTypeService.Find(goods.TypeId).Name,
                UserId         = goods.UserId,
                UserName       = _usersService.Find(goods.UserId).Name,
                StorageId      = goodsStorage.StorageId,
                StorageName    = _storageService.Find(goodsStorage.StorageId).Name,
                RegionId       = goodsStorage.RegionId,
                RegionName     = _regionService.Find(goodsStorage.RegionId).Name,
            };

            return(goodsStorageDetailModel);
        }
 public CircuitBoard()
 {
     PriceList = new GoodsStorage();
 }
Пример #11
0
 public void Refresh()
 {
     FillViewList(GoodsStorage.GetItems(a => a == a, -1));
 }
        protected virtual void InitParts()
        {
            coinStorage = new CoinStorage();
            returnStorage = new CoinStorage();
            goodStorage = new GoodsStorage();
            display = new Display();

            avaliableCoins = new List<Coin>();
            prices = new PriceList();
        }
 public TradeParticipantSimple(string _name)
 {
     Name = _name;
     Wallet = new Wallet();
     GoodsStorage = new GoodsStorage();
 }
Пример #14
0
 public bool Delete(GoodsStorage goodsStorage)
 {
     _repository.Delete(goodsStorage);
     return(_unitOfWork.Commit() > 0);
 }
 protected virtual void InitParts()
 {
     display = new Display();
     returnChange = new CoinStorage();
     goodStorage = new GoodsStorage();
     changer = new CoinChanger(display, returnChange);
 }