Skip to content

Commit 8a3cf38

Browse files
Ticket #10 : Display list of functions
1 parent 417445e commit 8a3cf38

File tree

75 files changed

+13554
-16
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+13554
-16
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<PropertyGroup>
3-
<VersionPrefix>0.0.2</VersionPrefix>
3+
<VersionPrefix>0.0.3</VersionPrefix>
44
<Authors>SimpleIdServer</Authors>
55
<Owners>SimpleIdServer</Owners>
66
</PropertyGroup>

FaasNet.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "04. Templates", "04. Templa
3131
EndProject
3232
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FaasNet.Templates", "src\FaasNet.Templates\FaasNet.Templates.csproj", "{6738B4F6-C01A-42D0-B205-7A9DACB4FD52}"
3333
EndProject
34+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FaasNet.Website", "src\FaasNet.Website\FaasNet.Website.csproj", "{6B493287-F29B-4988-A21F-A32EF81DE717}"
35+
EndProject
3436
Global
3537
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3638
Debug|Any CPU = Debug|Any CPU
@@ -77,6 +79,10 @@ Global
7779
{6738B4F6-C01A-42D0-B205-7A9DACB4FD52}.Debug|Any CPU.Build.0 = Debug|Any CPU
7880
{6738B4F6-C01A-42D0-B205-7A9DACB4FD52}.Release|Any CPU.ActiveCfg = Release|Any CPU
7981
{6738B4F6-C01A-42D0-B205-7A9DACB4FD52}.Release|Any CPU.Build.0 = Release|Any CPU
82+
{6B493287-F29B-4988-A21F-A32EF81DE717}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
83+
{6B493287-F29B-4988-A21F-A32EF81DE717}.Debug|Any CPU.Build.0 = Debug|Any CPU
84+
{6B493287-F29B-4988-A21F-A32EF81DE717}.Release|Any CPU.ActiveCfg = Release|Any CPU
85+
{6B493287-F29B-4988-A21F-A32EF81DE717}.Release|Any CPU.Build.0 = Release|Any CPU
8086
EndGlobalSection
8187
GlobalSection(SolutionProperties) = preSolution
8288
HideSolutionNode = FALSE
@@ -92,6 +98,7 @@ Global
9298
{EDDFD04B-B4F0-47A6-8FD3-628F3F542402} = {B0C38F6D-3F83-458A-A493-428AB3DD9F85}
9399
{8B02C02D-EF1A-4F48-A69D-DC8592D966B9} = {1064A767-7322-4A14-BFD4-97FDD40E76B4}
94100
{6738B4F6-C01A-42D0-B205-7A9DACB4FD52} = {8C14A385-0FC5-4517-B570-05FF7039CEA3}
101+
{6B493287-F29B-4988-A21F-A32EF81DE717} = {B0C38F6D-3F83-458A-A493-428AB3DD9F85}
95102
EndGlobalSection
96103
GlobalSection(ExtensibilityGlobals) = postSolution
97104
SolutionGuid = {46764455-0D10-4266-9C37-35D7BD67517C}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System.Collections.Generic;
2+
3+
namespace FaasNet.Gateway.Core.Common
4+
{
5+
public class BaseSearchResult<T> where T : class
6+
{
7+
public BaseSearchResult()
8+
{
9+
Content = new List<T>();
10+
}
11+
12+
public int StartIndex { get; set; }
13+
public int Count { get; set; }
14+
public int TotalLength { get; set; }
15+
public ICollection<T> Content { get; set; }
16+
}
17+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using FaasNet.Gateway.Core.Repositories.Parameters;
2+
using System;
3+
using System.Linq;
4+
using System.Linq.Expressions;
5+
6+
namespace FaasNet.Gateway.Core.Extensions
7+
{
8+
public static class QueryableExtensions
9+
{
10+
public static IQueryable<T> InvokeOrderBy<T>(this IQueryable<T> source, string propertyName, SortOrders order)
11+
{
12+
var piParametr = Expression.Parameter(typeof(T), "r");
13+
var property = Expression.Property(piParametr, propertyName);
14+
var lambdaExpr = Expression.Lambda(property, piParametr);
15+
return (IQueryable<T>)Expression.Call(
16+
typeof(Queryable),
17+
order == SortOrders.ASC ? "OrderBy" : "OrderByDescending",
18+
new Type[] { typeof(T), property.Type },
19+
source.Expression,
20+
lambdaExpr)
21+
.Method.Invoke(null, new object[] { source, lambdaExpr });
22+
}
23+
}
24+
}

src/FaasNet.Gateway.Core/Functions/Commands/Handlers/GetFunctionConfigurationCommandHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ namespace FaasNet.Gateway.Core.Functions.Commands.Handlers
1414
{
1515
public class GetFunctionConfigurationCommandHandler : IRequestHandler<GetFunctionConfigurationCommand, JObject>
1616
{
17-
private readonly IFunctionRepository _functionRepository;
17+
private readonly IFunctionCommandRepository _functionRepository;
1818
private readonly IHttpClientFactory _httpClientFactory;
1919
private readonly GatewayConfiguration _configuration;
2020

2121
public GetFunctionConfigurationCommandHandler(
22-
IFunctionRepository functionRepository,
22+
IFunctionCommandRepository functionRepository,
2323
IHttpClientFactory httpClientFactory,
2424
IOptions<GatewayConfiguration> configuration)
2525
{

src/FaasNet.Gateway.Core/Functions/Commands/Handlers/InvokeFunctionCommandHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ namespace FaasNet.Gateway.Core.Functions.Commands.Handlers
1717
{
1818
public class InvokeFunctionCommandHandler : IRequestHandler<InvokeFunctionCommand, JObject>
1919
{
20-
private readonly IFunctionRepository _functionRepository;
20+
private readonly IFunctionCommandRepository _functionRepository;
2121
private readonly IHttpClientFactory _httpClientFactory;
2222
private readonly GatewayConfiguration _configuration;
2323

2424
public InvokeFunctionCommandHandler(
25-
IFunctionRepository functionRepository,
25+
IFunctionCommandRepository functionRepository,
2626
IHttpClientFactory httpClientFactory,
2727
IOptions<GatewayConfiguration> configuration)
2828
{

src/FaasNet.Gateway.Core/Functions/Commands/Handlers/PublishFunctionCommandHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ namespace FaasNet.Gateway.Core.Functions.Commands.Handlers
1717
public class PublishFunctionCommandHandler : IRequestHandler<PublishFunctionCommand, bool>
1818
{
1919
private readonly IHttpClientFactory _httpClientFactory;
20-
private readonly IFunctionRepository _functionRepository;
20+
private readonly IFunctionCommandRepository _functionRepository;
2121
private readonly GatewayConfiguration _configuration;
2222

2323
public PublishFunctionCommandHandler(
2424
IHttpClientFactory httpClientFactory,
25-
IFunctionRepository functionRepository,
25+
IFunctionCommandRepository functionRepository,
2626
IOptions<GatewayConfiguration> configuration)
2727
{
2828
_httpClientFactory = httpClientFactory;

src/FaasNet.Gateway.Core/Functions/Commands/Handlers/UnpublishFunctionCommandHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ namespace FaasNet.Gateway.Core.Functions.Commands.Handlers
1414
public class UnpublishFunctionCommandHandler : IRequestHandler<UnpublishFunctionCommand, bool>
1515
{
1616
private readonly IHttpClientFactory _httpClientFactory;
17-
private readonly IFunctionRepository _functionRepository;
17+
private readonly IFunctionCommandRepository _functionRepository;
1818
private readonly GatewayConfiguration _configuration;
1919

2020
public UnpublishFunctionCommandHandler(
2121
IHttpClientFactory httpClientFactory,
22-
IFunctionRepository functionRepository,
22+
IFunctionCommandRepository functionRepository,
2323
IOptions<GatewayConfiguration> configuration)
2424
{
2525
_httpClientFactory = httpClientFactory;

src/FaasNet.Gateway.Core/Functions/FunctionService.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using FaasNet.Gateway.Core.Functions.Commands;
22
using MediatR;
3-
using System;
43
using System.Threading;
54
using System.Threading.Tasks;
65

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using FaasNet.Gateway.Core.Common;
2+
using FaasNet.Gateway.Core.Functions.Queries.Results;
3+
using FaasNet.Gateway.Core.Repositories;
4+
using FaasNet.Gateway.Core.Repositories.Parameters;
5+
using MediatR;
6+
using System.Threading;
7+
using System.Threading.Tasks;
8+
9+
namespace FaasNet.Gateway.Core.Functions.Queries.Handlers
10+
{
11+
public class SearchFunctionsQueryHandler : IRequestHandler<SearchFunctionsQuery, BaseSearchResult<FunctionResult>>
12+
{
13+
private readonly IFunctionQueryRepository _functionRepository;
14+
15+
public SearchFunctionsQueryHandler(IFunctionQueryRepository functionRepository)
16+
{
17+
_functionRepository = functionRepository;
18+
}
19+
20+
public Task<BaseSearchResult<FunctionResult>> Handle(SearchFunctionsQuery request, CancellationToken cancellationToken)
21+
{
22+
return _functionRepository.Search(new SearchFunctionsParameter
23+
{
24+
Count = request.Count,
25+
Order = request.Order,
26+
OrderBy = request.OrderBy,
27+
StartIndex = request.StartIndex
28+
}, cancellationToken);
29+
}
30+
}
31+
}

0 commit comments

Comments
 (0)