forked from hngprojects/hng_boilerplate_csharp_web
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Admin management in Graphql (hngprojects#382)
- Loading branch information
Showing
3 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
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,30 @@ | ||
using Hng.Application.Features.Subscriptions.Commands; | ||
using Hng.Application.Features.Subscriptions.Dtos.Requests; | ||
using Hng.Application.Features.Subscriptions.Dtos.Responses; | ||
using HotChocolate.Authorization; | ||
using MediatR; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
|
||
namespace Hng.Graphql | ||
{ | ||
public partial class Mutations | ||
{ | ||
//[Authorize] | ||
//public async Task<SubscribeFreePlanResponse> SubscribeFreePlan(SubscribeFreePlan command, [FromServices] IMediator mediator) | ||
//{ | ||
// //var command = new SubscribeFreePlan(); | ||
// // return await mediator.Send(command); | ||
|
||
|
||
// // return await mediator.Send(command); | ||
//} | ||
|
||
[Authorize] | ||
public async Task<SubscriptionDto> ActivateSubscription(Guid subscriptionId, [FromServices] IMediator mediator) | ||
{ | ||
var command = new ActivateSubscriptionCommand(subscriptionId); | ||
return await mediator.Send(command); | ||
} | ||
} | ||
} |
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,17 @@ | ||
using Hng.Application.Features.SuperAdmin.Dto; | ||
using Hng.Application.Features.SuperAdmin.Queries; | ||
using Hng.Application.Shared.Dtos; | ||
using MediatR; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace Hng.Graphql | ||
{ | ||
public partial class Queries | ||
{ | ||
public async Task<PagedListDto<UserDto>> GetUsersBySearch(UsersQueryParameters parameters, [FromServices] IMediator mediator) | ||
{ | ||
var users = new GetUsersBySearchQuery(parameters); | ||
return await mediator.Send(users); | ||
} | ||
} | ||
} |
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,35 @@ | ||
using Hng.Application.Features.Subscriptions.Dtos.Requests; | ||
using Hng.Application.Features.Subscriptions.Dtos.Responses; | ||
using Hng.Application.Features.Subscriptions.Queries; | ||
using Hng.Application.Shared.Dtos; | ||
using HotChocolate.Authorization; | ||
using MediatR; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
|
||
namespace Hng.Graphql | ||
{ | ||
public partial class Queries | ||
{ | ||
[Authorize] | ||
public async Task<SubscriptionDto> GetSubscriptionByOrganizationId(Guid organizationId, [FromServices] IMediator mediator) | ||
{ | ||
var response = new GetSubscriptionByOrganizationIdQuery(organizationId); | ||
return await mediator.Send(response); | ||
} | ||
|
||
[Authorize] | ||
public async Task<SubscriptionDto> GetSubscriptionByUserId(Guid userId, [FromServices] IMediator mediator) | ||
{ | ||
var response = new GetSubscriptionByUserIdQuery(userId); | ||
return await mediator.Send(response); | ||
} | ||
|
||
[Authorize] | ||
public async Task<PagedListDto<SubscriptionDto>> GetSubscriptions(GetSubscriptionsQueryParameters parameters, [FromServices] IMediator mediator) | ||
{ | ||
var subscriptions = new GetSubscriptionsQuery(parameters); | ||
return await mediator.Send(subscriptions); | ||
} | ||
} | ||
} |