internal bool SaveRelation(string conn, List <LinkComponentField> lk) { var dataComponentModal = new Data.Component.ComponentModal(conn); foreach (LinkComponentField lf in lk) { if (this.Relations.Where(x => x.ModalItemRelationID == lf.ModalItemRelationID).FirstOrDefault() == null) { dataComponentModal.SaveItemRelation(this.ClientID, this.ComponentModalItemID, lf.ParentField, lf.RelatedField, lf.Parent, lf.Child); } else { dataComponentModal.UpdateItemRelation(this.ClientID, lf.ModalItemRelationID, this.ComponentModalItemID, lf.ParentField, lf.RelatedField); } } return(true); }
/// <summary> /// /// </summary> /// <param name="mrelatedID"></param> /// <param name="parentfield"></param> /// <param name="relatedfield"></param> /// <returns></returns> public bool UpdateModalItemRelation(string mrelatedID, string parentfield, string relatedfield) { var c = new ClientServer(ClientID); var item = this.Relations.Where(x => x.ModalItemRelationID == mrelatedID).FirstOrDefault(); var dataComponentModal = new Data.Component.ComponentModal(c.GetServer().Connection()); if (item != null) { dataComponentModal.UpdateItemRelation(this.ClientID, mrelatedID, this.ComponentModalItemID, parentfield, relatedfield); return(true); } else { return(false); } }