Skip to content

Commit

Permalink
initial cosmos sdk update
Browse files Browse the repository at this point in the history
  • Loading branch information
dlmelendez committed Nov 12, 2019
1 parent be691c4 commit 31ce326
Show file tree
Hide file tree
Showing 22 changed files with 830 additions and 908 deletions.
2 changes: 1 addition & 1 deletion src/ElCamino.AspNetCore.Identity.CosmosDB/Constants.cs
Expand Up @@ -11,7 +11,7 @@ namespace ElCamino.AspNetCore.Identity.CosmosDB
public static class Constants
{

public static class DocumentCollectionIds
public static class ContainerIds
{
public const string DefaultIdentityCollection = "identity";
}
Expand Down
Expand Up @@ -34,7 +34,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.2.0" />
<PackageReference Include="Microsoft.Azure.DocumentDB.Core" Version="2.2.0" />
<PackageReference Include="Microsoft.Azure.Cosmos" Version="3.4.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="2.2.0" />
<PackageReference Include="System.ComponentModel.TypeConverter" Version="4.3.0" />
Expand Down
Expand Up @@ -12,8 +12,16 @@ internal static class IQueryableExtensions
{
public static Task<List<TSource>> ToListAsync<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> where = null, CancellationToken cancellationToken = default(CancellationToken))
{
if(where == null)

if (where == null)
{
List<TSource> list = source as List<TSource>;
if (list != null)
{
return Task.FromResult(list);
}
return Task.Run(() => { return source.ToList(); }, cancellationToken);
}
else
return Task.Run(() => { return source.Where(where).ToList(); }, cancellationToken);
}
Expand All @@ -22,17 +30,17 @@ public static Task<TSource> FirstOrDefaultAsync<TSource>(this IEnumerable<TSourc
{
return Task.Run(() => {
if (where == null)
return source.Where(where).FirstOrDefault();
return source.Where(where).FirstOrDefault(where);
return source.FirstOrDefault();
return source.FirstOrDefault(where);
}, cancellationToken);
}

public static Task<TSource> SingleOrDefaultAsync<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> where = null, CancellationToken cancellationToken = default(CancellationToken))
{
return Task.Run(() => {
if(where == null)
return source.Where(where).SingleOrDefault();
return source.Where(where).SingleOrDefault(where);
return source.SingleOrDefault();
return source.Where(where).SingleOrDefault();
}, cancellationToken);
}
}
Expand Down
28 changes: 0 additions & 28 deletions src/ElCamino.AspNetCore.Identity.CosmosDB/Helpers/JsonHelpers.cs

This file was deleted.

@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace ElCamino.AspNetCore.Identity.CosmosDB.Helpers
{
public static class PartitionKeyHelper
{
public static string GetPartitionKeyFromId(string id)
{
id = id?.ToString()?.Trim();
if (!string.IsNullOrWhiteSpace(id))
{
if (id.Length > 4)
{
return id.Substring(id.Length - 4, 4);
}
}

return string.Empty;
}
}
}

0 comments on commit 31ce326

Please sign in to comment.