Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using O2NextGen.CertificateManagement.Application.Controllers.ViewModels;
using O2NextGen.CertificateManagement.Application.Services.Interfaces;
using O2NextGen.CertificateManagement.Domain.UseCases.ForCategory.CreateCategory;
using O2NextGen.CertificateManagement.Domain.UseCases.ForCategory.DeleteCategory;
using O2NextGen.CertificateManagement.Domain.UseCases.ForCategory.GetCategories;
Expand All @@ -20,18 +21,21 @@ public class CategoriesController : ControllerBase
{
#region Ctors

public CategoriesController(IMediator mediator, ILogger<CategoriesController> logger)
public CategoriesController(IMediator mediator, ILogger<CategoriesController> logger, ISubscribeService subscribeService)
{
_mediator = mediator ?? throw new ArgumentNullException(nameof(mediator));
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
_subscribeService = subscribeService ?? throw new ArgumentNullException(nameof(subscribeService));;
}

#endregion


#region Fields

private readonly IMediator _mediator;
private readonly ILogger<CategoriesController> _logger;
private readonly ISubscribeService _subscribeService;

private static readonly string GetByIdActionName
= nameof(GetByIdAsync).Replace("Async", string.Empty);
Expand Down Expand Up @@ -77,6 +81,8 @@ public async Task<ActionResult<CreateCategoryCommandResult>> AddAsync(
[FromBody] CategoryViewModel viewModel,
CancellationToken ct)
{
var productId = _subscribeService.GetProductId();
var tenantId = _subscribeService.GetTenantInfo();
var result = await _mediator.Send(
new CreateCategoryCommand(
viewModel.CategoryName,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using O2NextGen.CertificateManagement.Application.Services;
using O2NextGen.CertificateManagement.Application.Services.Interfaces;

namespace O2NextGen.CertificateManagement.Application;

Expand All @@ -15,7 +16,7 @@ public static IServiceCollection AddCustomIntegrations(this IServiceCollection s


services.AddHttpClient<ITemplateService, TemplateService>();
//services.AddHttpClient<ISubscribeService, SubscribeService>();
services.AddHttpClient<ISubscribeService, SubscribeService>();
return services;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace O2NextGen.CertificateManagement.Application.Services.Interfaces;

public interface ISubscribeService
{
Guid GetTenantInfo();

Guid GetProductId();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Microsoft.Extensions.Options;
using O2NextGen.CertificateManagement.Application.Services.Interfaces;

namespace O2NextGen.CertificateManagement.Application.Services;

public class SubscribeService : ISubscribeService
{
private readonly Guid _fakeTenantId = Guid.Parse("A9D99999-CF70-4EEF-8340-BCBAA4B60C4A");
private readonly Guid _fakeProductId = Guid.Parse("A1D11999-CF99-4EEF-8340-BCBAA4B60C4A");
private readonly IOptions<UrlsConfig> _config;
private readonly HttpClient _httpClient;

public SubscribeService(HttpClient httpClient, IOptions<UrlsConfig> config)
{
_httpClient = httpClient;
_config = config;
}

public Guid GetTenantInfo()
{
return _fakeTenantId;
}

public Guid GetProductId()
{
return _fakeProductId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

namespace O2NextGen.CertificateManagement.Domain.UseCases.ForCategory.CreateCategory;

public class CreateCategoryCommandHandler : IRequestHandler<CreateCategoryCommand, CreateCategoryCommandResult>
public class CreateCategoryHandler : IRequestHandler<CreateCategoryCommand, CreateCategoryCommandResult>
{
private readonly IRepository<CategoryEntity> categoryRepository;

public CreateCategoryCommandHandler(IRepository<CategoryEntity> categoryRepository)
public CreateCategoryHandler(IRepository<CategoryEntity> categoryRepository)
{
this.categoryRepository = categoryRepository;
}
Expand All @@ -28,7 +28,7 @@ public async Task<CreateCategoryCommandResult> Handle(CreateCategoryCommand requ
IsDeleted = request.IsDeleted,
TimeLifeInDays = request.TimeLifeInDays,
QuantityCertificates = request.QuantityCertificates,
QuantityPublishCode = request.QuantityPublishCode
QuantityPublishCode = request.QuantityPublishCode,
};

var addedCertificate = await categoryRepository.AddAsync(category, cancellationToken);
Expand Down