public void DeleteFullyWarehGroup(WarehouseGroup delWarehGroup) { try { _warehGroupDal.Delete(delWarehGroup); } catch (RepositoryException ex) { throw ex; } }
/// <summary> /// 删除一个仓库组 /// </summary> /// <param name="delWarehGroup">要删除的仓库组</param> public void DeleteWarehGroup(WarehouseGroup delWarehGroup) { try { DeleteSubWarehGroup(delWarehGroup); _unitOfWork.Save(); } catch (RepositoryException ex) { throw ex; } }
/// <summary> /// 修改一个仓库组 /// </summary> /// <param name="updWarehGroup">要修改的仓库组</param> /// <returns>修改后的仓库组</returns> public WarehouseGroup UpdateWarehGroup(WarehouseGroup updWarehGroup) { try { _warehGroupDal.Update(updWarehGroup); return(updWarehGroup); } catch (RepositoryException ex) { throw ex; } }
/// <summary> /// 新增一个仓库组 /// </summary> /// <param name="newWarehGroup">新增的仓库组</param> /// <returns>新增后的仓库组</returns> public WarehouseGroup AddWarehGroup(WarehouseGroup newWarehGroup) { try { _warehGroupDal.Add(newWarehGroup); return(newWarehGroup); } catch (RepositoryException ex) { throw ex; } }
private void DeleteSubWarehGroup(WarehouseGroup delWarehGroup) { if (delWarehGroup.SubWarehouseGroup != null) { foreach (WarehouseGroup subGroup in delWarehGroup.SubWarehouseGroup) { DeleteSubWarehGroup(subGroup); } } delWarehGroup.warehouse_group_deleted = true; _unitOfWork.AddAction(delWarehGroup, DataActions.Update); }
public void UpdateAsHQ(IEnumerable <DataCenter.Models.BusinessModel.WarehouseGroup> warehGroupHQ) { //同步总部数据 foreach (DataCenter.Models.BusinessModel.WarehouseGroup warehGroup in warehGroupHQ) { var tempWarehGroup = _warehGroupDal.Single(w => w.warehouse_group_id == warehGroup.warehouse_group_id); if (tempWarehGroup.HasValue) { //if exist,just update //如果已经存在了,就更新(Update) WarehouseGroup warehGroupTemp = tempWarehGroup.Entity; warehGroupTemp.warehouse_group_desc = warehGroup.warehouse_group_desc; warehGroupTemp.warehouse_group_name = warehGroup.warehouse_group_name; warehGroupTemp.parent_warehouse_group = warehGroup.parent_warehouse_group; warehGroupTemp.warehouse_group_deleted = false; _unitOfWork.AddAction(warehGroupTemp, DataActions.Update); } else { WarehouseGroup warehGroupTemp = new WarehouseGroup(); warehGroupTemp.warehouse_group_deleted = false; warehGroupTemp.warehouse_group_id = warehGroup.warehouse_group_id; warehGroupTemp.warehouse_group_desc = warehGroup.warehouse_group_desc; warehGroupTemp.warehouse_group_name = warehGroup.warehouse_group_name; warehGroupTemp.parent_warehouse_group = warehGroup.parent_warehouse_group; _unitOfWork.AddAction(warehGroupTemp, DataActions.Add); } } _unitOfWork.Save(); //处理parent_id IEnumerable <WarehouseGroup> warehGroupList = _warehGroupDal.Find(w => w.warehouse_group_id != 0).Entities; foreach (WarehouseGroup warehGroup in warehGroupList) { if (warehGroup.parent_warehouse_group != null) { warehGroup.parent_warehouse_group = warehGroupList.Single(w => w.warehouse_group_id == warehGroup.parent_warehouse_group.Value).id; _unitOfWork.AddAction(warehGroup, DataActions.Update); } } _unitOfWork.Save(); }