public static string GetAmbitoIdByName(string ambitoName)
        {
            string    path = System.Web.Hosting.HostingEnvironment.MapPath(FilePaths.AmbitiXML);
            XDocument root = AmbitiUtility.GetXmlDocument(path);

            string ambitoId = null;

            if (root != null)
            {
                ambitoId = (from f in root.Elements("ambiti").Elements("ambito").Elements("node")
                            where f.Value.Equals(ambitoName)
                            select f)
                           .Select(f => f.Parent.Attribute("id").Value).SingleOrDefault();
            }
            return(ambitoId);
        }
        public static string GetAmbitoRoleById(int ambitoId, List <string> roles)
        {
            string    path = System.Web.Hosting.HostingEnvironment.MapPath(FilePaths.RolesXML);
            XDocument root = AmbitiUtility.GetXmlDocument(path);

            string role = null;

            if (root != null)
            {
                role = root.Elements("ambiti").Elements("role")
                       .Where(r => r.Attributes("id").Any(x => roles.Contains(x.Value)))
                       .Where(r => r.Attribute("ambito").Value.Equals(ambitoId.ToString()))
                       .OrderByDescending(p => p.Attribute("priority").Value)
                       .Select(r => r.Value).FirstOrDefault();
            }

            return(role);
        }