/// <summary>
 /// Returns roles from list.
 /// </summary>
 /// <param name="roles">list of roles</param>
 /// <param name="collListItem">list of item collection</param>
 /// <returns>resultant list of roles</returns>
 internal static IList<Role> GetRoleDataUtility(IList<Role> roles, ListItemCollection collListItem)
 {
     if (null != collListItem && 0 != collListItem.Count)
     {
         foreach (ListItem item in collListItem)
         {
             Role tempRole = new Role();
             tempRole.Id = Convert.ToString(item[ServiceConstantStrings.ColumnNameGuid], CultureInfo.InvariantCulture);
             tempRole.Name = Convert.ToString(item[ServiceConstantStrings.RoleListColumnRoleName], CultureInfo.InvariantCulture);
             tempRole.Mandatory = Convert.ToBoolean(item[ServiceConstantStrings.RoleListColumnIsRoleMandatory], CultureInfo.InvariantCulture);
             roles.Add(tempRole);
         }
     }
     return roles;
 }
 /// <summary>
 /// Generates list of users permissions which are allowed on created matter.
 /// </summary>
 /// <param name="roles">List of Roles present in the SharePoint Permissions</param>
 /// <param name="web">SharePoint Web Object</param>
 /// <returns>List of permissions which are allowed on the created matter</returns>
 internal static List<Role> GetAllowedUserPermissions(List<Role> roles, Web web)
 {
     string userAllowedPermissions = ServiceConstantStrings.UserPermissions;
     List<Role> result = null;
     try
     {
         if (!String.IsNullOrWhiteSpace(userAllowedPermissions))
         {
             //// Get the user permissions from the Resource file
             List<string> userPermissions = userAllowedPermissions.ToUpperInvariant().Trim().Split(new string[] { ConstantStrings.Comma }, StringSplitOptions.RemoveEmptyEntries).ToList();
             //// Filter only the allowed roles using LINQ query
             List<RoleDefinition> roleDefinition = (from webRole in web.RoleDefinitions.ToList()
                                                    where userPermissions.Contains(webRole.Name.ToUpperInvariant())
                                                    select webRole).ToList();
             foreach (RoleDefinition role in roleDefinition)
             {
                 Role tempRole = new Role();
                 tempRole.Name = role.Name;
                 tempRole.Id = Convert.ToString(role.Id, CultureInfo.InvariantCulture);
                 roles.Add(tempRole);
             }
         }
         result = roles.OrderBy(role => role.Name).ToList();
     }
     catch (Exception exception)
     {
         Logger.LogError(exception, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, ServiceConstantStrings.LogTableName);
         List<Role> GetAllowedUserPermissionsError = new List<Role>();
         result = GetAllowedUserPermissionsError;
     }
     return result;
 }