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