Skip to content

Commit

Permalink
Merge branch 'iss312' of https://github.com/DaleyKD/pnpcore into pr470
Browse files Browse the repository at this point in the history
  • Loading branch information
jansenbe committed Jun 2, 2021
2 parents e6b5829 + e4f6f72 commit af0f310
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
3 changes: 1 addition & 2 deletions src/sdk/PnP.Core/Model/SharePoint/Core/Internal/ListItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ public ListItem()
};
AddApiCallHandler = async (keyValuePairs) =>
{
var parentList = Parent.Parent as List;
// sample parent list uri: https://bertonline.sharepoint.com/sites/modern/_api/Web/Lists(guid'b2d52a36-52f1-48a4-b499-629063c6a38c')
var parentListUri = parentList.GetMetadata(PnPConstants.MetaDataUri);
Expand All @@ -99,7 +98,7 @@ public ListItem()
string serverRelativeUrl = null;
if (string.IsNullOrEmpty(parentListTitle) || string.IsNullOrEmpty(parentListUri) || !parentList.IsPropertyAvailable(p => p.TemplateType))
{
// Fall back to loading the rootfolder propery if we can't determine the list name
// Fall back to loading the RootFolder property if we can't determine the list name
await parentList.EnsurePropertiesAsync(p => p.RootFolder).ConfigureAwait(false);
serverRelativeUrl = parentList.RootFolder.ServerRelativeUrl;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ namespace PnP.Core.Model.SharePoint
{
internal static class ListMetaDataMapper
{

internal static string MicrosoftGraphNameToRestEntityTypeName(string microsoftGraphListName, ListTemplateType listTemplateType)
{
if (listTemplateType == ListTemplateType.UserInformation)
Expand All @@ -23,7 +22,7 @@ internal static string MicrosoftGraphNameToRestEntityTypeName(string microsoftGr
}

// Build the name
string entityNameToUse = $"{entityName.ToString().Replace(" ", "")}{(isList ? "List" : "")}";
string entityNameToUse = $"{entityName.Replace(" ", "")}{(isList ? "List" : "")}";
// Ensure first character is upper case
entityNameToUse = entityNameToUse.First().ToString().ToUpper() + entityNameToUse.Substring(1);

Expand All @@ -32,6 +31,7 @@ internal static string MicrosoftGraphNameToRestEntityTypeName(string microsoftGr

internal static string RestEntityTypeNameToUrl(Uri pnpContextUri, string restEntityTypeName, ListTemplateType listTemplateType)
{
var contextUrl = pnpContextUri.ToString().TrimEnd('/');
(bool isList, _, bool isCatalog) = DetectListType(listTemplateType);

// Translate special chars back to their regular values
Expand All @@ -52,17 +52,17 @@ internal static string RestEntityTypeNameToUrl(Uri pnpContextUri, string restEnt

// Drop List suffix
listUrl = listUrl.Substring(0, listUrl.Length - 4);
return $"{pnpContextUri}/lists/{listUrl}";
return $"{contextUrl}/lists/{listUrl}";
}
else if (isCatalog)
{
// catalog
return $"{pnpContextUri}/_catalogs/{listUrl}";
return $"{contextUrl}/_catalogs/{listUrl}";
}
else
{
// library
return $"{pnpContextUri}/{listUrl}";
return $"{contextUrl}/{listUrl}";
}
}

Expand Down Expand Up @@ -118,8 +118,5 @@ internal static (bool isList, bool isLibrary, bool isCatalog) DetectListType(Lis

return (isList, isLibrary, isCatalog);
}



}
}

0 comments on commit af0f310

Please sign in to comment.