diff --git a/services/fnb-engine-net/src/FnbEngine.API/Application/Commands/ChangeSampleStatusCommand.cs b/services/fnb-engine-net/src/FnbEngine.API/Application/Commands/ChangeSampleStatusCommand.cs
deleted file mode 100644
index c70629ee..00000000
--- a/services/fnb-engine-net/src/FnbEngine.API/Application/Commands/ChangeSampleStatusCommand.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using MediatR;
-
-namespace FnbEngine.API.Application.Commands;
-
-///
-/// EN: Command to change status of a Sample.
-/// VI: Command để thay đổi trạng thái của Sample.
-///
-/// EN: Sample ID / VI: ID sample
-/// EN: New status (activate, complete, cancel) / VI: Trạng thái mới (activate, complete, cancel)
-public record ChangeSampleStatusCommand(
- Guid SampleId,
- string NewStatus
-) : IRequest;
diff --git a/services/fnb-engine-net/src/FnbEngine.API/Application/Commands/ChangeSampleStatusCommandHandler.cs b/services/fnb-engine-net/src/FnbEngine.API/Application/Commands/ChangeSampleStatusCommandHandler.cs
deleted file mode 100644
index aeb626db..00000000
--- a/services/fnb-engine-net/src/FnbEngine.API/Application/Commands/ChangeSampleStatusCommandHandler.cs
+++ /dev/null
@@ -1,70 +0,0 @@
-using MediatR;
-using FnbEngine.Domain.AggregatesModel.SampleAggregate;
-
-namespace FnbEngine.API.Application.Commands;
-
-///
-/// EN: Handler for ChangeSampleStatusCommand.
-/// VI: Handler cho ChangeSampleStatusCommand.
-///
-public class ChangeSampleStatusCommandHandler : IRequestHandler
-{
- private readonly ISampleRepository _sampleRepository;
- private readonly ILogger _logger;
-
- public ChangeSampleStatusCommandHandler(
- ISampleRepository sampleRepository,
- ILogger logger)
- {
- _sampleRepository = sampleRepository ?? throw new ArgumentNullException(nameof(sampleRepository));
- _logger = logger ?? throw new ArgumentNullException(nameof(logger));
- }
-
- public async Task Handle(
- ChangeSampleStatusCommand request,
- CancellationToken cancellationToken)
- {
- _logger.LogInformation(
- "Changing status of sample {SampleId} to {NewStatus} / Thay đổi trạng thái sample {SampleId} thành {NewStatus}",
- request.SampleId, request.NewStatus);
-
- // EN: Get existing sample / VI: Lấy sample đã tồn tại
- var sample = await _sampleRepository.GetAsync(request.SampleId);
-
- if (sample is null)
- {
- _logger.LogWarning(
- "Sample {SampleId} not found / Sample {SampleId} không tìm thấy",
- request.SampleId);
- return false;
- }
-
- // EN: Change status based on action / VI: Thay đổi trạng thái dựa trên action
- switch (request.NewStatus.ToLowerInvariant())
- {
- case "activate":
- sample.Activate();
- break;
- case "complete":
- sample.Complete();
- break;
- case "cancel":
- sample.Cancel();
- break;
- default:
- _logger.LogWarning(
- "Invalid status action: {NewStatus} / Action trạng thái không hợp lệ: {NewStatus}",
- request.NewStatus);
- return false;
- }
-
- // EN: Save changes / VI: Lưu thay đổi
- await _sampleRepository.UnitOfWork.SaveEntitiesAsync(cancellationToken);
-
- _logger.LogInformation(
- "Sample {SampleId} status changed to {NewStatus} / Trạng thái sample {SampleId} đã đổi thành {NewStatus}",
- request.SampleId, request.NewStatus);
-
- return true;
- }
-}
diff --git a/services/fnb-engine-net/src/FnbEngine.API/Application/Commands/CreateSampleCommand.cs b/services/fnb-engine-net/src/FnbEngine.API/Application/Commands/CreateSampleCommand.cs
deleted file mode 100644
index e8dadccb..00000000
--- a/services/fnb-engine-net/src/FnbEngine.API/Application/Commands/CreateSampleCommand.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-using MediatR;
-
-namespace FnbEngine.API.Application.Commands;
-
-///
-/// EN: Command to create a new Sample.
-/// VI: Command để tạo một Sample mới.
-///
-/// EN: Sample name / VI: Tên sample
-/// EN: Optional description / VI: Mô tả tùy chọn
-public record CreateSampleCommand(
- string Name,
- string? Description
-) : IRequest;
-
-///
-/// EN: Result of CreateSampleCommand.
-/// VI: Kết quả của CreateSampleCommand.
-///
-/// EN: Created sample ID / VI: ID sample đã tạo
-public record CreateSampleCommandResult(Guid Id);
diff --git a/services/fnb-engine-net/src/FnbEngine.API/Application/Commands/CreateSampleCommandHandler.cs b/services/fnb-engine-net/src/FnbEngine.API/Application/Commands/CreateSampleCommandHandler.cs
deleted file mode 100644
index 28ace011..00000000
--- a/services/fnb-engine-net/src/FnbEngine.API/Application/Commands/CreateSampleCommandHandler.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-using MediatR;
-using FnbEngine.Domain.AggregatesModel.SampleAggregate;
-
-namespace FnbEngine.API.Application.Commands;
-
-///
-/// EN: Handler for CreateSampleCommand.
-/// VI: Handler cho CreateSampleCommand.
-///
-public class CreateSampleCommandHandler : IRequestHandler
-{
- private readonly ISampleRepository _sampleRepository;
- private readonly ILogger _logger;
-
- public CreateSampleCommandHandler(
- ISampleRepository sampleRepository,
- ILogger logger)
- {
- _sampleRepository = sampleRepository ?? throw new ArgumentNullException(nameof(sampleRepository));
- _logger = logger ?? throw new ArgumentNullException(nameof(logger));
- }
-
- public async Task Handle(
- CreateSampleCommand request,
- CancellationToken cancellationToken)
- {
- _logger.LogInformation(
- "Creating new sample with name: {Name} / Tạo sample mới với tên: {Name}",
- request.Name);
-
- // EN: Create domain entity / VI: Tạo domain entity
- var sample = new Sample(request.Name, request.Description);
-
- // EN: Add to repository / VI: Thêm vào repository
- _sampleRepository.Add(sample);
-
- // EN: Save changes (dispatches domain events) / VI: Lưu thay đổi (dispatch domain events)
- await _sampleRepository.UnitOfWork.SaveEntitiesAsync(cancellationToken);
-
- _logger.LogInformation(
- "Sample created successfully with ID: {SampleId} / Sample đã tạo thành công với ID: {SampleId}",
- sample.Id);
-
- return new CreateSampleCommandResult(sample.Id);
- }
-}
diff --git a/services/fnb-engine-net/src/FnbEngine.API/Application/Commands/DeleteSampleCommand.cs b/services/fnb-engine-net/src/FnbEngine.API/Application/Commands/DeleteSampleCommand.cs
deleted file mode 100644
index d532b9dd..00000000
--- a/services/fnb-engine-net/src/FnbEngine.API/Application/Commands/DeleteSampleCommand.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using MediatR;
-
-namespace FnbEngine.API.Application.Commands;
-
-///
-/// EN: Command to delete a Sample.
-/// VI: Command để xóa một Sample.
-///
-/// EN: Sample ID to delete / VI: ID sample cần xóa
-public record DeleteSampleCommand(Guid SampleId) : IRequest;
diff --git a/services/fnb-engine-net/src/FnbEngine.API/Application/Commands/DeleteSampleCommandHandler.cs b/services/fnb-engine-net/src/FnbEngine.API/Application/Commands/DeleteSampleCommandHandler.cs
deleted file mode 100644
index bfb3b237..00000000
--- a/services/fnb-engine-net/src/FnbEngine.API/Application/Commands/DeleteSampleCommandHandler.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-using MediatR;
-using FnbEngine.Domain.AggregatesModel.SampleAggregate;
-
-namespace FnbEngine.API.Application.Commands;
-
-///
-/// EN: Handler for DeleteSampleCommand.
-/// VI: Handler cho DeleteSampleCommand.
-///
-public class DeleteSampleCommandHandler : IRequestHandler
-{
- private readonly ISampleRepository _sampleRepository;
- private readonly ILogger _logger;
-
- public DeleteSampleCommandHandler(
- ISampleRepository sampleRepository,
- ILogger logger)
- {
- _sampleRepository = sampleRepository ?? throw new ArgumentNullException(nameof(sampleRepository));
- _logger = logger ?? throw new ArgumentNullException(nameof(logger));
- }
-
- public async Task Handle(
- DeleteSampleCommand request,
- CancellationToken cancellationToken)
- {
- _logger.LogInformation(
- "Deleting sample {SampleId} / Xóa sample {SampleId}",
- request.SampleId);
-
- // EN: Get existing sample / VI: Lấy sample đã tồn tại
- var sample = await _sampleRepository.GetAsync(request.SampleId);
-
- if (sample is null)
- {
- _logger.LogWarning(
- "Sample {SampleId} not found / Sample {SampleId} không tìm thấy",
- request.SampleId);
- return false;
- }
-
- // EN: Delete sample / VI: Xóa sample
- _sampleRepository.Delete(sample);
-
- // EN: Save changes / VI: Lưu thay đổi
- await _sampleRepository.UnitOfWork.SaveEntitiesAsync(cancellationToken);
-
- _logger.LogInformation(
- "Sample {SampleId} deleted successfully / Sample {SampleId} đã xóa thành công",
- request.SampleId);
-
- return true;
- }
-}
diff --git a/services/fnb-engine-net/src/FnbEngine.API/Application/Commands/UpdateSampleCommand.cs b/services/fnb-engine-net/src/FnbEngine.API/Application/Commands/UpdateSampleCommand.cs
deleted file mode 100644
index 2213b81a..00000000
--- a/services/fnb-engine-net/src/FnbEngine.API/Application/Commands/UpdateSampleCommand.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using MediatR;
-
-namespace FnbEngine.API.Application.Commands;
-
-///
-/// EN: Command to update an existing Sample.
-/// VI: Command để cập nhật một Sample đã tồn tại.
-///
-/// EN: Sample ID to update / VI: ID sample cần cập nhật
-/// EN: New name / VI: Tên mới
-/// EN: New description / VI: Mô tả mới
-public record UpdateSampleCommand(
- Guid SampleId,
- string Name,
- string? Description
-) : IRequest;
diff --git a/services/fnb-engine-net/src/FnbEngine.API/Application/Commands/UpdateSampleCommandHandler.cs b/services/fnb-engine-net/src/FnbEngine.API/Application/Commands/UpdateSampleCommandHandler.cs
deleted file mode 100644
index dcf72e54..00000000
--- a/services/fnb-engine-net/src/FnbEngine.API/Application/Commands/UpdateSampleCommandHandler.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-using MediatR;
-using FnbEngine.Domain.AggregatesModel.SampleAggregate;
-
-namespace FnbEngine.API.Application.Commands;
-
-///
-/// EN: Handler for UpdateSampleCommand.
-/// VI: Handler cho UpdateSampleCommand.
-///
-public class UpdateSampleCommandHandler : IRequestHandler
-{
- private readonly ISampleRepository _sampleRepository;
- private readonly ILogger _logger;
-
- public UpdateSampleCommandHandler(
- ISampleRepository sampleRepository,
- ILogger logger)
- {
- _sampleRepository = sampleRepository ?? throw new ArgumentNullException(nameof(sampleRepository));
- _logger = logger ?? throw new ArgumentNullException(nameof(logger));
- }
-
- public async Task Handle(
- UpdateSampleCommand request,
- CancellationToken cancellationToken)
- {
- _logger.LogInformation(
- "Updating sample {SampleId} / Cập nhật sample {SampleId}",
- request.SampleId);
-
- // EN: Get existing sample / VI: Lấy sample đã tồn tại
- var sample = await _sampleRepository.GetAsync(request.SampleId);
-
- if (sample is null)
- {
- _logger.LogWarning(
- "Sample {SampleId} not found / Sample {SampleId} không tìm thấy",
- request.SampleId);
- return false;
- }
-
- // EN: Update sample using domain method / VI: Cập nhật sample sử dụng domain method
- sample.Update(request.Name, request.Description);
-
- // EN: Save changes / VI: Lưu thay đổi
- await _sampleRepository.UnitOfWork.SaveEntitiesAsync(cancellationToken);
-
- _logger.LogInformation(
- "Sample {SampleId} updated successfully / Sample {SampleId} đã cập nhật thành công",
- request.SampleId);
-
- return true;
- }
-}
diff --git a/services/fnb-engine-net/src/FnbEngine.API/Application/Queries/GetSampleQuery.cs b/services/fnb-engine-net/src/FnbEngine.API/Application/Queries/GetSampleQuery.cs
deleted file mode 100644
index 4555d605..00000000
--- a/services/fnb-engine-net/src/FnbEngine.API/Application/Queries/GetSampleQuery.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using MediatR;
-
-namespace FnbEngine.API.Application.Queries;
-
-///
-/// EN: Query to get a Sample by ID.
-/// VI: Query để lấy một Sample theo ID.
-///
-/// EN: Sample ID / VI: ID sample
-public record GetSampleQuery(Guid SampleId) : IRequest;
-
-///
-/// EN: Sample view model for API responses.
-/// VI: Sample view model cho API responses.
-///
-public record SampleViewModel(
- Guid Id,
- string Name,
- string? Description,
- string Status,
- DateTime CreatedAt,
- DateTime? UpdatedAt
-);
diff --git a/services/fnb-engine-net/src/FnbEngine.API/Application/Queries/GetSampleQueryHandler.cs b/services/fnb-engine-net/src/FnbEngine.API/Application/Queries/GetSampleQueryHandler.cs
deleted file mode 100644
index d4be2933..00000000
--- a/services/fnb-engine-net/src/FnbEngine.API/Application/Queries/GetSampleQueryHandler.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-using MediatR;
-using FnbEngine.Domain.AggregatesModel.SampleAggregate;
-
-namespace FnbEngine.API.Application.Queries;
-
-///
-/// EN: Handler for GetSampleQuery.
-/// VI: Handler cho GetSampleQuery.
-///
-public class GetSampleQueryHandler : IRequestHandler
-{
- private readonly ISampleRepository _sampleRepository;
-
- public GetSampleQueryHandler(ISampleRepository sampleRepository)
- {
- _sampleRepository = sampleRepository ?? throw new ArgumentNullException(nameof(sampleRepository));
- }
-
- public async Task Handle(
- GetSampleQuery request,
- CancellationToken cancellationToken)
- {
- var sample = await _sampleRepository.GetAsync(request.SampleId);
-
- if (sample is null)
- {
- return null;
- }
-
- return new SampleViewModel(
- sample.Id,
- sample.Name,
- sample.Description,
- sample.Status.Name,
- sample.CreatedAt,
- sample.UpdatedAt
- );
- }
-}
diff --git a/services/fnb-engine-net/src/FnbEngine.API/Application/Queries/GetSamplesQuery.cs b/services/fnb-engine-net/src/FnbEngine.API/Application/Queries/GetSamplesQuery.cs
deleted file mode 100644
index 33c85dee..00000000
--- a/services/fnb-engine-net/src/FnbEngine.API/Application/Queries/GetSamplesQuery.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-using MediatR;
-
-namespace FnbEngine.API.Application.Queries;
-
-///
-/// EN: Query to get all Samples.
-/// VI: Query để lấy tất cả Samples.
-///
-public record GetSamplesQuery : IRequest>;
diff --git a/services/fnb-engine-net/src/FnbEngine.API/Application/Queries/GetSamplesQueryHandler.cs b/services/fnb-engine-net/src/FnbEngine.API/Application/Queries/GetSamplesQueryHandler.cs
deleted file mode 100644
index 724a0e76..00000000
--- a/services/fnb-engine-net/src/FnbEngine.API/Application/Queries/GetSamplesQueryHandler.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-using MediatR;
-using FnbEngine.Domain.AggregatesModel.SampleAggregate;
-
-namespace FnbEngine.API.Application.Queries;
-
-///
-/// EN: Handler for GetSamplesQuery.
-/// VI: Handler cho GetSamplesQuery.
-///
-public class GetSamplesQueryHandler : IRequestHandler>
-{
- private readonly ISampleRepository _sampleRepository;
-
- public GetSamplesQueryHandler(ISampleRepository sampleRepository)
- {
- _sampleRepository = sampleRepository ?? throw new ArgumentNullException(nameof(sampleRepository));
- }
-
- public async Task> Handle(
- GetSamplesQuery request,
- CancellationToken cancellationToken)
- {
- var samples = await _sampleRepository.GetAllAsync();
-
- return samples.Select(sample => new SampleViewModel(
- sample.Id,
- sample.Name,
- sample.Description,
- sample.Status.Name,
- sample.CreatedAt,
- sample.UpdatedAt
- ));
- }
-}
diff --git a/services/fnb-engine-net/src/FnbEngine.API/Application/Validations/CreateSampleCommandValidator.cs b/services/fnb-engine-net/src/FnbEngine.API/Application/Validations/CreateSampleCommandValidator.cs
deleted file mode 100644
index b0cf6e93..00000000
--- a/services/fnb-engine-net/src/FnbEngine.API/Application/Validations/CreateSampleCommandValidator.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using FluentValidation;
-using FnbEngine.API.Application.Commands;
-
-namespace FnbEngine.API.Application.Validations;
-
-///
-/// EN: Validator for CreateSampleCommand.
-/// VI: Validator cho CreateSampleCommand.
-///
-public class CreateSampleCommandValidator : AbstractValidator
-{
- public CreateSampleCommandValidator()
- {
- RuleFor(x => x.Name)
- .NotEmpty()
- .WithMessage("Name is required / Tên là bắt buộc")
- .MaximumLength(200)
- .WithMessage("Name must be less than 200 characters / Tên phải ít hơn 200 ký tự");
-
- RuleFor(x => x.Description)
- .MaximumLength(1000)
- .WithMessage("Description must be less than 1000 characters / Mô tả phải ít hơn 1000 ký tự")
- .When(x => x.Description != null);
- }
-}
diff --git a/services/fnb-engine-net/src/FnbEngine.API/Application/Validations/UpdateSampleCommandValidator.cs b/services/fnb-engine-net/src/FnbEngine.API/Application/Validations/UpdateSampleCommandValidator.cs
deleted file mode 100644
index cb336c44..00000000
--- a/services/fnb-engine-net/src/FnbEngine.API/Application/Validations/UpdateSampleCommandValidator.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-using FluentValidation;
-using FnbEngine.API.Application.Commands;
-
-namespace FnbEngine.API.Application.Validations;
-
-///
-/// EN: Validator for UpdateSampleCommand.
-/// VI: Validator cho UpdateSampleCommand.
-///
-public class UpdateSampleCommandValidator : AbstractValidator
-{
- public UpdateSampleCommandValidator()
- {
- RuleFor(x => x.SampleId)
- .NotEmpty()
- .WithMessage("Sample ID is required / ID sample là bắt buộc");
-
- RuleFor(x => x.Name)
- .NotEmpty()
- .WithMessage("Name is required / Tên là bắt buộc")
- .MaximumLength(200)
- .WithMessage("Name must be less than 200 characters / Tên phải ít hơn 200 ký tự");
-
- RuleFor(x => x.Description)
- .MaximumLength(1000)
- .WithMessage("Description must be less than 1000 characters / Mô tả phải ít hơn 1000 ký tự")
- .When(x => x.Description != null);
- }
-}
diff --git a/services/fnb-engine-net/src/FnbEngine.API/Controllers/SamplesController.cs b/services/fnb-engine-net/src/FnbEngine.API/Controllers/SamplesController.cs
deleted file mode 100644
index f03ec326..00000000
--- a/services/fnb-engine-net/src/FnbEngine.API/Controllers/SamplesController.cs
+++ /dev/null
@@ -1,200 +0,0 @@
-using Asp.Versioning;
-using MediatR;
-using Microsoft.AspNetCore.Mvc;
-using FnbEngine.API.Application.Commands;
-using FnbEngine.API.Application.Queries;
-
-namespace FnbEngine.API.Controllers;
-
-///
-/// EN: Controller for Sample CRUD operations using CQRS pattern.
-/// VI: Controller cho các thao tác CRUD Sample sử dụng pattern CQRS.
-///
-[ApiController]
-[ApiVersion("1.0")]
-[Route("api/v{version:apiVersion}/[controller]")]
-[Produces("application/json")]
-public class SamplesController : ControllerBase
-{
- private readonly IMediator _mediator;
- private readonly ILogger _logger;
-
- public SamplesController(IMediator mediator, ILogger logger)
- {
- _mediator = mediator ?? throw new ArgumentNullException(nameof(mediator));
- _logger = logger ?? throw new ArgumentNullException(nameof(logger));
- }
-
- ///
- /// EN: Get all samples.
- /// VI: Lấy tất cả samples.
- ///
- /// EN: List of samples / VI: Danh sách samples
- [HttpGet]
- [ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)]
- public async Task GetSamples()
- {
- var samples = await _mediator.Send(new GetSamplesQuery());
- return Ok(new { success = true, data = samples });
- }
-
- ///
- /// EN: Get a sample by ID.
- /// VI: Lấy một sample theo ID.
- ///
- /// EN: Sample ID / VI: ID sample
- /// EN: Sample details / VI: Chi tiết sample
- [HttpGet("{id:guid}")]
- [ProducesResponseType(typeof(SampleViewModel), StatusCodes.Status200OK)]
- [ProducesResponseType(StatusCodes.Status404NotFound)]
- public async Task GetSample(Guid id)
- {
- var sample = await _mediator.Send(new GetSampleQuery(id));
-
- if (sample is null)
- {
- return NotFound(new
- {
- success = false,
- error = new
- {
- code = "SAMPLE_NOT_FOUND",
- message = $"Sample with ID {id} not found / Sample với ID {id} không tìm thấy"
- }
- });
- }
-
- return Ok(new { success = true, data = sample });
- }
-
- ///
- /// EN: Create a new sample.
- /// VI: Tạo một sample mới.
- ///
- /// EN: Create request / VI: Request tạo
- /// EN: Created sample ID / VI: ID sample đã tạo
- [HttpPost]
- [ProducesResponseType(typeof(CreateSampleCommandResult), StatusCodes.Status201Created)]
- [ProducesResponseType(StatusCodes.Status400BadRequest)]
- public async Task CreateSample([FromBody] CreateSampleRequest request)
- {
- var command = new CreateSampleCommand(request.Name, request.Description);
- var result = await _mediator.Send(command);
-
- return CreatedAtAction(
- nameof(GetSample),
- new { id = result.Id },
- new { success = true, data = result });
- }
-
- ///
- /// EN: Update an existing sample.
- /// VI: Cập nhật một sample đã tồn tại.
- ///
- /// EN: Sample ID / VI: ID sample
- /// EN: Update request / VI: Request cập nhật
- /// EN: Success status / VI: Trạng thái thành công
- [HttpPut("{id:guid}")]
- [ProducesResponseType(StatusCodes.Status200OK)]
- [ProducesResponseType(StatusCodes.Status404NotFound)]
- public async Task UpdateSample(Guid id, [FromBody] UpdateSampleRequest request)
- {
- var command = new UpdateSampleCommand(id, request.Name, request.Description);
- var result = await _mediator.Send(command);
-
- if (!result)
- {
- return NotFound(new
- {
- success = false,
- error = new
- {
- code = "SAMPLE_NOT_FOUND",
- message = $"Sample with ID {id} not found / Sample với ID {id} không tìm thấy"
- }
- });
- }
-
- return Ok(new { success = true, message = "Sample updated successfully / Sample đã cập nhật thành công" });
- }
-
- ///
- /// EN: Delete a sample.
- /// VI: Xóa một sample.
- ///
- /// EN: Sample ID / VI: ID sample
- /// EN: Success status / VI: Trạng thái thành công
- [HttpDelete("{id:guid}")]
- [ProducesResponseType(StatusCodes.Status204NoContent)]
- [ProducesResponseType(StatusCodes.Status404NotFound)]
- public async Task DeleteSample(Guid id)
- {
- var command = new DeleteSampleCommand(id);
- var result = await _mediator.Send(command);
-
- if (!result)
- {
- return NotFound(new
- {
- success = false,
- error = new
- {
- code = "SAMPLE_NOT_FOUND",
- message = $"Sample with ID {id} not found / Sample với ID {id} không tìm thấy"
- }
- });
- }
-
- return NoContent();
- }
-
- ///
- /// EN: Change sample status.
- /// VI: Thay đổi trạng thái sample.
- ///
- /// EN: Sample ID / VI: ID sample
- /// EN: Status change request / VI: Request thay đổi trạng thái
- /// EN: Success status / VI: Trạng thái thành công
- [HttpPatch("{id:guid}/status")]
- [ProducesResponseType(StatusCodes.Status200OK)]
- [ProducesResponseType(StatusCodes.Status400BadRequest)]
- [ProducesResponseType(StatusCodes.Status404NotFound)]
- public async Task ChangeSampleStatus(Guid id, [FromBody] ChangeStatusRequest request)
- {
- var command = new ChangeSampleStatusCommand(id, request.Status);
- var result = await _mediator.Send(command);
-
- if (!result)
- {
- return BadRequest(new
- {
- success = false,
- error = new
- {
- code = "STATUS_CHANGE_FAILED",
- message = "Failed to change sample status / Thay đổi trạng thái sample thất bại"
- }
- });
- }
-
- return Ok(new { success = true, message = "Sample status changed successfully / Trạng thái sample đã thay đổi thành công" });
- }
-}
-
-///
-/// EN: Request model for creating a sample.
-/// VI: Model request để tạo sample.
-///
-public record CreateSampleRequest(string Name, string? Description);
-
-///
-/// EN: Request model for updating a sample.
-/// VI: Model request để cập nhật sample.
-///
-public record UpdateSampleRequest(string Name, string? Description);
-
-///
-/// EN: Request model for changing sample status.
-/// VI: Model request để thay đổi trạng thái sample.
-///
-public record ChangeStatusRequest(string Status);
diff --git a/services/fnb-engine-net/src/FnbEngine.API/FnbEngine.API.csproj b/services/fnb-engine-net/src/FnbEngine.API/FnbEngine.API.csproj
index 59aa4934..583c6ec9 100644
--- a/services/fnb-engine-net/src/FnbEngine.API/FnbEngine.API.csproj
+++ b/services/fnb-engine-net/src/FnbEngine.API/FnbEngine.API.csproj
@@ -14,6 +14,10 @@
+
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
diff --git a/services/fnb-engine-net/src/FnbEngine.Infrastructure/DependencyInjection.cs b/services/fnb-engine-net/src/FnbEngine.Infrastructure/DependencyInjection.cs
index 0758eed6..b08e8ed9 100644
--- a/services/fnb-engine-net/src/FnbEngine.Infrastructure/DependencyInjection.cs
+++ b/services/fnb-engine-net/src/FnbEngine.Infrastructure/DependencyInjection.cs
@@ -1,7 +1,7 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
-using FnbEngine.Domain.AggregatesModel.SampleAggregate;
+using FnbEngine.Domain.AggregatesModel.TableAggregate;
using FnbEngine.Infrastructure.Idempotency;
using FnbEngine.Infrastructure.Repositories;
diff --git a/services/fnb-engine-net/src/FnbEngine.Infrastructure/EntityConfigurations/SampleEntityTypeConfiguration.cs b/services/fnb-engine-net/src/FnbEngine.Infrastructure/EntityConfigurations/SampleEntityTypeConfiguration.cs
deleted file mode 100644
index 135425cd..00000000
--- a/services/fnb-engine-net/src/FnbEngine.Infrastructure/EntityConfigurations/SampleEntityTypeConfiguration.cs
+++ /dev/null
@@ -1,61 +0,0 @@
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Metadata.Builders;
-using FnbEngine.Domain.AggregatesModel.SampleAggregate;
-
-namespace FnbEngine.Infrastructure.EntityConfigurations;
-
-///
-/// EN: EF Core configuration for Sample entity.
-/// VI: Cấu hình EF Core cho entity Sample.
-///
-public class SampleEntityTypeConfiguration : IEntityTypeConfiguration
-{
- public void Configure(EntityTypeBuilder builder)
- {
- // EN: Table name / VI: Tên bảng
- builder.ToTable("samples");
-
- // EN: Primary key / VI: Khóa chính
- builder.HasKey(s => s.Id);
-
- // EN: Ignore domain events (not persisted)
- // VI: Bỏ qua domain events (không lưu)
- builder.Ignore(s => s.DomainEvents);
-
- // EN: Properties / VI: Các thuộc tính
- builder.Property(s => s.Id)
- .HasColumnName("id")
- .IsRequired();
-
- builder.Property("_name")
- .HasColumnName("name")
- .HasMaxLength(200)
- .IsRequired();
-
- builder.Property("_description")
- .HasColumnName("description")
- .HasMaxLength(1000);
-
- builder.Property("_createdAt")
- .HasColumnName("created_at")
- .IsRequired();
-
- builder.Property("_updatedAt")
- .HasColumnName("updated_at");
-
- // EN: Status relationship / VI: Quan hệ với Status
- builder.Property(s => s.StatusId)
- .HasColumnName("status_id")
- .IsRequired();
-
- builder.HasOne(s => s.Status)
- .WithMany()
- .HasForeignKey(s => s.StatusId)
- .OnDelete(DeleteBehavior.Restrict);
-
- // EN: Indexes / VI: Các index
- builder.HasIndex("_name");
- builder.HasIndex(s => s.StatusId);
- builder.HasIndex("_createdAt");
- }
-}
diff --git a/services/fnb-engine-net/src/FnbEngine.Infrastructure/EntityConfigurations/SampleStatusEntityTypeConfiguration.cs b/services/fnb-engine-net/src/FnbEngine.Infrastructure/EntityConfigurations/SampleStatusEntityTypeConfiguration.cs
deleted file mode 100644
index 73bdd15d..00000000
--- a/services/fnb-engine-net/src/FnbEngine.Infrastructure/EntityConfigurations/SampleStatusEntityTypeConfiguration.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Metadata.Builders;
-using FnbEngine.Domain.AggregatesModel.SampleAggregate;
-
-namespace FnbEngine.Infrastructure.EntityConfigurations;
-
-///
-/// EN: EF Core configuration for SampleStatus enumeration.
-/// VI: Cấu hình EF Core cho enumeration SampleStatus.
-///
-public class SampleStatusEntityTypeConfiguration : IEntityTypeConfiguration
-{
- public void Configure(EntityTypeBuilder builder)
- {
- // EN: Table name / VI: Tên bảng
- builder.ToTable("sample_statuses");
-
- // EN: Primary key / VI: Khóa chính
- builder.HasKey(s => s.Id);
-
- builder.Property(s => s.Id)
- .HasColumnName("id")
- .ValueGeneratedNever()
- .IsRequired();
-
- builder.Property(s => s.Name)
- .HasColumnName("name")
- .HasMaxLength(50)
- .IsRequired();
-
- // EN: Seed initial data / VI: Seed dữ liệu ban đầu
- builder.HasData(
- SampleStatus.Draft,
- SampleStatus.Active,
- SampleStatus.Completed,
- SampleStatus.Cancelled
- );
- }
-}
diff --git a/services/fnb-engine-net/src/FnbEngine.Infrastructure/EntityConfigurations/TableEntityTypeConfiguration.cs b/services/fnb-engine-net/src/FnbEngine.Infrastructure/EntityConfigurations/TableEntityTypeConfiguration.cs
new file mode 100644
index 00000000..34b281eb
--- /dev/null
+++ b/services/fnb-engine-net/src/FnbEngine.Infrastructure/EntityConfigurations/TableEntityTypeConfiguration.cs
@@ -0,0 +1,45 @@
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Metadata.Builders;
+using FnbEngine.Domain.AggregatesModel.TableAggregate;
+
+namespace FnbEngine.Infrastructure.EntityConfigurations;
+
+public class TableEntityTypeConfiguration : IEntityTypeConfiguration
+{
+ public void Configure(EntityTypeBuilder builder)
+ {
+ builder.ToTable("tables");
+ builder.HasKey(t => t.Id);
+ builder.Property(t => t.Id).HasColumnName("id").ValueGeneratedNever();
+ builder.Property("_shopId").HasColumnName("shop_id").IsRequired();
+ builder.Property("_tableNumber").HasColumnName("table_number").HasMaxLength(20).IsRequired();
+ builder.Property(t => t.StatusId).HasColumnName("status_id").IsRequired();
+ builder.Property("_capacity").HasColumnName("capacity").IsRequired();
+ builder.Property("_location").HasColumnName("location").HasMaxLength(100);
+
+ builder.OwnsMany(t => t.Sessions, s =>
+ {
+ s.ToTable("table_sessions");
+ s.WithOwner().HasForeignKey("TableId");
+ s.Property("TableId").HasColumnName("table_id");
+ s.HasKey(x => x.Id);
+ s.Property(x => x.Id).HasColumnName("id").ValueGeneratedNever();
+ s.Property("_orderId").HasColumnName("order_id");
+ s.Property("_startTime").HasColumnName("start_time").IsRequired();
+ s.Property("_endTime").HasColumnName("end_time");
+ s.Property("_isActive").HasColumnName("is_active").IsRequired();
+ s.Ignore(x => x.OrderId);
+ s.Ignore(x => x.StartTime);
+ s.Ignore(x => x.EndTime);
+ s.Ignore(x => x.IsActive);
+ });
+
+ builder.HasIndex("_shopId").HasDatabaseName("ix_tables_shop_id");
+ builder.HasIndex("_tableNumber").HasDatabaseName("ix_tables_table_number");
+ builder.Ignore(t => t.ShopId);
+ builder.Ignore(t => t.TableNumber);
+ builder.Ignore(t => t.Status);
+ builder.Ignore(t => t.Capacity);
+ builder.Ignore(t => t.Location);
+ }
+}
diff --git a/services/fnb-engine-net/src/FnbEngine.Infrastructure/EntityConfigurations/TableStatusEntityTypeConfiguration.cs b/services/fnb-engine-net/src/FnbEngine.Infrastructure/EntityConfigurations/TableStatusEntityTypeConfiguration.cs
new file mode 100644
index 00000000..1a020a18
--- /dev/null
+++ b/services/fnb-engine-net/src/FnbEngine.Infrastructure/EntityConfigurations/TableStatusEntityTypeConfiguration.cs
@@ -0,0 +1,17 @@
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Metadata.Builders;
+using FnbEngine.Domain.AggregatesModel.TableAggregate;
+
+namespace FnbEngine.Infrastructure.EntityConfigurations;
+
+public class TableStatusEntityTypeConfiguration : IEntityTypeConfiguration
+{
+ public void Configure(EntityTypeBuilder builder)
+ {
+ builder.ToTable("table_statuses");
+ builder.HasKey(s => s.Id);
+ builder.Property(s => s.Id).HasColumnName("id").ValueGeneratedNever();
+ builder.Property(s => s.Name).HasColumnName("name").HasMaxLength(50).IsRequired();
+ builder.HasData(TableStatus.Available, TableStatus.Occupied, TableStatus.Reserved, TableStatus.Cleaning);
+ }
+}
diff --git a/services/fnb-engine-net/src/FnbEngine.Infrastructure/FnbContext.cs b/services/fnb-engine-net/src/FnbEngine.Infrastructure/FnbContext.cs
new file mode 100644
index 00000000..6cbcc0ce
--- /dev/null
+++ b/services/fnb-engine-net/src/FnbEngine.Infrastructure/FnbContext.cs
@@ -0,0 +1,67 @@
+using MediatR;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Storage;
+using FnbEngine.Domain.AggregatesModel.TableAggregate;
+using FnbEngine.Domain.SeedWork;
+using FnbEngine.Infrastructure.EntityConfigurations;
+
+namespace FnbEngine.Infrastructure;
+
+public class FnbContext : DbContext, IUnitOfWork
+{
+ private readonly IMediator _mediator;
+ private IDbContextTransaction? _currentTransaction;
+
+ public DbSet Tables => Set();
+ public IDbContextTransaction? CurrentTransaction => _currentTransaction;
+ public bool HasActiveTransaction => _currentTransaction != null;
+
+ public FnbContext(DbContextOptions options, IMediator mediator) : base(options)
+ {
+ _mediator = mediator ?? throw new ArgumentNullException(nameof(mediator));
+ }
+
+ protected override void OnModelCreating(ModelBuilder modelBuilder)
+ {
+ modelBuilder.ApplyConfiguration(new TableEntityTypeConfiguration());
+ modelBuilder.ApplyConfiguration(new TableStatusEntityTypeConfiguration());
+ }
+
+ public async Task SaveEntitiesAsync(CancellationToken cancellationToken = default)
+ {
+ await DispatchDomainEventsAsync();
+ await base.SaveChangesAsync(cancellationToken);
+ return true;
+ }
+
+ public async Task BeginTransactionAsync()
+ {
+ if (_currentTransaction != null) return null;
+ _currentTransaction = await Database.BeginTransactionAsync(System.Data.IsolationLevel.ReadCommitted);
+ return _currentTransaction;
+ }
+
+ public async Task CommitTransactionAsync(IDbContextTransaction transaction)
+ {
+ ArgumentNullException.ThrowIfNull(transaction);
+ if (transaction != _currentTransaction)
+ throw new InvalidOperationException($"Transaction {transaction.TransactionId} is not current");
+ try { await SaveChangesAsync(); await transaction.CommitAsync(); }
+ catch { RollbackTransaction(); throw; }
+ finally { if (_currentTransaction != null) { _currentTransaction.Dispose(); _currentTransaction = null; } }
+ }
+
+ public void RollbackTransaction()
+ {
+ try { _currentTransaction?.Rollback(); }
+ finally { if (_currentTransaction != null) { _currentTransaction.Dispose(); _currentTransaction = null; } }
+ }
+
+ private async Task DispatchDomainEventsAsync()
+ {
+ var domainEntities = ChangeTracker.Entries().Where(x => x.Entity.DomainEvents.Any()).ToList();
+ var domainEvents = domainEntities.SelectMany(x => x.Entity.DomainEvents).ToList();
+ domainEntities.ForEach(entity => entity.Entity.ClearDomainEvents());
+ foreach (var domainEvent in domainEvents) await _mediator.Publish(domainEvent);
+ }
+}
diff --git a/services/fnb-engine-net/src/FnbEngine.Infrastructure/MyServiceContext.cs b/services/fnb-engine-net/src/FnbEngine.Infrastructure/MyServiceContext.cs
deleted file mode 100644
index c130434f..00000000
--- a/services/fnb-engine-net/src/FnbEngine.Infrastructure/MyServiceContext.cs
+++ /dev/null
@@ -1,160 +0,0 @@
-using MediatR;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Storage;
-using FnbEngine.Domain.AggregatesModel.SampleAggregate;
-using FnbEngine.Domain.SeedWork;
-using FnbEngine.Infrastructure.EntityConfigurations;
-
-namespace FnbEngine.Infrastructure;
-
-///
-/// EN: EF Core DbContext for FnbEngine.
-/// VI: EF Core DbContext cho FnbEngine.
-///
-public class FnbEngineContext : DbContext, IUnitOfWork
-{
- private readonly IMediator _mediator;
- private IDbContextTransaction? _currentTransaction;
-
- ///
- /// EN: Samples table.
- /// VI: Bảng Samples.
- ///
- public DbSet Samples => Set();
-
- ///
- /// EN: Read-only access to current transaction.
- /// VI: Truy cập chỉ đọc đến transaction hiện tại.
- ///
- public IDbContextTransaction? CurrentTransaction => _currentTransaction;
-
- ///
- /// EN: Check if there is an active transaction.
- /// VI: Kiểm tra xem có transaction đang hoạt động không.
- ///
- public bool HasActiveTransaction => _currentTransaction != null;
-
- public FnbEngineContext(DbContextOptions options) : base(options)
- {
- _mediator = null!;
- }
-
- public FnbEngineContext(DbContextOptions options, IMediator mediator) : base(options)
- {
- _mediator = mediator ?? throw new ArgumentNullException(nameof(mediator));
-
- System.Diagnostics.Debug.WriteLine("FnbEngineContext::ctor - " + GetHashCode());
- }
-
- protected override void OnModelCreating(ModelBuilder modelBuilder)
- {
- // EN: Apply entity configurations
- // VI: Áp dụng các cấu hình entity
- modelBuilder.ApplyConfiguration(new SampleEntityTypeConfiguration());
- modelBuilder.ApplyConfiguration(new SampleStatusEntityTypeConfiguration());
- }
-
- ///
- /// EN: Save entities and dispatch domain events.
- /// VI: Lưu entities và dispatch domain events.
- ///
- public async Task SaveEntitiesAsync(CancellationToken cancellationToken = default)
- {
- // EN: Dispatch domain events before saving (side effects)
- // VI: Dispatch domain events trước khi lưu (side effects)
- await DispatchDomainEventsAsync();
-
- // EN: Save changes to database
- // VI: Lưu thay đổi vào database
- await base.SaveChangesAsync(cancellationToken);
-
- return true;
- }
-
- ///
- /// EN: Begin a new transaction if none is active.
- /// VI: Bắt đầu một transaction mới nếu không có transaction nào đang hoạt động.
- ///
- public async Task BeginTransactionAsync()
- {
- if (_currentTransaction != null) return null;
-
- _currentTransaction = await Database.BeginTransactionAsync(System.Data.IsolationLevel.ReadCommitted);
-
- return _currentTransaction;
- }
-
- ///
- /// EN: Commit the current transaction.
- /// VI: Commit transaction hiện tại.
- ///
- public async Task CommitTransactionAsync(IDbContextTransaction transaction)
- {
- ArgumentNullException.ThrowIfNull(transaction);
-
- if (transaction != _currentTransaction)
- throw new InvalidOperationException($"Transaction {transaction.TransactionId} is not current");
-
- try
- {
- await SaveChangesAsync();
- await transaction.CommitAsync();
- }
- catch
- {
- RollbackTransaction();
- throw;
- }
- finally
- {
- if (_currentTransaction != null)
- {
- _currentTransaction.Dispose();
- _currentTransaction = null;
- }
- }
- }
-
- ///
- /// EN: Rollback the current transaction.
- /// VI: Rollback transaction hiện tại.
- ///
- public void RollbackTransaction()
- {
- try
- {
- _currentTransaction?.Rollback();
- }
- finally
- {
- if (_currentTransaction != null)
- {
- _currentTransaction.Dispose();
- _currentTransaction = null;
- }
- }
- }
-
- ///
- /// EN: Dispatch all domain events from tracked entities.
- /// VI: Dispatch tất cả domain events từ các entities đang được track.
- ///
- private async Task DispatchDomainEventsAsync()
- {
- var domainEntities = ChangeTracker
- .Entries()
- .Where(x => x.Entity.DomainEvents.Any())
- .ToList();
-
- var domainEvents = domainEntities
- .SelectMany(x => x.Entity.DomainEvents)
- .ToList();
-
- domainEntities.ForEach(entity => entity.Entity.ClearDomainEvents());
-
- foreach (var domainEvent in domainEvents)
- {
- await _mediator.Publish(domainEvent);
- }
- }
-}
diff --git a/services/fnb-engine-net/src/FnbEngine.Infrastructure/Repositories/SampleRepository.cs b/services/fnb-engine-net/src/FnbEngine.Infrastructure/Repositories/SampleRepository.cs
deleted file mode 100644
index 57b09f76..00000000
--- a/services/fnb-engine-net/src/FnbEngine.Infrastructure/Repositories/SampleRepository.cs
+++ /dev/null
@@ -1,72 +0,0 @@
-using Microsoft.EntityFrameworkCore;
-using FnbEngine.Domain.AggregatesModel.SampleAggregate;
-using FnbEngine.Domain.SeedWork;
-
-namespace FnbEngine.Infrastructure.Repositories;
-
-///
-/// EN: Repository implementation for Sample aggregate.
-/// VI: Triển khai repository cho Sample aggregate.
-///
-public class SampleRepository : ISampleRepository
-{
- private readonly FnbEngineContext _context;
-
- ///
- /// EN: Unit of work for transaction management.
- /// VI: Unit of work cho quản lý transaction.
- ///
- public IUnitOfWork UnitOfWork => _context;
-
- public SampleRepository(FnbEngineContext context)
- {
- _context = context ?? throw new ArgumentNullException(nameof(context));
- }
-
- ///
- public async Task GetAsync(Guid sampleId)
- {
- var sample = await _context.Samples
- .Include(s => s.Status)
- .FirstOrDefaultAsync(s => s.Id == sampleId);
-
- return sample;
- }
-
- ///
- public async Task> GetAllAsync()
- {
- return await _context.Samples
- .Include(s => s.Status)
- .OrderByDescending(s => s.CreatedAt)
- .ToListAsync();
- }
-
- ///
- public Sample Add(Sample sample)
- {
- return _context.Samples.Add(sample).Entity;
- }
-
- ///
- public void Update(Sample sample)
- {
- _context.Entry(sample).State = EntityState.Modified;
- }
-
- ///
- public void Delete(Sample sample)
- {
- _context.Samples.Remove(sample);
- }
-
- ///
- public async Task> GetByStatusAsync(int statusId)
- {
- return await _context.Samples
- .Include(s => s.Status)
- .Where(s => s.StatusId == statusId)
- .OrderByDescending(s => s.CreatedAt)
- .ToListAsync();
- }
-}
diff --git a/services/inventory-service-net/src/InventoryService.Domain/AggregatesModel/InventoryAggregate/IInventoryRepository.cs b/services/inventory-service-net/src/InventoryService.Domain/AggregatesModel/InventoryAggregate/IInventoryRepository.cs
new file mode 100644
index 00000000..e8dce754
--- /dev/null
+++ b/services/inventory-service-net/src/InventoryService.Domain/AggregatesModel/InventoryAggregate/IInventoryRepository.cs
@@ -0,0 +1,43 @@
+// EN: Inventory repository interface.
+// VI: Interface repository Inventory.
+
+using InventoryService.Domain.SeedWork;
+
+namespace InventoryService.Domain.AggregatesModel.InventoryAggregate;
+
+///
+/// EN: Repository interface for InventoryItem aggregate.
+/// VI: Interface repository cho InventoryItem aggregate.
+///
+public interface IInventoryRepository : IRepository
+{
+ ///
+ /// EN: Add a new inventory item.
+ /// VI: Thêm inventory item mới.
+ ///
+ InventoryItem Add(InventoryItem item);
+
+ ///
+ /// EN: Update an inventory item.
+ /// VI: Cập nhật inventory item.
+ ///
+ void Update(InventoryItem item);
+
+ ///
+ /// EN: Get inventory item by ID.
+ /// VI: Lấy inventory item theo ID.
+ ///
+ Task GetByIdAsync(Guid id, CancellationToken cancellationToken = default);
+
+ ///
+ /// EN: Get inventory item by product ID and shop ID.
+ /// VI: Lấy inventory item theo product ID và shop ID.
+ ///
+ Task GetByProductIdAsync(Guid productId, Guid shopId, CancellationToken cancellationToken = default);
+
+ ///
+ /// EN: Get all inventory items for a shop.
+ /// VI: Lấy tất cả inventory items cho một shop.
+ ///
+ Task> GetByShopIdAsync(Guid shopId, CancellationToken cancellationToken = default);
+}
diff --git a/services/inventory-service-net/src/InventoryService.Infrastructure/EntityConfigurations/SampleEntityTypeConfiguration.cs b/services/inventory-service-net/src/InventoryService.Infrastructure/EntityConfigurations/SampleEntityTypeConfiguration.cs
deleted file mode 100644
index b95ebf32..00000000
--- a/services/inventory-service-net/src/InventoryService.Infrastructure/EntityConfigurations/SampleEntityTypeConfiguration.cs
+++ /dev/null
@@ -1,61 +0,0 @@
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Metadata.Builders;
-using InventoryService.Domain.AggregatesModel.SampleAggregate;
-
-namespace InventoryService.Infrastructure.EntityConfigurations;
-
-///
-/// EN: EF Core configuration for Sample entity.
-/// VI: Cấu hình EF Core cho entity Sample.
-///
-public class SampleEntityTypeConfiguration : IEntityTypeConfiguration
-{
- public void Configure(EntityTypeBuilder builder)
- {
- // EN: Table name / VI: Tên bảng
- builder.ToTable("samples");
-
- // EN: Primary key / VI: Khóa chính
- builder.HasKey(s => s.Id);
-
- // EN: Ignore domain events (not persisted)
- // VI: Bỏ qua domain events (không lưu)
- builder.Ignore(s => s.DomainEvents);
-
- // EN: Properties / VI: Các thuộc tính
- builder.Property(s => s.Id)
- .HasColumnName("id")
- .IsRequired();
-
- builder.Property("_name")
- .HasColumnName("name")
- .HasMaxLength(200)
- .IsRequired();
-
- builder.Property("_description")
- .HasColumnName("description")
- .HasMaxLength(1000);
-
- builder.Property("_createdAt")
- .HasColumnName("created_at")
- .IsRequired();
-
- builder.Property("_updatedAt")
- .HasColumnName("updated_at");
-
- // EN: Status relationship / VI: Quan hệ với Status
- builder.Property(s => s.StatusId)
- .HasColumnName("status_id")
- .IsRequired();
-
- builder.HasOne(s => s.Status)
- .WithMany()
- .HasForeignKey(s => s.StatusId)
- .OnDelete(DeleteBehavior.Restrict);
-
- // EN: Indexes / VI: Các index
- builder.HasIndex("_name");
- builder.HasIndex(s => s.StatusId);
- builder.HasIndex("_createdAt");
- }
-}
diff --git a/services/inventory-service-net/src/InventoryService.Infrastructure/EntityConfigurations/SampleStatusEntityTypeConfiguration.cs b/services/inventory-service-net/src/InventoryService.Infrastructure/EntityConfigurations/SampleStatusEntityTypeConfiguration.cs
deleted file mode 100644
index c3a632b2..00000000
--- a/services/inventory-service-net/src/InventoryService.Infrastructure/EntityConfigurations/SampleStatusEntityTypeConfiguration.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Metadata.Builders;
-using InventoryService.Domain.AggregatesModel.SampleAggregate;
-
-namespace InventoryService.Infrastructure.EntityConfigurations;
-
-///
-/// EN: EF Core configuration for SampleStatus enumeration.
-/// VI: Cấu hình EF Core cho enumeration SampleStatus.
-///
-public class SampleStatusEntityTypeConfiguration : IEntityTypeConfiguration
-{
- public void Configure(EntityTypeBuilder builder)
- {
- // EN: Table name / VI: Tên bảng
- builder.ToTable("sample_statuses");
-
- // EN: Primary key / VI: Khóa chính
- builder.HasKey(s => s.Id);
-
- builder.Property(s => s.Id)
- .HasColumnName("id")
- .ValueGeneratedNever()
- .IsRequired();
-
- builder.Property(s => s.Name)
- .HasColumnName("name")
- .HasMaxLength(50)
- .IsRequired();
-
- // EN: Seed initial data / VI: Seed dữ liệu ban đầu
- builder.HasData(
- SampleStatus.Draft,
- SampleStatus.Active,
- SampleStatus.Completed,
- SampleStatus.Cancelled
- );
- }
-}
diff --git a/services/inventory-service-net/src/InventoryService.Infrastructure/Repositories/SampleRepository.cs b/services/inventory-service-net/src/InventoryService.Infrastructure/Repositories/SampleRepository.cs
deleted file mode 100644
index 8d67e52e..00000000
--- a/services/inventory-service-net/src/InventoryService.Infrastructure/Repositories/SampleRepository.cs
+++ /dev/null
@@ -1,72 +0,0 @@
-using Microsoft.EntityFrameworkCore;
-using InventoryService.Domain.AggregatesModel.SampleAggregate;
-using InventoryService.Domain.SeedWork;
-
-namespace InventoryService.Infrastructure.Repositories;
-
-///
-/// EN: Repository implementation for Sample aggregate.
-/// VI: Triển khai repository cho Sample aggregate.
-///
-public class SampleRepository : ISampleRepository
-{
- private readonly InventoryServiceContext _context;
-
- ///
- /// EN: Unit of work for transaction management.
- /// VI: Unit of work cho quản lý transaction.
- ///
- public IUnitOfWork UnitOfWork => _context;
-
- public SampleRepository(InventoryServiceContext context)
- {
- _context = context ?? throw new ArgumentNullException(nameof(context));
- }
-
- ///
- public async Task GetAsync(Guid sampleId)
- {
- var sample = await _context.Samples
- .Include(s => s.Status)
- .FirstOrDefaultAsync(s => s.Id == sampleId);
-
- return sample;
- }
-
- ///
- public async Task> GetAllAsync()
- {
- return await _context.Samples
- .Include(s => s.Status)
- .OrderByDescending(s => s.CreatedAt)
- .ToListAsync();
- }
-
- ///
- public Sample Add(Sample sample)
- {
- return _context.Samples.Add(sample).Entity;
- }
-
- ///
- public void Update(Sample sample)
- {
- _context.Entry(sample).State = EntityState.Modified;
- }
-
- ///
- public void Delete(Sample sample)
- {
- _context.Samples.Remove(sample);
- }
-
- ///
- public async Task> GetByStatusAsync(int statusId)
- {
- return await _context.Samples
- .Include(s => s.Status)
- .Where(s => s.StatusId == statusId)
- .OrderByDescending(s => s.CreatedAt)
- .ToListAsync();
- }
-}