public void SetFrontEndRoles(string frontEndRoles, Webpage webpage) { if (webpage == null) { throw new ArgumentNullException("webpage"); } if (frontEndRoles == null) { frontEndRoles = string.Empty; } System.Collections.Generic.IEnumerable <string> roleNames = frontEndRoles.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()).Where( x => !string.IsNullOrWhiteSpace(x)); System.Collections.Generic.List <UserRole> roles = webpage.FrontEndAllowedRoles.ToList(); if (webpage.InheritFrontEndRolesFromParent) { roles.ForEach(role => { role.FrontEndWebpages.Remove(webpage); webpage.FrontEndAllowedRoles.Remove(role); }); } else { roleNames.ForEach(name => { UserRole role = GetRole(name); if (role != null) { if (!webpage.FrontEndAllowedRoles.Contains(role)) { webpage.FrontEndAllowedRoles.Add(role); role.FrontEndWebpages.Add(webpage); } roles.Remove(role); } }); roles.ForEach(role => { webpage.FrontEndAllowedRoles.Remove(role); role.FrontEndWebpages.Remove(webpage); }); } }
public void SetTags(string taglist, Document document) { if (document == null) { throw new ArgumentNullException("document"); } if (taglist == null) { taglist = string.Empty; } System.Collections.Generic.IEnumerable <string> tagNames = taglist.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()).Where( x => !string.IsNullOrWhiteSpace(x)); System.Collections.Generic.List <Tag> existingTags = document.Tags.ToList(); tagNames.ForEach(name => { Tag tag = GetTag(name); if (tag == null) { tag = new Tag { Name = name }; _session.Transact(session => session.Save(tag)); } if (!document.Tags.Contains(tag)) { document.Tags.Add(tag); tag.Documents.Add(document); } existingTags.Remove(tag); }); existingTags.ForEach(tag => { document.Tags.Remove(tag); tag.Documents.Remove(document); }); }
/// <summary> /// Applies the modification to many-to-one mappings. /// </summary> /// <param name="mappings">The mappings to which the modification should be applied.</param> protected override void HandleBelongsToMappings(System.Collections.Generic.IEnumerable <IBelongsToMapping> mappings) { mappings.ForEach(ApplyStorageAttribute); }