initial commit

This commit is contained in:
2026-07-21 14:08:10 +07:00
commit f7cf118326
533 changed files with 41762 additions and 0 deletions
@@ -0,0 +1,55 @@
using Indotalent.Infrastructure.Database;
using MediatR;
using Microsoft.EntityFrameworkCore;
namespace Indotalent.Features.Organization.Department.Cqrs;
public class GetDepartmentByIdResponse
{
public string? Id { get; set; }
public string? AutoNumber { get; set; }
public string? CostCenter { get; set; }
public string? Name { get; set; }
public string? Description { get; set; }
public string? HeadOfDeptartment { get; set; }
public string? OtherInformation1 { get; set; }
public string? OtherInformation2 { get; set; }
public string? OtherInformation3 { get; set; }
public DateTimeOffset? CreatedAt { get; set; }
public string? CreatedBy { get; set; }
public DateTimeOffset? UpdatedAt { get; set; }
public string? UpdatedBy { get; set; }
}
public record GetDepartmentByIdQuery(string Id) : IRequest<GetDepartmentByIdResponse?>;
public class GetDepartmentByIdHandler : IRequestHandler<GetDepartmentByIdQuery, GetDepartmentByIdResponse?>
{
private readonly AppDbContext _context;
public GetDepartmentByIdHandler(AppDbContext context) => _context = context;
public async Task<GetDepartmentByIdResponse?> Handle(GetDepartmentByIdQuery request, CancellationToken cancellationToken)
{
return await _context.Department
.AsNoTracking()
.Where(x => x.Id == request.Id)
.Select(x => new GetDepartmentByIdResponse
{
Id = x.Id,
AutoNumber = x.AutoNumber,
CostCenter = x.CostCenter,
Name = x.Name,
Description = x.Description,
HeadOfDeptartment = x.HeadOfDeptartment,
OtherInformation1 = x.OtherInformation1,
OtherInformation2 = x.OtherInformation2,
OtherInformation3 = x.OtherInformation3,
CreatedAt = x.CreatedAt,
CreatedBy = x.CreatedBy,
UpdatedAt = x.UpdatedAt,
UpdatedBy = x.UpdatedBy
})
.FirstOrDefaultAsync(cancellationToken);
}
}