public async override Task <StorageAreaDto> Update(StorageAreaDto input) { // 删除区域现有货架 var OldStorageLocations = _repositorySL.GetAll().Where(r => r.StorageAreaId == input.Id).ToArray(); foreach (var StorageLocation in OldStorageLocations) { StorageLocation.StorageAreaId = null; } // 清空区域现有物料 var MPNStorageAreaMaps = _repositoryMPNSM.GetAll().Where(r => r.StorageAreaId == input.Id).ToArray(); foreach (var MPNStorageAreaMap in MPNStorageAreaMaps) { _repositoryMPNSM.Delete(MPNStorageAreaMap); } CurrentUnitOfWork.SaveChanges(); var StorageArea = await base.Update(input); CurrentUnitOfWork.SaveChanges(); // 更新库位区域 var StorageLocations = _repositorySL.GetAll().Where(r => input.ShelfNames.Contains(r.Name)).ToArray(); foreach (var StorageLocation in StorageLocations) { StorageLocation.StorageAreaId = StorageArea.Id; } // 更新料号区域 var MPNS = _repositoryMPN.GetAll().Where(r => input.MPNIds.Contains(r.Name)).ToArray(); foreach (var mpn in MPNS) { _repositoryMPNSM.Insert(new MPNStorageAreaMap() { MPNId = mpn.Id, StorageAreaId = StorageArea.Id }); } return(StorageArea); }
public override Task <ReelMoveMethodDto> Update(ReelMoveMethodDto input) { foreach (var item in _repositoryRMMStorageMap.GetAll().Where(r => r.ReelMoveMethodId == input.Id).ToList()) { _repositoryRMMStorageMap.Delete(item.Id); } CurrentUnitOfWork.SaveChanges(); return(base.Update(input)); }