-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8e326f5
commit 0990fe6
Showing
31 changed files
with
491 additions
and
365 deletions.
There are no files selected for viewing
6 changes: 0 additions & 6 deletions
6
src/VirtoCommerce.ProfileExperienceApiModule.Core/ModuleConstants.cs
This file was deleted.
Oops, something went wrong.
32 changes: 0 additions & 32 deletions
32
...erce.ProfileExperienceApiModule.Core/VirtoCommerce.ProfileExperienceApiModule.Core.csproj
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
...oCommerce.ProfileExperienceApiModule.Data/Aggregates/Vendor/IVendorAggregateRepository.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
namespace VirtoCommerce.ProfileExperienceApiModule.Data.Aggregates.Vendor; | ||
|
||
public interface IVendorAggregateRepository: IMemberAggregateRootRepository | ||
{ | ||
} |
14 changes: 14 additions & 0 deletions
14
src/VirtoCommerce.ProfileExperienceApiModule.Data/Aggregates/Vendor/VendorAggregate.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace VirtoCommerce.ProfileExperienceApiModule.Data.Aggregates.Vendor; | ||
|
||
public class VendorAggregate: MemberAggregateRootBase | ||
{ | ||
public CustomerModule.Core.Model.Contact Contact => Member as CustomerModule.Core.Model.Contact; | ||
|
||
public CustomerModule.Core.Model.Organization Organization => Member as CustomerModule.Core.Model.Organization; | ||
|
||
public CustomerModule.Core.Model.Vendor Vendor => Member as CustomerModule.Core.Model.Vendor; | ||
|
||
public IEnumerable<ExpVendorRating> Ratings { get; set; } | ||
} |
10 changes: 10 additions & 0 deletions
10
...toCommerce.ProfileExperienceApiModule.Data/Aggregates/Vendor/VendorAggregateRepository.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using VirtoCommerce.CustomerModule.Core.Services; | ||
|
||
namespace VirtoCommerce.ProfileExperienceApiModule.Data.Aggregates.Vendor; | ||
|
||
public class VendorAggregateRepository: MemberAggregateRootRepository, IVendorAggregateRepository | ||
{ | ||
public VendorAggregateRepository(IMemberService memberService, IMemberAggregateFactory factory) : base(memberService, factory) | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/VirtoCommerce.ProfileExperienceApiModule.Data/ExpVendorRating.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using VirtoCommerce.ExperienceApiModule.Core; | ||
|
||
namespace VirtoCommerce.ProfileExperienceApiModule.Data; | ||
|
||
public class ExpVendorRating: ExpRating | ||
{ | ||
public string StoreId { get; set; } | ||
} |
44 changes: 44 additions & 0 deletions
44
src/VirtoCommerce.ProfileExperienceApiModule.Data/Extensions/SchemaExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using GraphQL; | ||
using GraphQL.Resolvers; | ||
using GraphQL.Types; | ||
using MediatR; | ||
using VirtoCommerce.ExperienceApiModule.Core.Extensions; | ||
using VirtoCommerce.ExperienceApiModule.Core.Helpers; | ||
using VirtoCommerce.ProfileExperienceApiModule.Data.Aggregates; | ||
using VirtoCommerce.ProfileExperienceApiModule.Data.Queries; | ||
using VirtoCommerce.ProfileExperienceApiModule.Data.Schemas; | ||
|
||
namespace VirtoCommerce.ProfileExperienceApiModule.Data.Extensions; | ||
|
||
public static class SchemaExtensions | ||
{ | ||
public static void AddMemberQuery<TAggregate, TType, TQuery>(this ISchema schema, IMediator mediator, string name, Func<string, object, Task> checkAuthAsync) | ||
where TAggregate: MemberAggregateRootBase | ||
where TType: MemberBaseType<TAggregate> | ||
where TQuery: GetMemberByIdQueryBase<TAggregate>, new() | ||
{ | ||
schema.Query.AddField(new FieldType | ||
{ | ||
Name = name, | ||
Arguments = new QueryArguments( | ||
new QueryArgument<NonNullGraphType<StringGraphType>> { Name = "id" }, | ||
new QueryArgument<StringGraphType> { Name = "userId" } | ||
), | ||
Type = GraphTypeExtenstionHelper.GetActualType<TType>(), | ||
Resolver = new AsyncFieldResolver<object>(async context => | ||
{ | ||
var query = new TQuery { Id = context.GetArgument<string>("id") }; | ||
var aggregate = await mediator.Send(query); | ||
|
||
await checkAuthAsync(context.GetCurrentUserId(), aggregate); | ||
|
||
//store aggregate in the user context for future usage in the graph types resolvers | ||
context.UserContext.Add($"{name}Aggregate", aggregate); | ||
|
||
return aggregate; | ||
}) | ||
}); | ||
} | ||
} |
15 changes: 0 additions & 15 deletions
15
src/VirtoCommerce.ProfileExperienceApiModule.Data/Queries/GetContactByIdQuery.cs
This file was deleted.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
...mmerce.ProfileExperienceApiModule.Data/Queries/GetContactByIdQuery/GetContactByIdQuery.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System; | ||
using VirtoCommerce.ProfileExperienceApiModule.Data.Aggregates.Contact; | ||
|
||
namespace VirtoCommerce.ProfileExperienceApiModule.Data.Queries; | ||
|
||
public class GetContactByIdQuery : GetMemberByIdQueryBase<ContactAggregate> | ||
{ | ||
public GetContactByIdQuery() | ||
{ | ||
} | ||
|
||
[Obsolete("Use parameterless constructor with object initialization")] | ||
public GetContactByIdQuery(string contactId) | ||
{ | ||
ContactId = contactId; | ||
} | ||
|
||
[Obsolete("Use Id instead")] | ||
public string ContactId | ||
{ | ||
get => Id; | ||
set => Id = value; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...ProfileExperienceApiModule.Data/Queries/GetContactByIdQuery/GetContactByIdQueryHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using VirtoCommerce.ProfileExperienceApiModule.Data.Aggregates.Contact; | ||
|
||
namespace VirtoCommerce.ProfileExperienceApiModule.Data.Queries; | ||
|
||
public class GetContactByIdQueryHandler : GetMemberByIdQueryHandlerBase<GetContactByIdQuery, ContactAggregate> | ||
{ | ||
public GetContactByIdQueryHandler(IContactAggregateRepository contactAggregateRepository): base(contactAggregateRepository) | ||
{ | ||
} | ||
} |
22 changes: 0 additions & 22 deletions
22
src/VirtoCommerce.ProfileExperienceApiModule.Data/Queries/GetContactByIdQueryHandler.cs
This file was deleted.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
....ProfileExperienceApiModule.Data/Queries/GetMemberByIdQueryBase/GetMemberByIdQueryBase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using VirtoCommerce.ExperienceApiModule.Core.Infrastructure; | ||
using VirtoCommerce.ProfileExperienceApiModule.Data.Aggregates; | ||
|
||
namespace VirtoCommerce.ProfileExperienceApiModule.Data.Queries; | ||
|
||
public abstract class GetMemberByIdQueryBase<TAggregate> : IQuery<TAggregate> | ||
where TAggregate : MemberAggregateRootBase | ||
{ | ||
public string Id { get; set; } | ||
} |
23 changes: 23 additions & 0 deletions
23
...eExperienceApiModule.Data/Queries/GetMemberByIdQueryBase/GetMemberByIdQueryHandlerBase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System.Threading.Tasks; | ||
using System.Threading; | ||
using VirtoCommerce.ExperienceApiModule.Core.Infrastructure; | ||
using VirtoCommerce.ProfileExperienceApiModule.Data.Aggregates; | ||
|
||
namespace VirtoCommerce.ProfileExperienceApiModule.Data.Queries; | ||
|
||
public abstract class GetMemberByIdQueryHandlerBase<TQuery, TAggregate> : IQueryHandler<TQuery, TAggregate> | ||
where TQuery: GetMemberByIdQueryBase<TAggregate> | ||
where TAggregate: MemberAggregateRootBase | ||
{ | ||
private readonly IMemberAggregateRootRepository _aggregateRepository; | ||
|
||
protected GetMemberByIdQueryHandlerBase(IMemberAggregateRootRepository aggregateRepository) | ||
{ | ||
_aggregateRepository = aggregateRepository; | ||
} | ||
|
||
public virtual Task<TAggregate> Handle(TQuery request, CancellationToken cancellationToken) | ||
{ | ||
return _aggregateRepository.GetMemberAggregateRootByIdAsync<TAggregate>(request.Id); | ||
} | ||
} |
15 changes: 0 additions & 15 deletions
15
src/VirtoCommerce.ProfileExperienceApiModule.Data/Queries/GetOrganizationByIdQuery.cs
This file was deleted.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
...fileExperienceApiModule.Data/Queries/GetOrganizationByIdQuery/GetOrganizationByIdQuery.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System; | ||
using VirtoCommerce.ProfileExperienceApiModule.Data.Aggregates.Organization; | ||
|
||
namespace VirtoCommerce.ProfileExperienceApiModule.Data.Queries; | ||
|
||
public class GetOrganizationByIdQuery : GetMemberByIdQueryBase<OrganizationAggregate> | ||
{ | ||
public GetOrganizationByIdQuery() | ||
{ | ||
} | ||
|
||
[Obsolete("Use parameterless constructor with object initialization")] | ||
public GetOrganizationByIdQuery(string organizationId) | ||
{ | ||
OrganizationId = organizationId; | ||
} | ||
|
||
[Obsolete("Use Id instead")] | ||
public string OrganizationId | ||
{ | ||
get => Id; | ||
set => Id = value; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...erienceApiModule.Data/Queries/GetOrganizationByIdQuery/GetOrganizationByIdQueryHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using VirtoCommerce.ProfileExperienceApiModule.Data.Aggregates.Organization; | ||
|
||
namespace VirtoCommerce.ProfileExperienceApiModule.Data.Queries; | ||
|
||
public class GetOrganizationByIdQueryHandler : GetMemberByIdQueryHandlerBase<GetOrganizationByIdQuery, OrganizationAggregate> | ||
{ | ||
public GetOrganizationByIdQueryHandler(IOrganizationAggregateRepository contactAggregateRepository) : base(contactAggregateRepository) | ||
{ | ||
} | ||
} |
22 changes: 0 additions & 22 deletions
22
src/VirtoCommerce.ProfileExperienceApiModule.Data/Queries/GetOrganizationByIdQueryHandler.cs
This file was deleted.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
...Commerce.ProfileExperienceApiModule.Data/Queries/GetVendorByIdQuery/GetVendorByIdQuery.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
using VirtoCommerce.ProfileExperienceApiModule.Data.Aggregates.Vendor; | ||
|
||
namespace VirtoCommerce.ProfileExperienceApiModule.Data.Queries; | ||
|
||
public class GetVendorByIdQuery: GetMemberByIdQueryBase<VendorAggregate> | ||
{ | ||
} |
23 changes: 23 additions & 0 deletions
23
...e.ProfileExperienceApiModule.Data/Queries/GetVendorByIdQuery/GetVendorByIdQueryHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using VirtoCommerce.ExperienceApiModule.Core.Pipelines; | ||
using VirtoCommerce.ProfileExperienceApiModule.Data.Aggregates.Vendor; | ||
|
||
namespace VirtoCommerce.ProfileExperienceApiModule.Data.Queries; | ||
|
||
public class GetVendorByIdQueryHandler: GetMemberByIdQueryHandlerBase<GetVendorByIdQuery, VendorAggregate> | ||
{ | ||
private readonly IGenericPipelineLauncher _pipeline; | ||
|
||
public GetVendorByIdQueryHandler(IVendorAggregateRepository aggregateRepository, IGenericPipelineLauncher pipeline) : base(aggregateRepository) | ||
{ | ||
_pipeline = pipeline; | ||
} | ||
|
||
public override async Task<VendorAggregate> Handle(GetVendorByIdQuery request, CancellationToken cancellationToken) | ||
{ | ||
var result = await base.Handle(request, cancellationToken); | ||
await _pipeline.Execute(result); | ||
return result; | ||
} | ||
} |
Oops, something went wrong.