/// <summary> /// Saves associations for the subject entity. /// </summary> /// <returns>A Boolean value indicating success of operation.</returns> public override bool SaveAssociation() { bool result = false; using (ResourceDataAccess dataAccess = new ResourceDataAccess(base.CreateContext())) { AuthorizeResourcesBeforeSave <Tag>(dataAccess); switch (ObjectType) { case ObjectEntityType.Tag: result = dataAccess.SaveScholarlyWorkItemTagAssociation(SubjectItemId, DestinationList as List <Tag>); base.RefreshDataSource(); break; case ObjectEntityType.CategoryNode: result = dataAccess.SaveScholarlyItemCategoryAssociation(SubjectItemId, DestinationList as List <CategoryNode>, AuthenticatedToken, Constants.PermissionRequiredForAssociation); base.RefreshDataSource(); break; default: break; } } return(result); }
/// <summary> /// Updates subject ScholarlyworkItem to selected CategoryNodes association. /// </summary> /// <returns>true, if successful; else false.</returns> public bool SaveAssociation() { bool result = false; if (TreeView.Nodes.Count != 0) { for (int Index = 0; Index < TreeView.CheckedNodes.Count; Index++) { SelectedIdList.Add(new Guid(TreeView.CheckedNodes[Index].Value)); } using (ResourceDataAccess dataAccess = new ResourceDataAccess(base.CreateContext())) { List <CategoryNode> categoryNodeList = new List <CategoryNode>(); categoryNodeList = dataAccess.GetCategoryNodeList(SelectedIdList); foreach (CategoryNode node in categoryNodeList) { SelectedList.Add(node); } AuthorizeResourcesBeforeSave(dataAccess); result = dataAccess.SaveScholarlyItemCategoryAssociation(ResourceItemId, SelectedList as IList <Zentity.ScholarlyWorks.CategoryNode>, AuthenticatedToken, Constants.PermissionRequiredForAssociation); } if (result) { HeaderMessageLabel.Visible = true; ShowMessage(GlobalResource.MsgCategoryNodeAssociationSuccessfull, false); } } else { HeaderMessageLabel.Visible = true; ShowMessage(GlobalResource.MsgCategoryNodeNotFound, false); result = false; } return(result); }