public void UpdateCompatibleSet(CompatibleSet compatibleSet) { var dataRec = Mapper.Map <Data.Models.CompatibleSet>(compatibleSet); _compatibleSetGateway.Update(dataRec); var oldGoods = _compatibleSetGoodsGateway.SelectByCompatibleSet(compatibleSet.CompatibleSetId); var newGoods = compatibleSet.CompatibleGoods; foreach (var oldGoodsItem in oldGoods) { if (newGoods.All(x => x.ID != oldGoodsItem.HeartId)) { _compatibleSetGoodsGateway.Delete(oldGoodsItem); } } foreach (var newGoodsItem in newGoods) { var compatibleSetGoodsItem = new CompatibleSetGoods() { HeartId = newGoodsItem.ID, CompatibleSetId = compatibleSet.CompatibleSetId }; if (oldGoods.All(x => x.HeartId != newGoodsItem.ID)) { _compatibleSetGoodsGateway.Insert(compatibleSetGoodsItem); } } }
public void Insert(CompatibleSetGoods rec) { Exec(GetProcedureString(), rec); }
public void Delete(CompatibleSetGoods rec) { Exec(GetProcedureString(), rec); }