diff --git a/src/Services/c-gen/.vscode/launch.json b/src/Services/c-gen/.vscode/launch.json new file mode 100644 index 00000000..379ff20e --- /dev/null +++ b/src/Services/c-gen/.vscode/launch.json @@ -0,0 +1,35 @@ +{ + "version": "0.2.0", + "configurations": [ + { + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md + "name": ".NET Core Launch (web)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceFolder}/O2NextGen.CertificateManagement.Application/bin/Debug/net6.0/O2NextGen.CertificateManagement.Application.dll", + "args": [], + "cwd": "${workspaceFolder}/O2NextGen.CertificateManagement.Application", + "stopAtEntry": false, + // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser + "serverReadyAction": { + "action": "openExternally", + "pattern": "\\bNow listening on:\\s+(https?://\\S+)" + }, + "env": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "sourceFileMap": { + "/Views": "${workspaceFolder}/Views" + } + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach" + } + ] +} \ No newline at end of file diff --git a/src/Services/c-gen/.vscode/settings.json b/src/Services/c-gen/.vscode/settings.json new file mode 100644 index 00000000..37099cae --- /dev/null +++ b/src/Services/c-gen/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "dotnet-test-explorer.enableTelemetry": false, + "dotnet-test-explorer.testProjectPath": "Tests/*/*Tests.*.csproj" +} \ No newline at end of file diff --git a/src/Services/c-gen/.vscode/tasks.json b/src/Services/c-gen/.vscode/tasks.json new file mode 100644 index 00000000..0ccddd83 --- /dev/null +++ b/src/Services/c-gen/.vscode/tasks.json @@ -0,0 +1,72 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/O2NextGen.CertificateManagement.Application/O2NextGen.CertificateManagement.Application.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "publish", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "${workspaceFolder}/O2NextGen.CertificateManagement.Application/O2NextGen.CertificateManagement.Application.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "watch", + "command": "dotnet", + "type": "process", + "args": [ + "watch", + "run", + "--project", + "${workspaceFolder}/O2NextGen.CertificateManagement.Application/O2NextGen.CertificateManagement.Application.csproj" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "test", + "command": "dotnet", + "type": "process", + "args": [ + "test", + "${workspaceFolder}/Tests/IntegrationTests.O2NextGen.CertificateManagement.Application/IntegrationTests.O2NextGen.CertificateManagement.Application.csproj" + ], + "problemMatcher": "$msCompile", + "group": { + "kind": "test", + "isDefault": true + } + }, + { + "label": "test with coverage", + "command": "dotnet", + "type": "process", + "args": [ + "test", + "/p:CollectCoverage=true", + "/p:CoverletOutputFormat=lcov", + "/p:CoverletOutput=./lcov.info", + "${workspaceFolder}/Tests/IntegrationTests.O2NextGen.CertificateManagement.Application/IntegrationTests.O2NextGen.CertificateManagement.Application.csproj" + ], + "problemMatcher": "$msCompile", + "group": { + "kind": "test", + "isDefault": true + } + }, + ] +} \ No newline at end of file diff --git a/src/Services/c-gen/O2NextGen.CGen.sln b/src/Services/c-gen/O2NextGen.CGen.sln index 5ca96657..ffc04efb 100644 --- a/src/Services/c-gen/O2NextGen.CGen.sln +++ b/src/Services/c-gen/O2NextGen.CGen.sln @@ -41,6 +41,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CQRS", "CQRS", "{0835E199-8 EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests.O2NextGen.CertificateManagement.Infrastructure", "Tests\Tests.O2NextGen.CertificateManagement.Infrastructure\Tests.O2NextGen.CertificateManagement.Infrastructure.csproj", "{EC5B79FF-4A87-4740-B5EC-2778861EB017}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests.O2NextGen.CertificateManagement.Domain", "Tests\Tests.O2NextGen.CertificateManagement.Domain\Tests.O2NextGen.CertificateManagement.Domain.csproj", "{EFBD38BF-67DF-4507-94DC-E8BED67B6CF5}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests.O2NextGen.CertificateManagement.Application", "Tests\Tests.O2NextGen.CertificateManagement.Application\Tests.O2NextGen.CertificateManagement.Application.csproj", "{6EE05F8B-1BF0-493A-9408-C824F5C2D271}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -103,6 +107,14 @@ Global {EC5B79FF-4A87-4740-B5EC-2778861EB017}.Debug|Any CPU.Build.0 = Debug|Any CPU {EC5B79FF-4A87-4740-B5EC-2778861EB017}.Release|Any CPU.ActiveCfg = Release|Any CPU {EC5B79FF-4A87-4740-B5EC-2778861EB017}.Release|Any CPU.Build.0 = Release|Any CPU + {EFBD38BF-67DF-4507-94DC-E8BED67B6CF5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EFBD38BF-67DF-4507-94DC-E8BED67B6CF5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EFBD38BF-67DF-4507-94DC-E8BED67B6CF5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EFBD38BF-67DF-4507-94DC-E8BED67B6CF5}.Release|Any CPU.Build.0 = Release|Any CPU + {6EE05F8B-1BF0-493A-9408-C824F5C2D271}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6EE05F8B-1BF0-493A-9408-C824F5C2D271}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6EE05F8B-1BF0-493A-9408-C824F5C2D271}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6EE05F8B-1BF0-493A-9408-C824F5C2D271}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -123,6 +135,8 @@ Global {58CC0839-863D-4708-A6D4-42F245593538} = {0835E199-8062-45E0-899E-38ECAD9437CD} {0835E199-8062-45E0-899E-38ECAD9437CD} = {12E83C2A-23C7-4E71-B137-AC56CE28F9E4} {EC5B79FF-4A87-4740-B5EC-2778861EB017} = {0835E199-8062-45E0-899E-38ECAD9437CD} + {EFBD38BF-67DF-4507-94DC-E8BED67B6CF5} = {0835E199-8062-45E0-899E-38ECAD9437CD} + {6EE05F8B-1BF0-493A-9408-C824F5C2D271} = {0835E199-8062-45E0-899E-38ECAD9437CD} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {A6DFC9F0-3FA7-492B-ACE9-3EFBF3477712} diff --git a/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Features/Categories/CategoriesController.cs b/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Features/Categories/CategoriesController.cs index b16cb8bc..4259dabf 100644 --- a/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Features/Categories/CategoriesController.cs +++ b/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Features/Categories/CategoriesController.cs @@ -1,34 +1,35 @@ -using System.Threading; -using System.Threading.Tasks; -using MediatR; +using MediatR; using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Logging; -using O2NextGen.CertificateManagement.Application.Controllers; using O2NextGen.CertificateManagement.Domain.UseCases.ForCategory.CreateCategory; +using O2NextGen.CertificateManagement.Domain.UseCases.ForCategory.DeleteCategory; using O2NextGen.CertificateManagement.Domain.UseCases.ForCategory.GetCategories; using O2NextGen.CertificateManagement.Domain.UseCases.ForCategory.GetCategory; +using O2NextGen.CertificateManagement.Domain.UseCases.ForCategory.UpdateCategory; namespace O2NextGen.CertificateManagement.Application.Features.Categories { [Route("api/[controller]")] + //[ApiVersion("1.0")] + [ApiController] public class CategoriesController : ControllerBase { #region Fields private readonly IMediator _mediator; - private readonly ILogger _logger; + private readonly ILogger _logger; private static readonly string GetByIdActionName = nameof(GetByIdAsync).Replace("Async", string.Empty); + #endregion #region Ctors - public CategoriesController(IMediator mediator, ILogger logger) + public CategoriesController(IMediator mediator, ILogger logger) { - _mediator = mediator; - _logger = logger; + _mediator = mediator ?? throw new ArgumentNullException(nameof(mediator)); + _logger = logger ?? throw new ArgumentNullException(nameof(logger)); } #endregion @@ -40,11 +41,17 @@ public CategoriesController(IMediator mediator, ILogger [Route("{id}")] public async Task GetByIdAsync(long id, CancellationToken ct) { - var result = await _mediator.Send(new GetCategoryQuery(id)); + _logger.LogInformation("Call API method {ByIdAsyncName}: id = {Id}", nameof(GetByIdAsync), id); + + var result = await _mediator.Send(new GetCategoryQuery(id), ct); if (result is null) + { + _logger.LogError("GetByIdAsync: not found id = {Id}", id); return NotFound(); + } + _logger.LogInformation("GetByIdAsync: OK"); return Ok(result); } @@ -60,16 +67,50 @@ public async Task GetAllAsync() [HttpPost] [Route("")] public async Task> AddAsync( - CreateCategoryDetailsCommandModel model, + [FromBody] CreateCategoryModel model, CancellationToken ct) { var result = await _mediator.Send( - new CreateCategoryCommand()); + new CreateCategoryCommand( + model.CategoryName, + model.QuantityCertificates, + model.CategoryDescription, + model.CategorySeries), + ct); return CreatedAtAction(GetByIdActionName, - new { id = result.Id }, result); + new {id = result.Id}, result); } + [HttpPut] + [Route("{id}")] + public async Task> UpdateAsync( + long id, [FromBody] UpdateCategoryModel model, CancellationToken ct) + { + var result = await _mediator.Send( + new UpdateCategoryDetailsCommand( + model.Id, + model.CategoryName, + model.CategoryDescription, + model.CategorySeries, + model.CustomerId, + model.QuantityCertificates, + model.QuantityPublishCode), ct); + + if (result is null) + { + return NotFound(); + } + + return result; + } + + [HttpDelete] + [Route("{id}")] + public async Task RemoveAsync(long id, CancellationToken ct) + { + await _mediator.Send(new DeleteCategoryCommand(id), ct); + return NoContent(); + } #endregion } -} - +} \ No newline at end of file diff --git a/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Features/Categories/CreateCategoryDetailsCommandModel.cs b/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Features/Categories/CreateCategoryDetailsCommandModel.cs deleted file mode 100644 index 65941ff2..00000000 --- a/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Features/Categories/CreateCategoryDetailsCommandModel.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace O2NextGen.CertificateManagement.Application.Features.Categories -{ - public class CreateCategoryDetailsCommandModel - { - } -} \ No newline at end of file diff --git a/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Features/Categories/CreateCategoryModel.cs b/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Features/Categories/CreateCategoryModel.cs new file mode 100644 index 00000000..636ca9bc --- /dev/null +++ b/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Features/Categories/CreateCategoryModel.cs @@ -0,0 +1,19 @@ +using System.Runtime.Serialization; + +namespace O2NextGen.CertificateManagement.Application.Features.Categories +{ + public class CreateCategoryModel : ICreateCategoryModel + { + public string CategoryName { get; set; } + public string CategoryDescription { get; set; } + public string CategorySeries { get; set; } + public string CustomerId { get; set; } + public long? AddedDate { get; set; } + public long? ModifiedDate { get; set; } + public long? DeletedDate { get; set; } + public bool? IsDeleted { get; set; } + public int TimeLifeInDays { get; set; } + public int QuantityCertificates { get; set; } + public int QuantityPublishCode { get; set; } + } +} \ No newline at end of file diff --git a/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Features/Categories/ICreateCategoryModel.cs b/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Features/Categories/ICreateCategoryModel.cs new file mode 100644 index 00000000..1329e634 --- /dev/null +++ b/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Features/Categories/ICreateCategoryModel.cs @@ -0,0 +1,11 @@ +namespace O2NextGen.CertificateManagement.Application.Features.Categories; + +public interface ICreateCategoryModel +{ + string CategoryName { get; set; } + string CategoryDescription { get; set; } + string CategorySeries { get; set; } + string CustomerId { get; set; } + public int QuantityCertificates { get; set; } + public int QuantityPublishCode { get; set; } +} \ No newline at end of file diff --git a/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Features/Categories/ResponseDto.cs b/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Features/Categories/ResponseDto.cs new file mode 100644 index 00000000..2f2daeb2 --- /dev/null +++ b/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Features/Categories/ResponseDto.cs @@ -0,0 +1,6 @@ +namespace O2NextGen.CertificateManagement.Application.Features.Categories; + +public class ResponseDto +{ + +} \ No newline at end of file diff --git a/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Features/Categories/UpdateCategoryModel.cs b/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Features/Categories/UpdateCategoryModel.cs new file mode 100644 index 00000000..f86f7efb --- /dev/null +++ b/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Features/Categories/UpdateCategoryModel.cs @@ -0,0 +1,6 @@ +namespace O2NextGen.CertificateManagement.Application.Features.Categories; + +public class UpdateCategoryModel : CreateCategoryModel +{ + public long Id { get; set; } +} \ No newline at end of file diff --git a/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Features/Certificates/CertificatesController.cs b/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Features/Certificates/CertificatesController.cs index 311075df..f5410efa 100644 --- a/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Features/Certificates/CertificatesController.cs +++ b/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Features/Certificates/CertificatesController.cs @@ -1,17 +1,15 @@ -using System.Threading; -using System.Threading.Tasks; -using MediatR; +using MediatR; using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Logging; -using O2NextGen.CertificateManagement.Domain.Data.Queries; using O2NextGen.CertificateManagement.Domain.UseCases.ForCertificate.CreateCertificate; using O2NextGen.CertificateManagement.Domain.UseCases.ForCertificate.DeleteCertificate; +using O2NextGen.CertificateManagement.Domain.UseCases.ForCertificate.GetCertificate; using O2NextGen.CertificateManagement.Domain.UseCases.ForCertificate.GetCertificates; using O2NextGen.CertificateManagement.Domain.UseCases.ForCertificate.UpdateCertificate; -namespace O2NextGen.CertificateManagement.Application.Controllers +namespace O2NextGen.CertificateManagement.Application.Features.Certificates { [Route("api/[controller]")] + [ApiController] public partial class CertificatesController : ControllerBase { #region Fields @@ -41,7 +39,7 @@ public CertificatesController(IMediator mediator, ILogger GetByIdAsync(long id, CancellationToken ct) { - var result = await _mediator.Send(new CertificateQuery(id)); + var result = await _mediator.Send(new GetCertificateQuery(id), ct); if (result is null) return NotFound(); @@ -60,7 +58,7 @@ public async Task GetAllAsync() [HttpPut] [Route("id")] public async Task> UpdateAsync( - long id, UpdateCertificateDetailsCommandModel model, CancellationToken ct) + long id, [FromBody] UpdateCertificateDetailsCommandModel model, CancellationToken ct) { var result = await _mediator.Send( new UpdateCertificateDetailsCommand( @@ -96,7 +94,7 @@ public async Task> UpdateAsy [HttpPost] [Route("")] public async Task> AddAsync( - CreateCertificateDetailsCommandModel model, + [FromBody] CreateCertificateDetailsCommandModel model, CancellationToken ct) { var result = await _mediator.Send( diff --git a/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Features/Certificates/CreateCertificateDetailsCommandModel.cs b/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Features/Certificates/CreateCertificateDetailsCommandModel.cs index 91cb0f14..e435afd5 100644 --- a/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Features/Certificates/CreateCertificateDetailsCommandModel.cs +++ b/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Features/Certificates/CreateCertificateDetailsCommandModel.cs @@ -1,5 +1,6 @@ -using System.Collections.Generic; -using O2NextGen.CertificateManagement.Domain.Entities; +using O2NextGen.CertificateManagement.Domain.Entities; + +namespace O2NextGen.CertificateManagement.Application.Features.Certificates; public class CreateCertificateDetailsCommandModel { @@ -20,5 +21,4 @@ public class CreateCertificateDetailsCommandModel public long LockedDate { get; set; } public string LockInfo { get; set; } public ICollection LanguageInfos { get; } -} - +} \ No newline at end of file diff --git a/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Features/Certificates/UpdateCertificateDetailsCommandModel.cs b/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Features/Certificates/UpdateCertificateDetailsCommandModel.cs index cb0a07ef..ea5d7057 100644 --- a/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Features/Certificates/UpdateCertificateDetailsCommandModel.cs +++ b/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Features/Certificates/UpdateCertificateDetailsCommandModel.cs @@ -1,5 +1,6 @@ -using System.Collections.Generic; -using O2NextGen.CertificateManagement.Domain.Entities; +using O2NextGen.CertificateManagement.Domain.Entities; + +namespace O2NextGen.CertificateManagement.Application.Features.Certificates; public class UpdateCertificateDetailsCommandModel { @@ -23,5 +24,4 @@ public class UpdateCertificateDetailsCommandModel public bool? ModifiedDate { get; internal set; } public string AddedDate { get; internal set; } public string DeletedDate { get; internal set; } -} - +} \ No newline at end of file diff --git a/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Features/Projects/ProjectViewModel.cs b/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Features/Projects/ProjectViewModel.cs new file mode 100644 index 00000000..990a10f8 --- /dev/null +++ b/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Features/Projects/ProjectViewModel.cs @@ -0,0 +1,8 @@ +namespace O2NextGen.CertificateManagement.Application.Features.Projects; + +public class ProjectViewModel +{ + public string Name { get; set; } + public string Description { get; set; } + public Guid TenantId { get; set; } +} \ No newline at end of file diff --git a/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Features/Projects/ProjectsController.cs b/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Features/Projects/ProjectsController.cs new file mode 100644 index 00000000..934e41eb --- /dev/null +++ b/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Features/Projects/ProjectsController.cs @@ -0,0 +1,82 @@ +using System.Net; +using Microsoft.AspNetCore.Mvc; +using O2NextGen.CertificateManagement.Application.Services; + +namespace O2NextGen.CertificateManagement.Application.Features.Projects; + +[Route("api/[controller]")] +public class ProjectsController : ControllerBase +{ + private readonly ICustomerService _customerService; + + private List memoryList { get; } + + public ProjectsController(ICustomerService customerService) + { + _customerService = customerService; + memoryList = new List + { + new ProjectViewModel + { + Name = "PROJECT PFR", + Description = "Project of PFR CENTER", + TenantId = _customerService.CustomerId + }, + new ProjectViewModel() + { + Name = "PROJECT PFR 2", + Description = "Project of PFR CENTER", + TenantId = _customerService.CustomerId + } + }; + } + + [HttpGet] + [ProducesResponseType((int) HttpStatusCode.NotFound)] + [ProducesResponseType((int) HttpStatusCode.BadRequest)] + [ProducesResponseType((int) HttpStatusCode.Accepted)] + [Route("{id:long}")] + public IActionResult GetById() + { + return Ok(memoryList.FirstOrDefault()); + } + + [HttpGet] + [Route("")] + [ProducesResponseType((int) HttpStatusCode.NotFound)] + [ProducesResponseType((int) HttpStatusCode.BadRequest)] + [ProducesResponseType((int) HttpStatusCode.Accepted)] + public async Task GetAllAsync() + { + return Ok(memoryList); + } + + [HttpPut] + [Route("id")] + [ProducesResponseType((int) HttpStatusCode.NotFound)] + [ProducesResponseType((int) HttpStatusCode.BadRequest)] + [ProducesResponseType((int) HttpStatusCode.Accepted)] + public async Task UpdateAsync() + { + return Ok(memoryList.FirstOrDefault()); + } + + [HttpPut] + [HttpPost] + [Route("")] + [ProducesResponseType((int) HttpStatusCode.Created)] + [ProducesResponseType((int) HttpStatusCode.BadRequest)] + public async Task AddAsync() + { + return Ok(memoryList.FirstOrDefault()); + } + + + [HttpDelete] + [Route("{id}")] + [ProducesResponseType((int) HttpStatusCode.NoContent)] + public async Task RemoveAsync(long id, CancellationToken ct) + { + return NoContent(); + } +} \ No newline at end of file diff --git a/src/Services/c-gen/O2NextGen.CertificateManagement.Application/IServiceUrl.cs b/src/Services/c-gen/O2NextGen.CertificateManagement.Application/IServiceUrl.cs new file mode 100644 index 00000000..77b88296 --- /dev/null +++ b/src/Services/c-gen/O2NextGen.CertificateManagement.Application/IServiceUrl.cs @@ -0,0 +1,8 @@ +namespace O2NextGen.CertificateManagement.Application; + +public interface IServiceUrl +{ + string IdentityUrl { get; set; } + + string CGenUrl { get; set; } +} \ No newline at end of file diff --git a/src/Services/c-gen/O2NextGen.CertificateManagement.Application/IoC/ServiceCollectionExtensions.cs b/src/Services/c-gen/O2NextGen.CertificateManagement.Application/IoC/ServiceCollectionExtensions.cs index 1571b777..4aefec4a 100644 --- a/src/Services/c-gen/O2NextGen.CertificateManagement.Application/IoC/ServiceCollectionExtensions.cs +++ b/src/Services/c-gen/O2NextGen.CertificateManagement.Application/IoC/ServiceCollectionExtensions.cs @@ -1,12 +1,10 @@ -using System; -using MediatR; +using MediatR; using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Configuration; using O2NextGen.CertificateManagement.Domain.Data; using O2NextGen.CertificateManagement.Domain.Data.Queries; using O2NextGen.CertificateManagement.Infrastructure.Data; -namespace Microsoft.Extensions.DependencyInjection +namespace O2NextGen.CertificateManagement.Application.IoC { public static class ServiceCollectionExtensions { diff --git a/src/Services/c-gen/O2NextGen.CertificateManagement.Application/O2NextGen.CertificateManagement.Application.csproj b/src/Services/c-gen/O2NextGen.CertificateManagement.Application/O2NextGen.CertificateManagement.Application.csproj index 69a7a6c5..0aec1770 100644 --- a/src/Services/c-gen/O2NextGen.CertificateManagement.Application/O2NextGen.CertificateManagement.Application.csproj +++ b/src/Services/c-gen/O2NextGen.CertificateManagement.Application/O2NextGen.CertificateManagement.Application.csproj @@ -7,6 +7,11 @@ + + + + + diff --git a/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Program.cs b/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Program.cs index 6bee5714..b14b74a0 100644 --- a/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Program.cs +++ b/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Program.cs @@ -1,7 +1,5 @@ -using System.Threading.Tasks; -using Microsoft.AspNetCore.Builder; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; +using O2NextGen.CertificateManagement.Application; +using O2NextGen.CertificateManagement.Application.IoC; using O2NextGen.CertificateManagement.Infrastructure.Data; using O2NextGen.CertificateManagement.StartupTasks.DatabaseInitializer; @@ -21,6 +19,10 @@ var app = builder.Build(); +var scope = app.Services.CreateScope(); +var context = scope.ServiceProvider.GetRequiredService(); +SeedData.SeedAsync(context).Wait(); + // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) { diff --git a/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Properties/launchSettings.json b/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Properties/launchSettings.json index c03bb64c..c19fff4c 100644 --- a/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Properties/launchSettings.json +++ b/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Properties/launchSettings.json @@ -1,26 +1,9 @@ { - "$schema": "https://json.schemastore.org/launchsettings.json", - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:53435", - "sslPort": 44357 - } - }, "profiles": { "O2NextGen.CertificateManagement.Application": { "commandName": "Project", "launchBrowser": true, - "applicationUrl": "http://localhost:2579", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, - "launchUrl": "swagger", + "applicationUrl": "https://localhost:11001", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } diff --git a/src/Services/c-gen/O2NextGen.CertificateManagement.Application/SeedData.cs b/src/Services/c-gen/O2NextGen.CertificateManagement.Application/SeedData.cs new file mode 100644 index 00000000..00686c2c --- /dev/null +++ b/src/Services/c-gen/O2NextGen.CertificateManagement.Application/SeedData.cs @@ -0,0 +1,106 @@ +using Microsoft.EntityFrameworkCore; +using O2NextGen.CertificateManagement.Domain.Entities; +using O2NextGen.CertificateManagement.Infrastructure.Data; +using O2NextGen.Sdk.NetCore.Extensions; + +namespace O2NextGen.CertificateManagement.Application; + +public class SeedData +{ + public static async Task SeedAsync(CGenDbContext context) + { + context.Database.Migrate(); + + if (!context.Categories.Any()) + { + context.Categories.AddRange( + GetPreconfiguredCategories()); + await context.SaveChangesAsync(); + } + + if (!context.Certificates.Any()) + { + context.Certificates.AddRange( + GetPreconfiguredCertificates(context)); + await context.SaveChangesAsync(); + } + } + + private static Certificate[] GetPreconfiguredCertificates(CGenDbContext cGenDbContext) + { + return new Certificate[] + { + new Certificate() + { + Category = cGenDbContext.Categories.FirstOrDefault(), + CustomerId = Guid.NewGuid().ToString(), + AddedDate = DateTime.Now.ConvertToUnixTime(), + IsVisible = true, + CategoryId = cGenDbContext.Categories.FirstOrDefault().Id, + CreatorId = Guid.NewGuid().ToString(), + ExpiredDate = DateTime.Now.AddYears(1).ConvertToUnixTime() + }, + new Certificate() + { + Category = cGenDbContext.Categories.FirstOrDefault(), + CustomerId = Guid.NewGuid().ToString(), + AddedDate = DateTime.Now.ConvertToUnixTime(), + IsVisible = true, + CategoryId = cGenDbContext.Categories.FirstOrDefault().Id, + CreatorId = Guid.NewGuid().ToString(), + ExpiredDate = DateTime.Now.AddYears(1).ConvertToUnixTime() + }, + new Certificate() + { + Category = cGenDbContext.Categories.FirstOrDefault(), + CustomerId = Guid.NewGuid().ToString(), + AddedDate = DateTime.Now.ConvertToUnixTime(), + IsVisible = true, + CategoryId = cGenDbContext.Categories.FirstOrDefault().Id, + CreatorId = Guid.NewGuid().ToString(), + ExpiredDate = DateTime.Now.AddYears(1).ConvertToUnixTime() + }, + new Certificate() + { + Category = cGenDbContext.Categories.FirstOrDefault(), + CustomerId = Guid.NewGuid().ToString(), + AddedDate = DateTime.Now.ConvertToUnixTime(), + IsVisible = true, + CategoryId = cGenDbContext.Categories.FirstOrDefault().Id, + CreatorId = Guid.NewGuid().ToString(), + ExpiredDate = DateTime.Now.AddYears(1).ConvertToUnixTime() + }, + + new Certificate() + { + Category = cGenDbContext.Categories.FirstOrDefault(), + CustomerId = Guid.NewGuid().ToString(), + AddedDate = DateTime.Now.ConvertToUnixTime(), + IsVisible = true, + CategoryId = cGenDbContext.Categories.FirstOrDefault().Id, + CreatorId = Guid.NewGuid().ToString(), + ExpiredDate = DateTime.Now.AddYears(1).ConvertToUnixTime() + } + }; + } + + private static Category[] GetPreconfiguredCategories() + { + return new Category[] { + new Category() + { + CategoryName = "AA Category", + CategorySeries = "A", + CategoryDescription = "desc category A", + QuantityCertificates = 120 + }, + new Category() + { + CategoryName = "B Category", + CategorySeries = "B", + CategoryDescription = "desc category B", + QuantityCertificates = 120 + } + }; + } +} \ No newline at end of file diff --git a/src/Services/c-gen/O2NextGen.CertificateManagement.Application/ServiceUrls.cs b/src/Services/c-gen/O2NextGen.CertificateManagement.Application/ServiceUrls.cs new file mode 100644 index 00000000..81148220 --- /dev/null +++ b/src/Services/c-gen/O2NextGen.CertificateManagement.Application/ServiceUrls.cs @@ -0,0 +1,8 @@ +namespace O2NextGen.CertificateManagement.Application; + +public class ServiceUrls: IServiceUrl +{ + public string IdentityUrl { get; set; } + + public string CGenUrl { get; set; } +} \ No newline at end of file diff --git a/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Services/CustomerService.cs b/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Services/CustomerService.cs new file mode 100644 index 00000000..ca96efca --- /dev/null +++ b/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Services/CustomerService.cs @@ -0,0 +1,19 @@ +namespace O2NextGen.CertificateManagement.Application.Services +{ + public class CustomerService : ICustomerService + { + // ReSharper disable once NotAccessedField.Local + private IHttpContextAccessor _context; + + public CustomerService(IHttpContextAccessor context) + { + _context = context ?? throw new ArgumentNullException(nameof(context)); + } + + public Guid CustomerId { get; } = Guid.Parse("A6D86517-CF70-4EEF-8340-BCBAA4B60C4A"); + public string CustomerDescription { get; set; } = "#PF_R Community"; + public string RegisterLink { get; set; } = "https://pfr-centr.com"; + public string AccountLink { get; set; } = "https://pfr-centr.com"; + } +} + diff --git a/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Services/ICustomerService.cs b/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Services/ICustomerService.cs new file mode 100644 index 00000000..4921d27c --- /dev/null +++ b/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Services/ICustomerService.cs @@ -0,0 +1,11 @@ +namespace O2NextGen.CertificateManagement.Application.Services +{ + public interface ICustomerService + { + Guid CustomerId { get; } + string CustomerDescription { get; set; } + string RegisterLink { get; set; } + string AccountLink { get; set; } + } +} + diff --git a/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Services/IIdentityService.cs b/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Services/IIdentityService.cs new file mode 100644 index 00000000..73f75c43 --- /dev/null +++ b/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Services/IIdentityService.cs @@ -0,0 +1,10 @@ +namespace O2NextGen.CertificateManagement.Application.Services +{ + public interface IIdentityService + { + string GetUserIdentity(); + + string GetUserName(); + } +} + diff --git a/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Services/IdentityService.cs b/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Services/IdentityService.cs new file mode 100644 index 00000000..67a65962 --- /dev/null +++ b/src/Services/c-gen/O2NextGen.CertificateManagement.Application/Services/IdentityService.cs @@ -0,0 +1,23 @@ +namespace O2NextGen.CertificateManagement.Application.Services +{ + public class IdentityService : IIdentityService + { + private IHttpContextAccessor _context; + + public IdentityService(IHttpContextAccessor context) + { + _context = context ?? throw new ArgumentNullException(nameof(context)); + } + + public string GetUserIdentity() + { + return _context.HttpContext.User.FindFirst("sub").Value; + } + + public string GetUserName() + { + return _context.HttpContext.User.Identity.Name; + } + } +} + diff --git a/src/Services/c-gen/O2NextGen.CertificateManagement.Application/appsettings.Development.json b/src/Services/c-gen/O2NextGen.CertificateManagement.Application/appsettings.Development.json index 8722d7d1..43bc444f 100644 --- a/src/Services/c-gen/O2NextGen.CertificateManagement.Application/appsettings.Development.json +++ b/src/Services/c-gen/O2NextGen.CertificateManagement.Application/appsettings.Development.json @@ -2,12 +2,15 @@ "DatabaseInitializerSettings": { "Initialize": true }, - "ConnectionString": "Server=20.112.192.201;Initial Catalog=O2NextGen.CertificateDb-Dev;Persist Security Info=False;User ID=sa;Password=yourStrong(!)Password;Connection Timeout=30;", + "ConnectionString": "Server=52.185.108.164;Initial Catalog=O2NextGen.CertificateDb-Dev;Persist Security Info=False;User ID=sa;Password=yourStrong(!)Password;Connection Timeout=30;", "Logging": { "LogLevel": { "Default": "Information", "Microsoft.AspNetCore": "Information" } + }, + "Urls": { + "Auth": "http://localhost:10001" } } diff --git a/src/Services/c-gen/O2NextGen.CertificateManagement.Application/appsettings.json b/src/Services/c-gen/O2NextGen.CertificateManagement.Application/appsettings.json index 40a7b0b9..bcc9a7da 100644 --- a/src/Services/c-gen/O2NextGen.CertificateManagement.Application/appsettings.json +++ b/src/Services/c-gen/O2NextGen.CertificateManagement.Application/appsettings.json @@ -2,7 +2,7 @@ "DatabaseInitializerSettings": { "Initialize": true }, - "ConnectionString": "Server=20.112.192.201;Initial Catalog=O2NextGen.CertificateDb;Persist Security Info=False;User ID=sa;Password=yourStrong(!)Password;Connection Timeout=30;", + "ConnectionString": "Server=52.185.108.164;Initial Catalog=O2NextGen.CertificateDb;Persist Security Info=False;User ID=sa;Password=yourStrong(!)Password;Connection Timeout=30;", "Urls": { "Auth": "http://localhost:10001" }, diff --git a/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/Data/Queries/CategoryQuery.cs b/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/Data/Queries/CategoryQuery.cs index 36e5ee0c..50c70be8 100644 --- a/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/Data/Queries/CategoryQuery.cs +++ b/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/Data/Queries/CategoryQuery.cs @@ -2,12 +2,17 @@ { public class CategoryQuery : IQuery { + public long Id { get; set; } + public string CategoryName { get; set; } + public int QuantityCertificates { get; set; } + public string CategoryDescription { get; set; } + public string CategorySeries { get; set; } + public CategoryQuery(long id) { Id = id; } - public long Id { get; } } } diff --git a/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/O2NextGen.CertificateManagement.Domain.csproj b/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/O2NextGen.CertificateManagement.Domain.csproj index 4aaabf2d..ad7caf94 100644 --- a/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/O2NextGen.CertificateManagement.Domain.csproj +++ b/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/O2NextGen.CertificateManagement.Domain.csproj @@ -31,5 +31,6 @@ + diff --git a/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCategory/CreateCategory/CreateCategoryCommand.cs b/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCategory/CreateCategory/CreateCategoryCommand.cs index 21d410ce..6f93316c 100644 --- a/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCategory/CreateCategory/CreateCategoryCommand.cs +++ b/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCategory/CreateCategory/CreateCategoryCommand.cs @@ -1,20 +1,30 @@ using MediatR; - + namespace O2NextGen.CertificateManagement.Domain.UseCases.ForCategory.CreateCategory { public class CreateCategoryCommand : IRequest { - public long Id { get; internal set; } - public string CategoryName { get; internal set; } - public string CategoryDescription { get; internal set; } - public string CategorySeries { get; internal set; } + private readonly long _id; + + public CreateCategoryCommand(string categoryName, int quantityCertificates, + string categoryDescription, string categorySeries) + { + CategoryName = categoryName; + QuantityCertificates = quantityCertificates; + CategoryDescription = categoryDescription; + CategorySeries = categorySeries; + } + + public string CategoryName { get; } + public string CategoryDescription { get; } + public string CategorySeries { get; } public string CustomerId { get; internal set; } public long AddedDate { get; internal set; } public long ModifiedDate { get; internal set; } public long? DeletedDate { get; internal set; } public bool? IsDeleted { get; internal set; } public int TimeLifeInDays { get; internal set; } - public int QuantityCertificates { get; internal set; } + public int QuantityCertificates { get; } public int QuantityPublishCode { get; internal set; } } } \ No newline at end of file diff --git a/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCategory/CreateCategory/CreateCategoryCommandHandler.cs b/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCategory/CreateCategory/CreateCategoryCommandHandler.cs index 1c5cb983..6f0eebae 100644 --- a/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCategory/CreateCategory/CreateCategoryCommandHandler.cs +++ b/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCategory/CreateCategory/CreateCategoryCommandHandler.cs @@ -19,7 +19,6 @@ public async Task Handle(CreateCategoryCommand requ { var category = new Entities.Category { - Id = request.Id, CategoryName = request.CategoryName, CategoryDescription = request.CategoryDescription, CategorySeries = request.CategorySeries, diff --git a/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCategory/DeleteCategory/DeleteCategoryCommand.cs b/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCategory/DeleteCategory/DeleteCategoryCommand.cs index 39167af3..f4c472b8 100644 --- a/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCategory/DeleteCategory/DeleteCategoryCommand.cs +++ b/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCategory/DeleteCategory/DeleteCategoryCommand.cs @@ -1,11 +1,15 @@  -using MediatR; - +using MediatR; + namespace O2NextGen.CertificateManagement.Domain.UseCases.ForCategory.DeleteCategory { public class DeleteCategoryCommand : IRequest - { - + { + public DeleteCategoryCommand(long id) + { + Id = id; + } + public long Id { get; set; } } } diff --git a/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCategory/DeleteCategory/DeleteCategoryCommandHandler.cs b/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCategory/DeleteCategory/DeleteCategoryCommandHandler.cs new file mode 100644 index 00000000..af52f362 --- /dev/null +++ b/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCategory/DeleteCategory/DeleteCategoryCommandHandler.cs @@ -0,0 +1,34 @@ +using MediatR; +using O2NextGen.CertificateManagement.Domain.Data; +using O2NextGen.CertificateManagement.Domain.Data.Queries; + +namespace O2NextGen.CertificateManagement.Domain.UseCases.ForCategory.DeleteCategory; + +public class DeleteCategoryCommandHandler : IRequestHandler +{ + private readonly IQueryHandler _userGroupQueryHandler; + private readonly IRepository groupsRepository; + + public DeleteCategoryCommandHandler( + IQueryHandler userGroupQueryHandler, + IRepository groupsRepository) + { + _userGroupQueryHandler = + userGroupQueryHandler ?? throw new ArgumentNullException(nameof(userGroupQueryHandler)); + this.groupsRepository = groupsRepository; + } + + public async Task Handle(DeleteCategoryCommand request, CancellationToken cancellationToken) + { + var category = await _userGroupQueryHandler.HandleAsync( + new CategoryQuery(request.Id), + cancellationToken); + + if (category is object) + { + await groupsRepository.DeleteAsync(category, cancellationToken); + } + + return Unit.Value; + } +} \ No newline at end of file diff --git a/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCategory/GetCategories/GetCategoriesQueryHandler.cs b/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCategory/GetCategories/GetCategoriesQueryHandler.cs index 463f4c60..85d74d35 100644 --- a/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCategory/GetCategories/GetCategoriesQueryHandler.cs +++ b/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCategory/GetCategories/GetCategoriesQueryHandler.cs @@ -1,12 +1,8 @@ -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; -using MediatR; +using MediatR; using O2NextGen.CertificateManagement.Domain.Data; using O2NextGen.CertificateManagement.Domain.Data.Queries; using O2NextGen.CertificateManagement.Domain.Entities; using O2NextGen.CertificateManagement.Domain.Mappings; -using O2NextGen.CertificateManagement.Domain.UseCases.ForCategory.GetCategories; namespace O2NextGen.CertificateManagement.Domain.UseCases.ForCategory.GetCategories { @@ -29,8 +25,13 @@ public async Task Handle(GetCategoriesQuery request, cancellationToken); return new GetCategoriesQueryResult( - certificates.MapAsReadOnly(certificate => - new GetCategoriesQueryResult.CategoryViewModel())); + certificates.MapAsReadOnly(category => + new GetCategoriesQueryResult.CategoryViewModel( + category.Id, + category.CategoryName, + category.CategoryDescription, + category.CategorySeries, + category.QuantityCertificates))); } diff --git a/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCategory/GetCategories/GetCategoriesQueryResult.cs b/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCategory/GetCategories/GetCategoriesQueryResult.cs index 6900f0b6..16bc8a49 100644 --- a/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCategory/GetCategories/GetCategoriesQueryResult.cs +++ b/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCategory/GetCategories/GetCategoriesQueryResult.cs @@ -14,8 +14,20 @@ public GetCategoriesQueryResult(IReadOnlyCollection categorie public class CategoryViewModel { - public CategoryViewModel() + public long Id { get; set; } + public string CategoryName { get; } + public string CategoryDescription { get; } + public string CategorySeries { get; } + public int QuantityCertificates { get; } + + public CategoryViewModel(long id, string categoryName, string categoryDescription, + string categorySeries, int quantityCertificates) { + Id = id; + CategoryName = categoryName; + CategoryDescription = categoryDescription; + CategorySeries = categorySeries; + QuantityCertificates = quantityCertificates; } } } diff --git a/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCategory/GetCategory/GetCategoryQuery.cs b/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCategory/GetCategory/GetCategoryQuery.cs index f07bec38..dd922b80 100644 --- a/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCategory/GetCategory/GetCategoryQuery.cs +++ b/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCategory/GetCategory/GetCategoryQuery.cs @@ -11,5 +11,6 @@ public GetCategoryQuery(long id) } public long Id { get; } + public string CategoryName { get; set; } } } diff --git a/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCategory/GetCategory/GetCategoryQueryHandler.cs b/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCategory/GetCategory/GetCategoryQueryHandler.cs index f973b036..150808bf 100644 --- a/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCategory/GetCategory/GetCategoryQueryHandler.cs +++ b/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCategory/GetCategory/GetCategoryQueryHandler.cs @@ -21,22 +21,28 @@ public GetCategoryQueryHandler(IQueryHandler _queryHand public async Task Handle(GetCategoryQuery request, CancellationToken cancellationToken) { - var certificate = await _queryHandler.HandleAsync( - new CategoryQuery(request.Id), + var category = await _queryHandler.HandleAsync( + new CategoryQuery( + request.Id), cancellationToken); - if (certificate is null) + if (category is null) { return null; } return new GetCategoryQueryResult( - certificate.Id, - certificate.ModifiedDate, - certificate.AddedDate, - certificate.DeletedDate, - certificate.IsDeleted, - certificate.CustomerId); + id: category.Id, + modifiedDate: category.ModifiedDate, + addedDate: category.AddedDate, + deletedDate: category.DeletedDate, + isDeleted: category.IsDeleted, + customerId: category.CustomerId, + categoryName: category.CategoryName, + categoryDescription: category.CategoryDescription, + quantityCertificates: category.QuantityCertificates, + quantityPublishCode: category.QuantityPublishCode, + categorySeries: category.CategorySeries); } } } \ No newline at end of file diff --git a/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCategory/GetCategory/GetCategoryQueryResult.cs b/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCategory/GetCategory/GetCategoryQueryResult.cs index 67862f46..3d3535fd 100644 --- a/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCategory/GetCategory/GetCategoryQueryResult.cs +++ b/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCategory/GetCategory/GetCategoryQueryResult.cs @@ -1,10 +1,14 @@ namespace O2NextGen.CertificateManagement.Domain.UseCases.ForCategory.GetCategory { - public class GetCategoryQueryResult { - public GetCategoryQueryResult(long id, long modifiedDate, long addedDate, long? deletedDate, bool? isDeleted, - string customerId) + public GetCategoryQueryResult( + long id, long modifiedDate, long addedDate, long? deletedDate, bool? isDeleted, + string customerId, + string categoryName, + string categoryDescription, + int quantityCertificates, + int quantityPublishCode, string categorySeries) { Id = id; ModifiedDate = modifiedDate; @@ -12,13 +16,24 @@ public GetCategoryQueryResult(long id, long modifiedDate, long addedDate, long? DeletedDate = deletedDate; IsDeleted = isDeleted; CustomerId = customerId; + CategoryName = categoryName; + CategoryDescription = categoryDescription; + QuantityCertificates = quantityCertificates; + QuantityPublishCode = quantityPublishCode; + CategorySeries = categorySeries; } + public long Id { get; } public long ModifiedDate { get; } public long AddedDate { get; } public long? DeletedDate { get; } public bool? IsDeleted { get; } public string CustomerId { get; } + public string CategoryName { get; } + public string CategoryDescription { get; } + public int QuantityCertificates { get; } + public int QuantityPublishCode { get; } + public string CategorySeries { get; } } -} +} \ No newline at end of file diff --git a/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCategory/UpdateCategory/UpdateCategoryDetailsCommand.cs b/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCategory/UpdateCategory/UpdateCategoryDetailsCommand.cs new file mode 100644 index 00000000..f23e62f0 --- /dev/null +++ b/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCategory/UpdateCategory/UpdateCategoryDetailsCommand.cs @@ -0,0 +1,37 @@ +using MediatR; + +namespace O2NextGen.CertificateManagement.Domain.UseCases.ForCategory.UpdateCategory; + +public class UpdateCategoryDetailsCommand : IRequest +{ + public UpdateCategoryDetailsCommand( + long id, + string categoryName, + string categoryDescription, + string categorySeries, + string customerId, + int quantityCertificates, + int quantityPublishCode) + { + Id = id; + CategoryName = categoryName; + CategoryDescription = categoryDescription; + CategorySeries = categorySeries; + CustomerId = customerId; + QuantityCertificates = quantityCertificates; + QuantityPublishCode = quantityPublishCode; + } + + public string CategoryName { get; set; } + public string CategoryDescription { get; set; } + public string CategorySeries { get; set; } + public string CustomerId { get; set; } + public long? AddedDate { get; set; } + public long? ModifiedDate { get; set; } + public long? DeletedDate { get; set; } + public bool? IsDeleted { get; set; } + public int TimeLifeInDays { get; set; } + public int QuantityCertificates { get; set; } + public int QuantityPublishCode { get; set; } + public long Id { get; } +} \ No newline at end of file diff --git a/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCategory/UpdateCategory/UpdateCategoryDetailsCommandHandler.cs b/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCategory/UpdateCategory/UpdateCategoryDetailsCommandHandler.cs new file mode 100644 index 00000000..4e7f9ac3 --- /dev/null +++ b/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCategory/UpdateCategory/UpdateCategoryDetailsCommandHandler.cs @@ -0,0 +1,63 @@ +using MediatR; +using O2NextGen.CertificateManagement.Domain.Data; +using O2NextGen.CertificateManagement.Domain.Data.Queries; + +namespace O2NextGen.CertificateManagement.Domain.UseCases.ForCategory.UpdateCategory; + +public class UpdateCategoryDetailsCommandHandler + : IRequestHandler +{ + private readonly IQueryHandler _userGroupQueryHandler; + private readonly IRepository _groupsRepository; + + public UpdateCategoryDetailsCommandHandler( + IQueryHandler userGroupQueryHandler, + IRepository groupsRepository) + { + _userGroupQueryHandler = + userGroupQueryHandler ?? throw new ArgumentNullException(nameof(userGroupQueryHandler)); + _groupsRepository = groupsRepository ?? throw new ArgumentNullException(nameof(groupsRepository)); + } + + public async Task Handle(UpdateCategoryDetailsCommand request, + CancellationToken cancellationToken) + { + var category = await _userGroupQueryHandler.HandleAsync( + new CategoryQuery( + request.Id + ), + cancellationToken); + + if (category is null) + { + return null; + } + + + category.IsDeleted = request.IsDeleted; + category.CustomerId = request.CustomerId; + category.CategoryName = request.CategoryName; + + category.CategoryName = request.CategoryName; + + + category.CategoryDescription = request.CategoryDescription; + category.QuantityCertificates = request.QuantityCertificates; + category.CategorySeries = request.CategorySeries; + + await _groupsRepository.UpdateAsync(category, cancellationToken); + + return new UpdateCategoryDetailsCommandResult( + category.Id, + category.ModifiedDate, + category.AddedDate, + category.DeletedDate, + category.IsDeleted, + category.CustomerId, + category.CategoryName, + category.CategoryDescription, + category.QuantityCertificates, + category.QuantityPublishCode + ); + } +} \ No newline at end of file diff --git a/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCategory/UpdateCategory/UpdateCategoryDetailsCommandResult.cs b/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCategory/UpdateCategory/UpdateCategoryDetailsCommandResult.cs new file mode 100644 index 00000000..4d845c65 --- /dev/null +++ b/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCategory/UpdateCategory/UpdateCategoryDetailsCommandResult.cs @@ -0,0 +1,35 @@ +namespace O2NextGen.CertificateManagement.Domain.UseCases.ForCategory.UpdateCategory; + +public class UpdateCategoryDetailsCommandResult +{ + public long Id { get; } + public long ModifiedDate { get; } + public long AddedDate { get; } + public long? DeletedDate { get; } + public bool? IsDeleted { get; } + public string CustomerId { get; } + public string CategoryName { get; } + public string CategoryDescription { get; } + public int QuantityCertificates { get; } + public int QuantityPublishCode { get; } + + public UpdateCategoryDetailsCommandResult(long id, + long modifiedDate, + long addedDate, + long? deletedDate, + bool? isDeleted, string customerId, string categoryName, + string categoryDescription, + int quantityCertificates, int quantityPublishCode) + { + Id = id; + ModifiedDate = modifiedDate; + AddedDate = addedDate; + DeletedDate = deletedDate; + IsDeleted = isDeleted; + CustomerId = customerId; + CategoryName = categoryName; + CategoryDescription = categoryDescription; + QuantityCertificates = quantityCertificates; + QuantityPublishCode = quantityPublishCode; + } +} \ No newline at end of file diff --git a/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCertificate/NewCertificate/NewCertificateCommand.cs b/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCertificate/NewCertificate/NewCertificateCommand.cs new file mode 100644 index 00000000..b7c829d2 --- /dev/null +++ b/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCertificate/NewCertificate/NewCertificateCommand.cs @@ -0,0 +1,21 @@ +using MediatR; + +namespace O2NextGen.CertificateManagement.Domain.UseCases.ForCertificate.NewCertificate +{ + public class NewCertificateCommand : IRequest + { + public NewCertificateCommand(string userId, long categoryId, int languageId, string customerId) + { + UserId = userId; + CategoryId = categoryId; + LanguageId = languageId; + CustomerId = customerId; + } + + public string UserId { get; } + public long CategoryId { get; } + public int LanguageId { get; } + public string CustomerId { get; } + } +} + diff --git a/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCertificate/NewCertificate/NewCertificateCommandHandler.cs b/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCertificate/NewCertificate/NewCertificateCommandHandler.cs new file mode 100644 index 00000000..657e8e50 --- /dev/null +++ b/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCertificate/NewCertificate/NewCertificateCommandHandler.cs @@ -0,0 +1,102 @@ +using MediatR; +using O2NextGen.CertificateManagement.Domain.Data; +using O2NextGen.CertificateManagement.Domain.Data.Queries; +using O2NextGen.CertificateManagement.Domain.Entities; +using O2NextGen.Sdk.NetCore.Extensions; + +namespace O2NextGen.CertificateManagement.Domain.UseCases.ForCertificate.NewCertificate +{ + public class NewCertificateCommandHandler : + IRequestHandler + { + private readonly IQueryHandler _queryCategoryHandler; + + public NewCertificateCommandHandler(IQueryHandler queryCategoryHandler) + { + this._queryCategoryHandler = queryCategoryHandler; + } + + public async Task Handle(NewCertificateCommand request, CancellationToken cancellationToken) + { + var category = await _queryCategoryHandler.HandleAsync(new CategoryQuery(request.CategoryId), cancellationToken); + + if (category == null) + throw new ArgumentException($"CategoryModel {nameof(category)} not found"); + + LanguageInfo language; + + switch (request.LanguageId) + { + case 1: + { + language = new LanguageInfo + { + LanguageId = request.LanguageId, + Firstname = string.Empty, + Lastname = string.Empty, + Middlename = string.Empty + }; + break; + } + case 2: + { + language = new LanguageInfo + { + LanguageId = request.LanguageId, + Firstname = string.Empty, + Lastname = string.Empty, + Middlename = string.Empty + }; + break; + } + case 3: + { + language = new LanguageInfo + { + LanguageId = request.LanguageId, + Firstname = string.Empty, + Lastname = string.Empty, + Middlename = string.Empty + }; + break; + } + case 4: + { + language = new LanguageInfo + { + LanguageId = request.LanguageId, + Firstname = string.Empty, + Lastname = string.Empty, + Middlename = string.Empty + }; + break; + } + + default: + { + throw new ArgumentException("languageId is not found"); + } + } + + var languageInfos = new List { language }; + + return new NewCertificateCommandResult( + AddedDate: DateTime.Now.ConvertToUnixTime(), + ModifiedDate: DateTime.Now.ConvertToUnixTime(), + PublishCode: "", + LockInfo: string.Empty, + LockedDate: 0, + ExpiredDate: DateTime.Now.AddDays(category.TimeLifeInDays).ConvertToUnixTime(), + PublishDate: DateTime.Now.ConvertToUnixTime(), + CreatorId: request.UserId, + CustomerId: request.CustomerId, + OwnerAccountId: Guid.Empty.ToString(), + DeletedDate: default(long), + CategoryId: request.CategoryId, + Category: category, + LanguageInfos: languageInfos + ); + } + } +} + diff --git a/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCertificate/NewCertificate/NewCertificateCommandResult.cs b/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCertificate/NewCertificate/NewCertificateCommandResult.cs new file mode 100644 index 00000000..7ec07ce2 --- /dev/null +++ b/src/Services/c-gen/O2NextGen.CertificateManagement.Domain/UseCases/ForCertificate/NewCertificate/NewCertificateCommandResult.cs @@ -0,0 +1,40 @@ +using O2NextGen.CertificateManagement.Domain.Entities; + +namespace O2NextGen.CertificateManagement.Domain.UseCases.ForCertificate.NewCertificate +{ + public class NewCertificateCommandResult + { + public NewCertificateCommandResult(long AddedDate, long ModifiedDate, string PublishCode, string LockInfo, int LockedDate, long ExpiredDate, long PublishDate, string CreatorId, string CustomerId, string OwnerAccountId, long DeletedDate, long CategoryId, Category Category, List LanguageInfos) + { + this.AddedDate = AddedDate; + this.ModifiedDate = ModifiedDate; + this.PublishCode = PublishCode; + this.LockInfo = LockInfo; + this.LockedDate = LockedDate; + this.ExpiredDate = ExpiredDate; + this.PublishDate = PublishDate; + this.CreatorId = CreatorId; + this.CustomerId = CustomerId; + this.OwnerAccountId = OwnerAccountId; + this.DeletedDate = DeletedDate; + this.CategoryId = CategoryId; + this.Category = Category; + this.LanguageInfos = LanguageInfos; + } + + public long AddedDate { get; } + public long ModifiedDate { get; } + public string PublishCode { get; } + public string LockInfo { get; } + public int LockedDate { get; } + public long ExpiredDate { get; } + public long PublishDate { get; } + public string CreatorId { get; } + public string CustomerId { get; } + public string OwnerAccountId { get; } + public long DeletedDate { get; } + public long CategoryId { get; } + public Category Category { get; } + public List LanguageInfos { get; } + } +} \ No newline at end of file diff --git a/src/Services/c-gen/Tests/Skeleton/IntegrationTests.O2NextGen.CertificateManagement.Api/CategoryScenarioBase.cs b/src/Services/c-gen/Tests/Skeleton/IntegrationTests.O2NextGen.CertificateManagement.Api/CategoryScenarioBase.cs new file mode 100644 index 00000000..568f435d --- /dev/null +++ b/src/Services/c-gen/Tests/Skeleton/IntegrationTests.O2NextGen.CertificateManagement.Api/CategoryScenarioBase.cs @@ -0,0 +1,27 @@ +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.TestHost; +using System.IO; +using System.Reflection; + +namespace IntegrationTests.O2NextGen.CertificateManagement.Api; + +public class CategoryScenarioBase +{ + public TestServer CreateServer() + { + var path = Assembly.GetAssembly(typeof(CertificateScenarioBase)) + .Location; + + var hostBuilder = new WebHostBuilder() + .UseContentRoot(Path.GetDirectoryName(path)) + .ConfigureAppConfiguration(cb => + { + // cb.AddJsonFile("appsettings.json", false) + // .AddEnvironmentVariables(); + }).UseStartup(); + + var testServer = new TestServer(hostBuilder); + + return testServer; + } +} \ No newline at end of file diff --git a/src/Services/c-gen/Tests/Skeleton/IntegrationTests.O2NextGen.CertificateManagement.Api/CategoryServiceTests.cs b/src/Services/c-gen/Tests/Skeleton/IntegrationTests.O2NextGen.CertificateManagement.Api/CategoryServiceTests.cs new file mode 100644 index 00000000..c53e99a7 --- /dev/null +++ b/src/Services/c-gen/Tests/Skeleton/IntegrationTests.O2NextGen.CertificateManagement.Api/CategoryServiceTests.cs @@ -0,0 +1,6 @@ +namespace IntegrationTests.O2NextGen.CertificateManagement.Api; + +public class CategoryServiceTests : CategoryScenarioBase +{ + +} \ No newline at end of file diff --git a/src/Services/c-gen/Tests/Skeleton/IntegrationTests.O2NextGen.CertificateManagement.Api/CertificateManagementTestsStartup.cs b/src/Services/c-gen/Tests/Skeleton/IntegrationTests.O2NextGen.CertificateManagement.Api/CertificateManagementTestsStartup.cs new file mode 100644 index 00000000..6d7287b5 --- /dev/null +++ b/src/Services/c-gen/Tests/Skeleton/IntegrationTests.O2NextGen.CertificateManagement.Api/CertificateManagementTestsStartup.cs @@ -0,0 +1,18 @@ +namespace IntegrationTests.O2NextGen.CertificateManagement.Api; + +public class TestsStartup //: Startup +{ + // public TestsStartup(IConfiguration config, IWebHostEnvironment env) + // : base(config,env) + // { + // } + + // protected override void ConfigureAuth(IApplicationBuilder app) + // { + // //if (Configuration["isTest"] == bool.TrueString.ToLowerInvariant()) + // // app.UseMiddleware(); + // //else + // app.UseMiddleware(); + // base.ConfigureAuth(app); + // } +} \ No newline at end of file diff --git a/src/Services/c-gen/Tests/Skeleton/IntegrationTests.O2NextGen.CertificateManagement.Api/CertificateScenarioBase.cs b/src/Services/c-gen/Tests/Skeleton/IntegrationTests.O2NextGen.CertificateManagement.Api/CertificateScenarioBase.cs new file mode 100644 index 00000000..11b14e41 --- /dev/null +++ b/src/Services/c-gen/Tests/Skeleton/IntegrationTests.O2NextGen.CertificateManagement.Api/CertificateScenarioBase.cs @@ -0,0 +1,61 @@ +using System.IO; +using System.Reflection; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.TestHost; + +namespace IntegrationTests.O2NextGen.CertificateManagement.Api; + +public class CertificateScenarioBase +{ + public TestServer CreateServer() + { + var path = Assembly.GetAssembly(typeof(CertificateScenarioBase)) + .Location; + + var hostBuilder = new WebHostBuilder() + .UseContentRoot(Path.GetDirectoryName(path)) + .ConfigureAppConfiguration(cb => + { + // cb.AddJsonFile("appsettings.json", false) + // .AddEnvironmentVariables(); + }).UseStartup(); + + var testServer = new TestServer(hostBuilder); + + //testServer.Host + //.MigrateDbContext((context, services) => + //{ + // var env = services.GetService(); + // var settings = services.GetService>(); + // var logger = services.GetService>(); + + // //new CertificateDataContext() + // // .SeedAsync(context, env, settings, logger) + // // .Wait(); + //}) + //.MigrateDbContext((_, __) => { }); + + return testServer; + } + + public static class Get + { + public static string Certificates = "certificates"; + + public static string CertificateBy(int id) + { + return $"certificates/{id}"; + } + } + + public static class Put + { + // public static string CancelOrder = "api/v1/orders/cancel"; + // public static string ShipOrder = "api/v1/orders/ship"; + } + + public static class Post + { + + } +} \ No newline at end of file diff --git a/src/Services/c-gen/Tests/Skeleton/IntegrationTests.O2NextGen.CertificateManagement.Api/CertificateServiceTests.cs b/src/Services/c-gen/Tests/Skeleton/IntegrationTests.O2NextGen.CertificateManagement.Api/CertificateServiceTests.cs new file mode 100644 index 00000000..a54fa2e8 --- /dev/null +++ b/src/Services/c-gen/Tests/Skeleton/IntegrationTests.O2NextGen.CertificateManagement.Api/CertificateServiceTests.cs @@ -0,0 +1,58 @@ +using System.Net; +using System.Threading.Tasks; +using Xunit; + +namespace IntegrationTests.O2NextGen.CertificateManagement.Api; + +public class CertificateServiceTests : CertificateScenarioBase +{ + + // [Fact] + // public async Task Get_get_all_stored_orders_and_response_ok_status_code() + // { + // using (var server = CreateServer()) + // { + // var response = await server.CreateClient() + // .GetAsync(Get.Certificates); + // + // response.EnsureSuccessStatusCode(); + // } + // } + // + // [Fact] + // public async Task Get_get_catalogitem_by_id_and_response_ok_status_code() + // { + // using (var server = CreateServer()) + // { + // var response = await server.CreateClient() + // .GetAsync(Get.CertificateBy(1)); + // + // response.EnsureSuccessStatusCode(); + // } + // } + // + // [Fact] + // public async Task Get_get_catalogitem_by_id_and_response_bad_request_status_code() + // { + // using (var server = CreateServer()) + // { + // var response = await server.CreateClient() + // .GetAsync(Get.CertificateBy(1)); + // + // Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); + // } + // } + + [Fact] + public async Task Get_certificate_item_by_id_and_response_not_found_status_code() + { + + using (var server = CreateServer()) + { + var response = await server.CreateClient() + .GetAsync(Get.CertificateBy(int.MaxValue)); + + Assert.Equal(HttpStatusCode.NotFound, response.StatusCode); + } + } +} \ No newline at end of file diff --git a/src/Services/c-gen/Tests/Skeleton/IntegrationTests.O2NextGen.CertificateManagement.Api/IntegrationTests.O2NextGen.CertificateManagement.Api.csproj b/src/Services/c-gen/Tests/Skeleton/IntegrationTests.O2NextGen.CertificateManagement.Api/IntegrationTests.O2NextGen.CertificateManagement.Api.csproj new file mode 100644 index 00000000..e377fa4e --- /dev/null +++ b/src/Services/c-gen/Tests/Skeleton/IntegrationTests.O2NextGen.CertificateManagement.Api/IntegrationTests.O2NextGen.CertificateManagement.Api.csproj @@ -0,0 +1,38 @@ + + + + net6.0 + + false + + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + + + + + + + + + + true + PreserveNewest + PreserveNewest + + + diff --git a/src/Services/c-gen/Tests/Skeleton/IntegrationTests.O2NextGen.CertificateManagement.Api/IntegrationTests.O2NextGen.CertificateManagement.Api.sln b/src/Services/c-gen/Tests/Skeleton/IntegrationTests.O2NextGen.CertificateManagement.Api/IntegrationTests.O2NextGen.CertificateManagement.Api.sln new file mode 100644 index 00000000..c7ca75ad --- /dev/null +++ b/src/Services/c-gen/Tests/Skeleton/IntegrationTests.O2NextGen.CertificateManagement.Api/IntegrationTests.O2NextGen.CertificateManagement.Api.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 25.0.1704.2 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IntegrationTests.O2NextGen.CertificateManagement.Api", "IntegrationTests.O2NextGen.CertificateManagement.Api.csproj", "{2048912F-DF3D-464A-8239-DA6C99662DB5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2048912F-DF3D-464A-8239-DA6C99662DB5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2048912F-DF3D-464A-8239-DA6C99662DB5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2048912F-DF3D-464A-8239-DA6C99662DB5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2048912F-DF3D-464A-8239-DA6C99662DB5}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {BB4B76CA-581F-44C3-A268-B1EB8FEA16D8} + EndGlobalSection +EndGlobal diff --git a/src/Services/c-gen/Tests/Skeleton/IntegrationTests.O2NextGen.CertificateManagement.Api/IntegrationTests.O2NextGen.CertificateManagement.Api.v3.ncrunchproject b/src/Services/c-gen/Tests/Skeleton/IntegrationTests.O2NextGen.CertificateManagement.Api/IntegrationTests.O2NextGen.CertificateManagement.Api.v3.ncrunchproject new file mode 100644 index 00000000..5d07ca51 --- /dev/null +++ b/src/Services/c-gen/Tests/Skeleton/IntegrationTests.O2NextGen.CertificateManagement.Api/IntegrationTests.O2NextGen.CertificateManagement.Api.v3.ncrunchproject @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/src/Services/c-gen/Tests/Skeleton/IntegrationTests.O2NextGen.CertificateManagement.Api/appsettings.json b/src/Services/c-gen/Tests/Skeleton/IntegrationTests.O2NextGen.CertificateManagement.Api/appsettings.json new file mode 100644 index 00000000..ef9f68fa --- /dev/null +++ b/src/Services/c-gen/Tests/Skeleton/IntegrationTests.O2NextGen.CertificateManagement.Api/appsettings.json @@ -0,0 +1,15 @@ +{ + "ConnectionString": "Server=localhost;Initial Catalog=IntegrationTests.O2NextGen.CertificateDb;Persist Security Info=False;User ID=sa;Password=your@Password;Connection Timeout=30;", + "Urls": { + "Auth": "http://localhost:10001" + }, + "AllowedHosts": "*", + "Logging": { + "IncludeScopes": false, + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + } +} \ No newline at end of file diff --git a/src/Services/c-gen/Tests/Skeleton/Tests.O2NextGen.CertificateManagement.Api/Tests.O2NextGen.CertificateManagement.Api.csproj b/src/Services/c-gen/Tests/Skeleton/Tests.O2NextGen.CertificateManagement.Api/Tests.O2NextGen.CertificateManagement.Api.csproj new file mode 100644 index 00000000..a91b6ea1 --- /dev/null +++ b/src/Services/c-gen/Tests/Skeleton/Tests.O2NextGen.CertificateManagement.Api/Tests.O2NextGen.CertificateManagement.Api.csproj @@ -0,0 +1,22 @@ + + + + net6.0 + + false + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + diff --git a/src/Services/c-gen/Tests/Skeleton/Tests.O2NextGen.CertificateManagement.Api/Tests.O2NextGen.CertificateManagement.Api.v3.ncrunchproject b/src/Services/c-gen/Tests/Skeleton/Tests.O2NextGen.CertificateManagement.Api/Tests.O2NextGen.CertificateManagement.Api.v3.ncrunchproject new file mode 100644 index 00000000..5d07ca51 --- /dev/null +++ b/src/Services/c-gen/Tests/Skeleton/Tests.O2NextGen.CertificateManagement.Api/Tests.O2NextGen.CertificateManagement.Api.v3.ncrunchproject @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/src/Services/c-gen/Tests/Skeleton/Tests.O2NextGen.CertificateManagement.Impl/Tests.O2NextGen.CertificateManagement.Impl.csproj b/src/Services/c-gen/Tests/Skeleton/Tests.O2NextGen.CertificateManagement.Impl/Tests.O2NextGen.CertificateManagement.Impl.csproj new file mode 100644 index 00000000..e899dc0c --- /dev/null +++ b/src/Services/c-gen/Tests/Skeleton/Tests.O2NextGen.CertificateManagement.Impl/Tests.O2NextGen.CertificateManagement.Impl.csproj @@ -0,0 +1,22 @@ + + + + net6.0 + + false + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + diff --git a/src/Services/c-gen/Tests/Skeleton/Tests.O2NextGen.CertificateManagement.Impl/Tests.O2NextGen.CertificateManagement.Impl.v3.ncrunchproject b/src/Services/c-gen/Tests/Skeleton/Tests.O2NextGen.CertificateManagement.Impl/Tests.O2NextGen.CertificateManagement.Impl.v3.ncrunchproject new file mode 100644 index 00000000..5d07ca51 --- /dev/null +++ b/src/Services/c-gen/Tests/Skeleton/Tests.O2NextGen.CertificateManagement.Impl/Tests.O2NextGen.CertificateManagement.Impl.v3.ncrunchproject @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/src/Services/c-gen/Tests/Tests.O2NextGen.CertificateManagement.Application/Base/BaseConfigTests.cs b/src/Services/c-gen/Tests/Tests.O2NextGen.CertificateManagement.Application/Base/BaseConfigTests.cs new file mode 100644 index 00000000..d9df0d40 --- /dev/null +++ b/src/Services/c-gen/Tests/Tests.O2NextGen.CertificateManagement.Application/Base/BaseConfigTests.cs @@ -0,0 +1,6 @@ +namespace Tests.O2NextGen.CertificateManagement.Application.Base; + +public class BaseConfigTests : BaseTests + where TClass : class +{ +} \ No newline at end of file diff --git a/src/Services/c-gen/Tests/Tests.O2NextGen.CertificateManagement.Application/Base/BaseControllerTests.cs b/src/Services/c-gen/Tests/Tests.O2NextGen.CertificateManagement.Application/Base/BaseControllerTests.cs new file mode 100644 index 00000000..168fef05 --- /dev/null +++ b/src/Services/c-gen/Tests/Tests.O2NextGen.CertificateManagement.Application/Base/BaseControllerTests.cs @@ -0,0 +1,66 @@ +using System; +using System.Linq; +using System.Reflection; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Xunit; + +namespace Tests.O2NextGen.CertificateManagement.Application.Base; + +public class BaseControllerTests : BaseTests + where TClass : class +{ + + [Fact] + public void ControllerBaseTests_AttributeApiController() + { + Assert.NotNull(Attribute.GetCustomAttribute(typeof(TClass), typeof(ApiControllerAttribute))); + } + + [Fact] + public void ControllerBaseTests_AttributeRoute() + { + Assert.NotNull(Attribute.GetCustomAttribute(typeof(TClass), typeof(RouteAttribute))); + } + + [Fact] + public virtual void ControllerBaseTests_AttributeAuthorize() + { + Assert.NotNull(Attribute.GetCustomAttribute(typeof(TClass), typeof(AuthorizeAttribute))); + } + + [Fact] + public virtual void ControllerBaseTests_AttributeApiVersion() + { + Assert.NotNull(Attribute.GetCustomAttributes(typeof(TClass), typeof(ApiVersionAttribute))); + } + + [Fact] + public void ControllerBaseTests_BaseClass() + { + Assert.True(typeof(ControllerBase).IsAssignableFrom(typeof(TClass))); + } + + [Fact] + public void ControllerBaseTests_NameContainController() + { + Assert.Contains("Controller", typeof(TClass).Name); + } + + [Fact] + public void Methods_MarkerAttributePostOrGetOrDelete() + { + var result = typeof(TClass) + .GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly) + .Count(p => + CustomAttributeExtensions.GetCustomAttribute((MemberInfo) p, typeof(HttpGetAttribute), false) == null + && + CustomAttributeExtensions.GetCustomAttribute((MemberInfo) p, typeof(HttpPostAttribute), false) == null + && + CustomAttributeExtensions.GetCustomAttribute((MemberInfo) p, typeof(HttpDeleteAttribute), false) == null + && + CustomAttributeExtensions.GetCustomAttribute((MemberInfo) p, typeof(HttpPutAttribute), false) == null + ); + Assert.True(result == 0); + } +} \ No newline at end of file diff --git a/src/Services/c-gen/Tests/Tests.O2NextGen.CertificateManagement.Application/Base/BaseHelper.cs b/src/Services/c-gen/Tests/Tests.O2NextGen.CertificateManagement.Application/Base/BaseHelper.cs new file mode 100644 index 00000000..afdeff6c --- /dev/null +++ b/src/Services/c-gen/Tests/Tests.O2NextGen.CertificateManagement.Application/Base/BaseHelper.cs @@ -0,0 +1,20 @@ +using System; +using System.Linq; + +namespace Tests.O2NextGen.CertificateManagement.Application.Base; + +public static class BaseHelper +{ + public static bool It_CheckExistProperty(string nameProperty) + { + return typeof(TClass) + .GetProperties() + .SingleOrDefault(p => p.Name == nameProperty) != null; + } + + public static bool It_CheckExistPropertyOfType(string nameProperty, Type type) + { + return type == + typeof(TClass).GetProperties().SingleOrDefault(p => p.Name == nameProperty)?.PropertyType; + } +} \ No newline at end of file diff --git a/src/Services/c-gen/Tests/Tests.O2NextGen.CertificateManagement.Application/Base/BaseTests.cs b/src/Services/c-gen/Tests/Tests.O2NextGen.CertificateManagement.Application/Base/BaseTests.cs new file mode 100644 index 00000000..65140d2f --- /dev/null +++ b/src/Services/c-gen/Tests/Tests.O2NextGen.CertificateManagement.Application/Base/BaseTests.cs @@ -0,0 +1,12 @@ +using Xunit; + +namespace Tests.O2NextGen.CertificateManagement.Application.Base; + +public class BaseTests + where TClass : class +{ + public virtual void It_CheckClassName(string name = "") + { + Assert.Equal(name, typeof(TClass).Name); + } +} \ No newline at end of file diff --git a/src/Services/c-gen/Tests/Tests.O2NextGen.CertificateManagement.Application/CreateCategoryModelTests.cs b/src/Services/c-gen/Tests/Tests.O2NextGen.CertificateManagement.Application/CreateCategoryModelTests.cs new file mode 100644 index 00000000..3ed8cb4c --- /dev/null +++ b/src/Services/c-gen/Tests/Tests.O2NextGen.CertificateManagement.Application/CreateCategoryModelTests.cs @@ -0,0 +1,69 @@ +using FluentAssertions; +using Moq; +using O2NextGen.CertificateManagement.Application.Features.Categories; +using Xunit; + +namespace Tests.O2NextGen.CertificateManagement.Application; + +public class CreateCategoryModelTests +{ + #region Tests of CategoryName Property + + [Fact] + public void CreateCategoryModel_CheckPropertySetCategoryName_Test() + { + // Arrange + var mock = new Mock(); + // Act + mock.SetupProperty(m => m.CategoryName, "CategoryName"); + // Assert + mock.Object.CategoryName.Should().Be("CategoryName"); + } + + #endregion + + #region Tests of CategoryDescription Property + + [Fact] + public void CreateCategoryModel_CheckPropertySetCategoryDescription_Test() + { + // Arrange + var mock = new Mock(); + // Act + mock.SetupProperty(m => m.CategoryDescription, "CategoryDescription"); + // Assert + mock.Object.CategoryDescription.Should().Be("CategoryDescription"); + } + + #endregion + + #region Tests of CategorySeries Property + + [Fact] + public void CreateCategoryModel_CheckPropertySetCategorySeries_Test() + { + // Arrange + var mock = new Mock(); + // Act + mock.SetupProperty(m => m.CategorySeries, "CategorySeries"); + // Assert + mock.Object.CategorySeries.Should().Be("CategorySeries"); + } + + #endregion + + #region Tests of CustomerId Property + + [Fact] + public void CreateCategoryModel_CheckPropertySetCustomerId_Test() + { + // Arrange + var mock = new Mock(); + // Act + mock.SetupProperty(m => m.CustomerId, "CustomerId"); + // Assert + mock.Object.CustomerId.Should().Be("CustomerId"); + } + + #endregion +} \ No newline at end of file diff --git a/src/Services/c-gen/Tests/Tests.O2NextGen.CertificateManagement.Application/Features/Categories/CategoryControllerTests.cs b/src/Services/c-gen/Tests/Tests.O2NextGen.CertificateManagement.Application/Features/Categories/CategoryControllerTests.cs new file mode 100644 index 00000000..f6ace8cc --- /dev/null +++ b/src/Services/c-gen/Tests/Tests.O2NextGen.CertificateManagement.Application/Features/Categories/CategoryControllerTests.cs @@ -0,0 +1,188 @@ +using System; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using MediatR; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using Moq; +using O2NextGen.CertificateManagement.Application.Features.Categories; +using O2NextGen.CertificateManagement.Domain.UseCases.ForCategory.GetCategory; +using Tests.O2NextGen.CertificateManagement.Application.Base; +using Xunit; + +namespace Tests.O2NextGen.CertificateManagement.Application.Features.Categories; + +public class CategoryControllerTests + : BaseControllerTests +{ + #region Tests for Attributes + + [Theory] + [InlineData("CategoriesController")] + public override void It_CheckClassName(string name = "") + { + base.It_CheckClassName(name); + } + + [Fact] + public void CategoryControllerTests_AttributeApiVersion_Supported_v1_0() + { + Assert.Contains(Attribute.GetCustomAttributes(typeof(CategoriesController), typeof(ApiVersionAttribute)), att => + ((ApiVersionAttribute) att).Versions.Any(x => x is {MajorVersion: 1, MinorVersion: 0})); + } + + [Fact] + public void CategoryControllerTests_AttributeApiVersion_Supported_v1_1() + { + Assert.Contains(Attribute.GetCustomAttributes(typeof(CategoriesController), typeof(ApiVersionAttribute)), att => + ((ApiVersionAttribute) att).Versions.Any(x => x is {MajorVersion: 1, MinorVersion: 1})); + } + + #endregion + + #region Tests for Logging Methods + + [Fact] + public async Task CategoryControllerTests_GetById_LoggerInfo_Tests() + { + //Arrange + var mediator = new Mock(); + + CancellationTokenSource cts = new(); + + var cancellationToken = cts.Token; + + var categoryQueryResult = new Mock(); + + mediator.Setup(_ => _.Send(It.IsAny(), cancellationToken)) + .Returns(() => Task.FromResult( + It.IsAny() + )); + + var logger = new Mock>(); + + // Act + var controller = new CategoriesController(mediator.Object, logger.Object); + const long id = 1; + var result = await controller.GetByIdAsync(id, cancellationToken); + + // Asser + logger.VerifyLog(_ => _.LogInformation(It.IsAny())); + logger.VerifyLog(_ => _.LogInformation(It.IsNotNull())); + logger.VerifyLog(_ => _.LogInformation(It.Is(msg => msg.Length > 0))); + logger.VerifyLog(_ => _.LogInformation("Call API method {ByIdAsyncName}: id = {Id}", "GetByIdAsync", id)); + } + + [Fact] + public async Task CategoryControllerTests_GetById_Ok_LoggerInfo_Tests() + { + //Arrange + var mediator = new Mock(); + + CancellationTokenSource cts = new(); + + var cancellationToken = cts.Token; + + var categoryQueryResult = new Mock(); + + mediator.Setup(_ => _.Send(It.IsAny(), cancellationToken)) + .Returns(() => Task.FromResult( + It.IsAny() + )); + + var logger = new Mock>(); + + // Act + var controller = new CategoriesController(mediator.Object, logger.Object); + const long id = 1; + var result = await controller.GetByIdAsync(id, cancellationToken); + + // Asser + logger.VerifyLog(_ => _.LogInformation(It.IsAny())); + logger.VerifyLog(_ => _.LogInformation(It.IsNotNull())); + logger.VerifyLog(_ => _.LogInformation(It.Is(msg => msg.Length > 0))); + logger.VerifyLog(_ => _.LogInformation("GetByIdAsync: OK")); + } + + [Fact] + public async Task CategoryControllerTests_GetById_LoggerError_Tests() + { + //Arrange + var mediator = new Mock(); + CancellationTokenSource cts = new(); + CancellationToken cancellationToken = cts.Token; + + var categoryQueryResult = new Mock(); + mediator.Setup(_ => _.Send(It.IsAny(), cancellationToken)) + .Returns(() => Task.FromResult( + null as GetCategoryQueryResult + )); + // .Returns(Task.Run(async () => { await Task.Delay(1000, cancellationToken) }, cancellationToken)) + // .Callback((roles, databaseName) => + // { + // cts.Cancel(); + // }); + var logger = new Mock>(); + + // Act + var controller = new CategoriesController(mediator.Object, logger.Object); + const long id = 1; + var result = await controller.GetByIdAsync(id, cancellationToken); + + // Asser + logger.VerifyLog(_ => _.LogError(It.IsAny())); + logger.VerifyLog(_ => _.LogError(It.IsNotNull())); + logger.VerifyLog(_ => _.LogError(It.Is(msg => msg.Length > 0))); + logger.VerifyLog(_ => _.LogError("GetByIdAsync: not found id = {Id}", id)); + } + + #endregion + + #region Tests for Func Methods + + [Fact] + public async Task CategoryControllerTests_GetById_Test() + { + //Arrange + var mediator = new Mock(); + + CancellationTokenSource cts = new(); + + var cancellationToken = cts.Token; + + var expectedResult = new GetCategoryQueryResult( + id: 1, + modifiedDate: 1, + addedDate: 1, + deletedDate: 1, + isDeleted: false, + customerId: "1", + categoryName: "categoryName", + categoryDescription: "categoryDescription", + quantityCertificates: 1, + quantityPublishCode: 1, + categorySeries: "categorySeries" + ); + + mediator.Setup(_ => _.Send(It.IsAny(), cancellationToken)) + .Returns(() => Task.FromResult( + expectedResult + )); + + var logger = new Mock>(); + + // Act + var controller = new CategoriesController(mediator.Object, logger.Object); + const long id = 1; + var actionResult = await controller.GetByIdAsync(id, cancellationToken); + var okObjectResult = actionResult as OkObjectResult; + + // Assert + Assert.NotNull(okObjectResult); + Assert.Equal(expectedResult,okObjectResult?.Value); + } + + + #endregion +} \ No newline at end of file diff --git a/src/Services/c-gen/Tests/Tests.O2NextGen.CertificateManagement.Application/Features/Certificates/CertificatesControllerTests.cs b/src/Services/c-gen/Tests/Tests.O2NextGen.CertificateManagement.Application/Features/Certificates/CertificatesControllerTests.cs new file mode 100644 index 00000000..878c2eac --- /dev/null +++ b/src/Services/c-gen/Tests/Tests.O2NextGen.CertificateManagement.Application/Features/Certificates/CertificatesControllerTests.cs @@ -0,0 +1,32 @@ +using System; +using System.Linq; +using Microsoft.AspNetCore.Mvc; +using O2NextGen.CertificateManagement.Application.Features.Certificates; +using Tests.O2NextGen.CertificateManagement.Application.Base; +using Xunit; + +namespace Tests.O2NextGen.CertificateManagement.Application.Features.Certificates; + +public class CertificatesControllerTests: BaseControllerTests +{ + [Theory] + [InlineData("CertificatesController")] + public override void It_CheckClassName(string name = "") + { + base.It_CheckClassName(name); + } + + [Fact] + public void ControllerBaseTests_AttributeApiVersion_Supported_v1_0() + { + Assert.Contains(Attribute.GetCustomAttributes(typeof(CertificatesController), typeof(ApiVersionAttribute)), att => + ((ApiVersionAttribute) att).Versions.Any(x => x is {MajorVersion: 1, MinorVersion: 0})); + } + + [Fact] + public void ControllerBaseTests_AttributeApiVersion_Supported_v1_1() + { + Assert.Contains(Attribute.GetCustomAttributes(typeof(CertificatesController), typeof(ApiVersionAttribute)), att => + ((ApiVersionAttribute) att).Versions.Any(x => x is {MajorVersion: 1, MinorVersion: 1})); + } +} \ No newline at end of file diff --git a/src/Services/c-gen/Tests/Tests.O2NextGen.CertificateManagement.Application/ServiceUrlsTests.cs b/src/Services/c-gen/Tests/Tests.O2NextGen.CertificateManagement.Application/ServiceUrlsTests.cs new file mode 100644 index 00000000..f717ac68 --- /dev/null +++ b/src/Services/c-gen/Tests/Tests.O2NextGen.CertificateManagement.Application/ServiceUrlsTests.cs @@ -0,0 +1,27 @@ +using O2NextGen.CertificateManagement.Application; +using Tests.O2NextGen.CertificateManagement.Application.Base; +using Xunit; + +namespace Tests.O2NextGen.CertificateManagement.Application; + +public class ServiceUrlsTests : BaseConfigTests +{ + [Theory] + [InlineData("ServiceUrls")] + public override void It_CheckClassName(string name = "") + { + base.It_CheckClassName(name); + } + + [Fact] + public void UrlsConfigTests_PropertyIdentityUrl_IsType() + { + Assert.True(BaseHelper.It_CheckExistPropertyOfType("IdentityUrl", typeof(string))); + } + + [Fact] + public void UrlsConfigTests_PropertyCGenUrl_IsType() + { + Assert.True(BaseHelper.It_CheckExistPropertyOfType("CGenUrl", typeof(string))); + } +} \ No newline at end of file diff --git a/src/Services/c-gen/Tests/Tests.O2NextGen.CertificateManagement.Application/Tests.O2NextGen.CertificateManagement.Application.csproj b/src/Services/c-gen/Tests/Tests.O2NextGen.CertificateManagement.Application/Tests.O2NextGen.CertificateManagement.Application.csproj new file mode 100644 index 00000000..320e239b --- /dev/null +++ b/src/Services/c-gen/Tests/Tests.O2NextGen.CertificateManagement.Application/Tests.O2NextGen.CertificateManagement.Application.csproj @@ -0,0 +1,29 @@ + + + + net6.0 + enable + + false + + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + diff --git a/src/Services/c-gen/Tests/Tests.O2NextGen.CertificateManagement.Domain/Tests.O2NextGen.CertificateManagement.Domain.csproj b/src/Services/c-gen/Tests/Tests.O2NextGen.CertificateManagement.Domain/Tests.O2NextGen.CertificateManagement.Domain.csproj new file mode 100644 index 00000000..35cd8dcc --- /dev/null +++ b/src/Services/c-gen/Tests/Tests.O2NextGen.CertificateManagement.Domain/Tests.O2NextGen.CertificateManagement.Domain.csproj @@ -0,0 +1,23 @@ + + + + net6.0 + enable + + false + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + diff --git a/src/Services/c-gen/Tests/Tests.O2NextGen.CertificateManagement.Domain/UnitTest1.cs b/src/Services/c-gen/Tests/Tests.O2NextGen.CertificateManagement.Domain/UnitTest1.cs new file mode 100644 index 00000000..d8bd405b --- /dev/null +++ b/src/Services/c-gen/Tests/Tests.O2NextGen.CertificateManagement.Domain/UnitTest1.cs @@ -0,0 +1,11 @@ +using Xunit; + +namespace Tests.O2NextGen.CertificateManagement.Domain; + +public class UnitTest1 +{ + [Fact] + public void Test1() + { + } +} \ No newline at end of file diff --git a/src/Services/o2bionics-id/src/O2Bionics.Services.IdServer/appsettings.Development.json b/src/Services/o2bionics-id/src/O2Bionics.Services.IdServer/appsettings.Development.json index f47c7b72..f1dd9ff7 100644 --- a/src/Services/o2bionics-id/src/O2Bionics.Services.IdServer/appsettings.Development.json +++ b/src/Services/o2bionics-id/src/O2Bionics.Services.IdServer/appsettings.Development.json @@ -8,5 +8,13 @@ }, "Urls": { "PfrMvcUrl":"https://localhost:5003" + }, + "DataProtection": { + "KeyVaultKeyId": "https://identity.o2bus.com/keys/DataProtectionKey/bfc1bda979bc4081b89ab6f43bad12b8", + "AadTenantId": "f3a52f65-e3a4-4386-8bc9-a42f32fc1cd6", + "StorageAccountName": "o2nextgen001", + "StorageKeyContainerName": "dataprotection", + "StorageKeyBlobName": "keys.xml", + "StorageDevKeyBlobName": "dev-keys.xml" } } diff --git a/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Controllers/CategoryController.cs b/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Controllers/CategoryController.cs new file mode 100644 index 00000000..5f89af4c --- /dev/null +++ b/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Controllers/CategoryController.cs @@ -0,0 +1,102 @@ +using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; +using PFRCentr.App.MvcClient.Models.Dto; +using PFRCentr.App.MvcClient.Services; + +namespace PFRCentr.App.MvcClient.Controllers; + +public class CategoryController:Controller +{ + private readonly ICGenCategoryService _icGenCategoryService; + + public CategoryController(ICGenCategoryService icGenCategoryService) + { + _icGenCategoryService = icGenCategoryService; + } + public async Task CategoryIndex() + { + var response = await _icGenCategoryService.GetCategoriesAsync>(); + List list = null; + // if (response != null && response.IsSuccess) + // { + // list = JsonConvert.DeserializeObject>(response.ToString()); + // } + return View(response); + } + + public IActionResult CreateCategory() + { + return View(); + } + [HttpPost] + [ValidateAntiForgeryToken] + public async Task CreateCategory(CategoryDto model) + { + if (ModelState.IsValid) + { + var response = await _icGenCategoryService.CreateCategoryAsync(model); + List list = null; + // if (response != null && response.IsSuccess) + // { + // list = JsonConvert.DeserializeObject>(response.ToString()); + // } + // if (response == null) + // return View(model); + return RedirectToAction(nameof(CategoryIndex)); + } + return View(model); + } + + public async Task EditCategory(long categoryId) + { + var response = await _icGenCategoryService.GetCategoryByIdAsync(categoryId); + List list = null; + if (response != null ) + return View(response); + return NotFound(); + // { + // list = JsonConvert.DeserializeObject>(response.ToString()); + // } + // if (response == null) + // return View(model); + + } + [HttpPost] + [ValidateAntiForgeryToken] + public async Task EditCategory(CategoryDto model) + { + if (ModelState.IsValid) + { + var response = await _icGenCategoryService.UpdateCategoryAsync(model.Id, model); + List list = null; + // if (response != null && response.IsSuccess) + // { + // list = JsonConvert.DeserializeObject>(response.ToString()); + // } + // if (response == null) + // return View(model); + return RedirectToAction(nameof(CategoryIndex)); + } + return View(model); + } + + public async Task DeleteCategory(long categoryId) + { + var response = await _icGenCategoryService.GetCategoryByIdAsync(categoryId); + List list = null; + if (response != null ) + return View(response); + return NotFound(); + + } + + [HttpPost] + [ValidateAntiForgeryToken] + public async Task DeleteCategory(CategoryDto model) + { + + await _icGenCategoryService.DeleteCategoryAsync(model.Id); + return RedirectToAction(nameof(CategoryIndex)); + + } +} \ No newline at end of file diff --git a/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Controllers/CertificateController.cs b/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Controllers/CertificateController.cs new file mode 100644 index 00000000..73deb082 --- /dev/null +++ b/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Controllers/CertificateController.cs @@ -0,0 +1,101 @@ +using Microsoft.AspNetCore.Mvc; +using PFRCentr.App.MvcClient.Models.Dto; +using PFRCentr.App.MvcClient.Services; + +namespace PFRCentr.App.MvcClient.Controllers; + +public class CertificateController : Controller +{ + private readonly ICGenCertificateService _cGenCertificateService; + + public CertificateController(ICGenCertificateService cGenCertificateService) + { + _cGenCertificateService = cGenCertificateService; + } + public async Task CertificateIndex() + { + var response = await _cGenCertificateService.GetCertificatesAsync>(); + List list = null; + // if (response != null && response.IsSuccess) + // { + // list = JsonConvert.DeserializeObject>(response.ToString()); + // } + return View(response); + } + + public IActionResult CreateCertificate() + { + return View(); + } + [HttpPost] + [ValidateAntiForgeryToken] + public async Task CreateCertificate(CertificateDto model) + { + if (ModelState.IsValid) + { + var response = await _cGenCertificateService.CreateCertificateAsync(model); + List list = null; + // if (response != null && response.IsSuccess) + // { + // list = JsonConvert.DeserializeObject>(response.ToString()); + // } + // if (response == null) + // return View(model); + return RedirectToAction(nameof(CertificateIndex)); + } + return View(model); + } + + public async Task EditCertificate(long CertificateId) + { + var response = await _cGenCertificateService.GetCertificateByIdAsync(CertificateId); + List list = null; + if (response != null ) + return View(response); + return NotFound(); + // { + // list = JsonConvert.DeserializeObject>(response.ToString()); + // } + // if (response == null) + // return View(model); + + } + [HttpPost] + [ValidateAntiForgeryToken] + public async Task EditCertificate(CertificateDto model) + { + if (ModelState.IsValid) + { + var response = await _cGenCertificateService.UpdateCertificateAsync(model.Id, model); + List list = null; + // if (response != null && response.IsSuccess) + // { + // list = JsonConvert.DeserializeObject>(response.ToString()); + // } + // if (response == null) + // return View(model); + return RedirectToAction(nameof(CertificateIndex)); + } + return View(model); + } + + public async Task DeleteCertificate(long CertificateId) + { + var response = await _cGenCertificateService.GetCertificateByIdAsync(CertificateId); + List list = null; + if (response != null ) + return View(response); + return NotFound(); + + } + + [HttpPost] + [ValidateAntiForgeryToken] + public async Task DeleteCertificate(CertificateDto model) + { + + await _cGenCertificateService.DeleteCertificateAsync(model.Id); + return RedirectToAction(nameof(CertificateIndex)); + + } +} \ No newline at end of file diff --git a/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Controllers/HomeController.cs b/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Controllers/HomeController.cs index f97678b6..2c6c68ab 100644 --- a/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Controllers/HomeController.cs +++ b/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Controllers/HomeController.cs @@ -1,4 +1,4 @@ -using Microsoft.AspNetCore.Mvc; + using Microsoft.AspNetCore.Mvc; using PFRCentr.App.MvcClient.Models; using System.Diagnostics; using Microsoft.AspNetCore.Authentication; diff --git a/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Models/Dto/CategoryDto.cs b/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Models/Dto/CategoryDto.cs new file mode 100644 index 00000000..af2e7343 --- /dev/null +++ b/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Models/Dto/CategoryDto.cs @@ -0,0 +1,42 @@ +namespace PFRCentr.App.MvcClient.Models.Dto; + +public class CertificateDto +{ + public long Id { get; set; } + public string ExternalId { get; set; } + public bool? IsDeleted { get; set; } + + public string OwnerAccountId { get; set; } + public string CustomerId { get; set; } + public long ExpiredDate { get; set; } + public long PublishDate { get; set; } + public string CreatorId { get; set; } + public string PublishCode { get; set; } + public bool IsVisible { get; set; } + + public long CategoryId { get; set; } + public CategoryDto Category { get; set; } + public bool Lock { get; set; } + public long LockedDate { get; set; } + public string LockInfo { get; set; } + //public ICollection LanguageInfos { get; } + public bool? ModifiedDate { get; internal set; } + public string AddedDate { get; internal set; } + public string DeletedDate { get; internal set; } + +} +public class CategoryDto +{ + public long Id { get; set; } + public string CategoryName { get; set; } + public string CategoryDescription { get; set; } + public string CategorySeries { get; set; } + public string CustomerId { get; set; } + public long? AddedDate { get; set; } + public long? ModifiedDate { get; set; } + public long? DeletedDate { get; set; } + public bool? IsDeleted { get; set; } + public int TimeLifeInDays { get; set; } + public int QuantityCertificates { get; set; } + public int QuantityPublishCode { get; set; } +} \ No newline at end of file diff --git a/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Program.cs b/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Program.cs index b237a065..d81bbf75 100644 --- a/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Program.cs +++ b/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Program.cs @@ -1,12 +1,19 @@ using System.IdentityModel.Tokens.Jwt; +using System.Text.Json; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authentication.OpenIdConnect; using Microsoft.IdentityModel.Logging; +using PFRCentr.App.MvcClient; +using PFRCentr.App.MvcClient.Services; var builder = WebApplication.CreateBuilder(args); IdentityModelEventSource.ShowPII = true; // Add services to the container. -builder.Services.AddControllersWithViews(); +builder.Services.AddControllersWithViews() + .AddJsonOptions(options => + { + options.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase; + }); JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear(); var identityUrl = Environment.GetEnvironmentVariable("Services:AuthApiUrl") ?? @@ -17,7 +24,12 @@ Console.WriteLine($"IdentityUrl = {identityUrl}"); Console.WriteLine($"CallBackUrl = {callBackUrl}"); +SD.CGenApiBase = builder.Configuration.GetValue("Services:CGenApi"); +builder.Services.AddHttpClient(); +builder.Services.AddScoped(); +builder.Services.AddHttpClient(); +builder.Services.AddScoped(); builder.Services.AddAuthentication(option => { option.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; diff --git a/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/SD.cs b/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/SD.cs new file mode 100644 index 00000000..584d5703 --- /dev/null +++ b/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/SD.cs @@ -0,0 +1,13 @@ +namespace PFRCentr.App.MvcClient; + +public class SD +{ + public static string CGenApiBase { get; set; } + public enum ApiType + { + GET, + POST, + PUT, + DELETE + } +} \ No newline at end of file diff --git a/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Services/ApiRequest.cs b/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Services/ApiRequest.cs new file mode 100644 index 00000000..71ce64a2 --- /dev/null +++ b/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Services/ApiRequest.cs @@ -0,0 +1,107 @@ +using System.Text; +using Newtonsoft.Json; +using Newtonsoft.Json.Serialization; +using NotImplementedException = System.NotImplementedException; + +namespace PFRCentr.App.MvcClient.Services; + +public class ApiRequest : IApiRequest +{ + public SD.ApiType ApiType { get; set; } + public string Url { get; set; } + public object Data { get; set; } + public string Token { get; set; } +} + +public class ResponseDto +{ + public string DisplayMessage { get; set; } + public List ErrorMessage { get; set; } + public bool IsSuccess { get; set; } + public object Result { get; set; } +} + +public interface IBaseService : IDisposable +{ + ResponseDto ResponseModel { get; set; } + Task SendAsync(ApiRequest apiRequest); +} + +public class BaseService : IBaseService +{ + public void Dispose() + { + GC.SuppressFinalize(true); + } + + public BaseService(IHttpClientFactory httpClient) + { + ResponseModel = new ResponseDto(); + HttpClient = httpClient; + } + + protected IHttpClientFactory HttpClient { get; } + public ResponseDto ResponseModel { get; set; } + + public async Task SendAsync(ApiRequest apiRequest) + { + try + { + var client = HttpClient.CreateClient("GCenApi"); + HttpRequestMessage message = new HttpRequestMessage(); + message.Headers.Add("Accept", "application/json"); + message.RequestUri = new Uri(apiRequest.Url); + client.DefaultRequestHeaders.Clear(); + + if (apiRequest.Data != null) + { + var json = JsonConvert.SerializeObject(apiRequest.Data, new JsonSerializerSettings + { + ContractResolver = new CamelCasePropertyNamesContractResolver() + }); + message.Content = new StringContent(json,Encoding.UTF8,"application/json"); + } + HttpResponseMessage apiResponce = null; + switch (apiRequest.ApiType) + { + case SD.ApiType.POST: + message.Method = HttpMethod.Post; + break; + case SD.ApiType.PUT: + message.Method = HttpMethod.Put; + break; + case SD.ApiType.DELETE: + message.Method = HttpMethod.Delete; + break; + default: + message.Method = HttpMethod.Get; + break; + } + + apiResponce = await client.SendAsync(message); + var apiContent = await apiResponce.Content.ReadAsStringAsync(); + var apiResponseDto = JsonConvert.DeserializeObject(apiContent); + return apiResponseDto; + } + catch (Exception e) + { + var dto = new ResponseDto() + { + DisplayMessage = "Error", + ErrorMessage = new List {Convert.ToString(e.Message)}, + IsSuccess = false + }; + var res = JsonConvert.SerializeObject(dto); + var apiResponseDto = JsonConvert.DeserializeObject(res); + return apiResponseDto; + } + } +} + +public interface IApiRequest +{ + SD.ApiType ApiType { get; set; } + string Url { get; set; } + object Data { get; set; } + string Token { get; set; } +} \ No newline at end of file diff --git a/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Services/CGenCertificateService.cs b/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Services/CGenCertificateService.cs new file mode 100644 index 00000000..23b75951 --- /dev/null +++ b/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Services/CGenCertificateService.cs @@ -0,0 +1,66 @@ +namespace PFRCentr.App.MvcClient.Services; + +public class CGenCertificateService: BaseService,ICGenCertificateService +{ + public CGenCertificateService(IHttpClientFactory httpClient) : base(httpClient) + { + } + public async Task GetCertificatesAsync() + { + return await SendAsync( + new ApiRequest + { + ApiType = SD.ApiType.GET, + Url = SD.CGenApiBase +"/api/Certificates", + Token ="" + }); + } + + public async Task GetCertificateByIdAsync(long id) + { + return await SendAsync( + new ApiRequest + { + ApiType = SD.ApiType.GET, + Url = SD.CGenApiBase +$"/api/Certificates/{id}", + Token ="" + }); + } + + public async Task CreateCertificateAsync(T model) + { + return await SendAsync( + new ApiRequest + { + ApiType = SD.ApiType.POST, + Data = model, + Url = SD.CGenApiBase +"/api/Certificates", + Token ="" + }); + } + + + public async Task UpdateCertificateAsync(long id,T model) + { + return await SendAsync( + new ApiRequest + { + ApiType = SD.ApiType.PUT, + Data = model, + Url = SD.CGenApiBase + $"/api/Certificates/{id}", + Token = "" + }); + + } + + public async Task DeleteCertificateAsync(long id) + { + return await SendAsync( + new ApiRequest + { + ApiType = SD.ApiType.DELETE, + Url = SD.CGenApiBase + $"/api/Certificates/{id}", + Token = "" + }); + } +} \ No newline at end of file diff --git a/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Services/CGenService.cs b/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Services/CGenService.cs new file mode 100644 index 00000000..7f81854e --- /dev/null +++ b/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Services/CGenService.cs @@ -0,0 +1,71 @@ +using Newtonsoft.Json; +using PFRCentr.App.MvcClient.Models.Dto; + +namespace PFRCentr.App.MvcClient.Services; + +public class CGenCategoryService : BaseService,ICGenCategoryService +{ + public async Task GetCategoriesAsync() + { + return await SendAsync( + new ApiRequest + { + ApiType = SD.ApiType.GET, + Url = SD.CGenApiBase +"/api/Categories", + Token ="" + }); + } + + public async Task GetCategoryByIdAsync(long id) + { + return await SendAsync( + new ApiRequest + { + ApiType = SD.ApiType.GET, + Url = SD.CGenApiBase +$"/api/Categories/{id}", + Token ="" + }); + } + + public async Task CreateCategoryAsync(T model) + { + return await SendAsync( + new ApiRequest + { + ApiType = SD.ApiType.POST, + Data = model, + Url = SD.CGenApiBase +"/api/Categories", + Token ="" + }); + } + + + public async Task UpdateCategoryAsync(long id,T model) + { + return await SendAsync( + new ApiRequest + { + ApiType = SD.ApiType.PUT, + Data = model, + Url = SD.CGenApiBase + $"/api/Categories/{id}", + Token = "" + }); + + } + + public async Task DeleteCategoryAsync(long id) + { + return await SendAsync( + new ApiRequest + { + ApiType = SD.ApiType.DELETE, + Url = SD.CGenApiBase + $"/api/Categories/{id}", + Token = "" + }); + } + + public CGenCategoryService(IHttpClientFactory httpClient) : base(httpClient) + { + + } +} \ No newline at end of file diff --git a/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Services/ICGenCategoryService.cs b/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Services/ICGenCategoryService.cs new file mode 100644 index 00000000..fb1680d8 --- /dev/null +++ b/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Services/ICGenCategoryService.cs @@ -0,0 +1,12 @@ +using PFRCentr.App.MvcClient.Models.Dto; + +namespace PFRCentr.App.MvcClient.Services; + +public interface ICGenCategoryService: IBaseService +{ + Task GetCategoriesAsync(); + Task GetCategoryByIdAsync(long id); + Task CreateCategoryAsync(T model); + Task UpdateCategoryAsync(long id,T model); + Task DeleteCategoryAsync(long id); +} \ No newline at end of file diff --git a/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Services/ICGenCertificateService.cs b/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Services/ICGenCertificateService.cs new file mode 100644 index 00000000..9f011d53 --- /dev/null +++ b/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Services/ICGenCertificateService.cs @@ -0,0 +1,10 @@ +namespace PFRCentr.App.MvcClient.Services; + +public interface ICGenCertificateService +{ + Task GetCertificatesAsync(); + Task GetCertificateByIdAsync(long id); + Task CreateCertificateAsync(T model); + Task UpdateCertificateAsync(long id,T model); + Task DeleteCertificateAsync(long id); +} \ No newline at end of file diff --git a/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Views/Category/CategoryIndex.cshtml b/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Views/Category/CategoryIndex.cshtml new file mode 100644 index 00000000..a09a1c42 --- /dev/null +++ b/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Views/Category/CategoryIndex.cshtml @@ -0,0 +1,73 @@ +@model List + +@{ + ViewBag.Title = "title"; + Layout = "_Layout"; +} + +
+
+
+
+
+

Categories

+
+ +
+ + + + + + + + + + + + + @foreach (var item in Model) + { + + + + + + + + + + + + + } + +
+ Id + + Category Name + + Category Description + + Category Serial + + Category Number +
@item.Id@item.CategoryName@item.CategoryDescription@item.CategorySeries@item.QuantityCertificates + + + + + + + +
+
+@section Scripts { + +} \ No newline at end of file diff --git a/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Views/Category/CreateCategory.cshtml b/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Views/Category/CreateCategory.cshtml new file mode 100644 index 00000000..c927c304 --- /dev/null +++ b/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Views/Category/CreateCategory.cshtml @@ -0,0 +1,87 @@ +@model PFRCentr.App.MvcClient.Models.Dto.CategoryDto +
+
+
+

Create Category

+ +
+
+
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+ @*
*@ + @* *@ + @*
*@ + @*
*@ + @* *@ + @* *@ + @*
*@ + @*
*@ + @* *@ + @*
*@ + @*
*@ + @* *@ + @* *@ + @*
*@ +
+ + Back to List +
+
+ + +
+ +
+ +
+
+
+
diff --git a/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Views/Category/DeleteCategory.cshtml b/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Views/Category/DeleteCategory.cshtml new file mode 100644 index 00000000..a94c0d1f --- /dev/null +++ b/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Views/Category/DeleteCategory.cshtml @@ -0,0 +1,84 @@ +@model PFRCentr.App.MvcClient.Models.Dto.CategoryDto +
+ +
+
+

Delete Category

+ +
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+ @*
*@ + @* *@ + @*
*@ + @*
*@ + @* *@ + @* *@ + @*
*@ + @*
*@ + @* *@ + @*
*@ + @*
*@ + @* *@ + @* *@ + @*
*@ +
+ + Back to List +
+
+ + +
+ +
+ +
+
+
+
diff --git a/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Views/Category/EditCategory.cshtml b/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Views/Category/EditCategory.cshtml new file mode 100644 index 00000000..de228d02 --- /dev/null +++ b/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Views/Category/EditCategory.cshtml @@ -0,0 +1,87 @@ +@model PFRCentr.App.MvcClient.Models.Dto.CategoryDto +
+ +
+
+

Edit Category

+
+
+
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+ @*
*@ + @* *@ + @*
*@ + @*
*@ + @* *@ + @* *@ + @*
*@ + @*
*@ + @* *@ + @*
*@ + @*
*@ + @* *@ + @* *@ + @*
*@ +
+ + Back to List +
+
+ + +
+ +
+ +
+
+
+
diff --git a/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Views/Certificate/CertificateIndex.cshtml b/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Views/Certificate/CertificateIndex.cshtml new file mode 100644 index 00000000..f51f7508 --- /dev/null +++ b/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Views/Certificate/CertificateIndex.cshtml @@ -0,0 +1,76 @@ +@model System.Collections.Generic.List + +@{ + ViewBag.Title = "title"; + Layout = "_Layout"; +} + +
+
+
+
+
+

Certificates

+
+ +
+ + + + + + + + + + + + + + @foreach (var item in Model) + { + + + + + + + + + + + + + } + +
+ Id + + Category Name + + Category Description + + Category Serial + + Category Number + + actions +
@item.Id@item?.AddedDate@item?.ExpiredDate@item?.ExternalId@item?.CustomerId + + + + + + +
+
+ +@section Scripts { + +} \ No newline at end of file diff --git a/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Views/Certificate/CreateCertificate.cshtml b/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Views/Certificate/CreateCertificate.cshtml new file mode 100644 index 00000000..59387883 --- /dev/null +++ b/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Views/Certificate/CreateCertificate.cshtml @@ -0,0 +1,92 @@ +@model PFRCentr.App.MvcClient.Models.Dto.CertificateDto +
+
+
+

Create Certificate

+ +
+
+
+
+ +
+
+ + +
+ +
+ +
+
+ + +
+ +
+ +
+
+ + +
+ +
+ +
+
+ + +
+ +
+ +
+
+ + +
+
+ @*
*@ + @* *@ + @*
*@ + @*
*@ + @* *@ + @* *@ + @*
*@ + @*
*@ + @* *@ + @*
*@ + @*
*@ + @* *@ + @* *@ + @*
*@ + @*
*@ + @* *@ + @*
*@ + @*
*@ + @* *@ + @* *@ + @*
*@ + @*
*@ + @* *@ + @*
*@ + @*
*@ + @* *@ + @* *@ + @*
*@ + @*
*@ + @* *@ + @* Back to List *@ + @*
*@ +
+ + +
+ +
+ +
+
+ +
diff --git a/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Views/Certificate/DeleteCertificate.cshtml b/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Views/Certificate/DeleteCertificate.cshtml new file mode 100644 index 00000000..372d0906 --- /dev/null +++ b/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Views/Certificate/DeleteCertificate.cshtml @@ -0,0 +1,57 @@ +@model PFRCentr.App.MvcClient.Models.Dto.CertificateDto +
+ +
+
+

Detele Category

+
+
+
+ +
+
+ + +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ + Back to List +
+
+ + +
+
+ +
+
+
\ No newline at end of file diff --git a/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Views/Certificate/EditCertificate.cshtml b/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Views/Certificate/EditCertificate.cshtml new file mode 100644 index 00000000..db996241 --- /dev/null +++ b/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Views/Certificate/EditCertificate.cshtml @@ -0,0 +1,52 @@ +@model PFRCentr.App.MvcClient.Models.Dto.CertificateDto +
+ +
+
+

Edit Category

+
+
+
+
+ +
+
+ + +
+ +
+ +
+
+ + +
+ +
+ +
+
+ + +
+ +
+ +
+
+ + +
+ +
+ +
+
+ + +
+
+
+
+
\ No newline at end of file diff --git a/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Views/Shared/_Layout.cshtml b/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Views/Shared/_Layout.cshtml index 400d474c..b3dbbb28 100644 --- a/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Views/Shared/_Layout.cshtml +++ b/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/Views/Shared/_Layout.cshtml @@ -1,53 +1,86 @@  - - + + @ViewData["Title"] - PFR Community - - - + + + + + @* *@ -
- +
+
+
+ @RenderBody() +
+
+ +
-
- @RenderBody() -
+ © 2023 - O2Bionics LLC - Privacy
- -
-
- © 2023 - O2Bionics LLC - Privacy -
-
- - - - @await RenderSectionAsync("Scripts", required: false) +
+ + + +@await RenderSectionAsync("Scripts", required: false) - + \ No newline at end of file diff --git a/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/appsettings.Development.json b/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/appsettings.Development.json index 30a1927b..ca4d3615 100644 --- a/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/appsettings.Development.json +++ b/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/appsettings.Development.json @@ -6,6 +6,8 @@ } }, "Services": { - "AuthApiUrl":"https://localhost:5000" +// "CallBackUrl":"https://localhost:5003", +// "AuthApiUrl": "https://localhost:5000", + "CGenApi":"https://localhost:11001" } } diff --git a/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/appsettings.json b/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/appsettings.json index 88909c22..64132c48 100644 --- a/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/appsettings.json +++ b/src/WebApps/PFRCentr.Mvc/src/PFRCentr.App.MvcClient/appsettings.json @@ -8,6 +8,7 @@ "AllowedHosts": "*", "Services": { "CallBackUrl":"https://localhost:5003", - "Auth": "https://localhost:5000" + "AuthApiUrl": "https://localhost:5000", + "CGenApi":"https://localhost:11001" } }