Пример #1
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);
        }
Пример #2
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);
        }