120 lines
5.5 KiB
C#
120 lines
5.5 KiB
C#
using Indotalent.Infrastructure.Database;
|
|
using MediatR;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace Indotalent.Features.Organization.Employee.Cqrs;
|
|
|
|
public class GetEmployeeByIdResponse
|
|
{
|
|
public string Id { get; set; } = string.Empty;
|
|
public string? AutoNumber { get; set; }
|
|
public string Code { get; set; } = string.Empty;
|
|
public string FirstName { get; set; } = string.Empty;
|
|
public string MiddleName { get; set; } = string.Empty;
|
|
public string LastName { get; set; } = string.Empty;
|
|
public string JobDescription { get; set; } = string.Empty;
|
|
public string? GradeId { get; set; }
|
|
public decimal BasicSalary { get; set; }
|
|
public string SalaryBankName { get; set; } = string.Empty;
|
|
public string SalaryBankAccountName { get; set; } = string.Empty;
|
|
public string SalaryBankAccountNumber { get; set; } = string.Empty;
|
|
public string PlaceOfBirth { get; set; } = string.Empty;
|
|
public DateTime? DateOfBirth { get; set; }
|
|
public string Gender { get; set; } = string.Empty;
|
|
public string MaritalStatus { get; set; } = string.Empty;
|
|
public string Religion { get; set; } = string.Empty;
|
|
public string BloodType { get; set; } = string.Empty;
|
|
public string IdentityNumber { get; set; } = string.Empty;
|
|
public string TaxNumber { get; set; } = string.Empty;
|
|
public string LastEducation { get; set; } = string.Empty;
|
|
public DateTime? JoinedDate { get; set; }
|
|
public DateTime? ResignedDate { get; set; }
|
|
public string EmployeeStatus { get; set; } = string.Empty;
|
|
public string EmploymentType { get; set; } = string.Empty;
|
|
public string StreetAddress { get; set; } = string.Empty;
|
|
public string City { get; set; } = string.Empty;
|
|
public string StateProvince { get; set; } = string.Empty;
|
|
public string ZipCode { get; set; } = string.Empty;
|
|
public string Phone { get; set; } = string.Empty;
|
|
public string Email { get; set; } = string.Empty;
|
|
public string BranchId { get; set; } = string.Empty;
|
|
public string DepartmentId { get; set; } = string.Empty;
|
|
public string DesignationId { get; set; } = string.Empty;
|
|
public string SocialMediaLinkedIn { get; set; } = string.Empty;
|
|
public string SocialMediaX { get; set; } = string.Empty;
|
|
public string SocialMediaFacebook { get; set; } = string.Empty;
|
|
public string SocialMediaInstagram { get; set; } = string.Empty;
|
|
public string SocialMediaTikTok { get; set; } = string.Empty;
|
|
public string OtherInformation1 { get; set; } = string.Empty;
|
|
public string OtherInformation2 { get; set; } = string.Empty;
|
|
public string OtherInformation3 { get; set; } = string.Empty;
|
|
public DateTimeOffset? CreatedAt { get; set; }
|
|
public string? CreatedBy { get; set; }
|
|
public DateTimeOffset? UpdatedAt { get; set; }
|
|
public string? UpdatedBy { get; set; }
|
|
}
|
|
|
|
public record GetEmployeeByIdQuery(string Id) : IRequest<GetEmployeeByIdResponse?>;
|
|
|
|
public class GetEmployeeByIdHandler : IRequestHandler<GetEmployeeByIdQuery, GetEmployeeByIdResponse?>
|
|
{
|
|
private readonly AppDbContext _context;
|
|
public GetEmployeeByIdHandler(AppDbContext context) => _context = context;
|
|
|
|
public async Task<GetEmployeeByIdResponse?> Handle(GetEmployeeByIdQuery request, CancellationToken cancellationToken)
|
|
{
|
|
return await _context.Employee
|
|
.AsNoTracking()
|
|
.Where(x => x.Id == request.Id)
|
|
.Select(x => new GetEmployeeByIdResponse
|
|
{
|
|
Id = x.Id,
|
|
AutoNumber = x.AutoNumber,
|
|
Code = x.Code,
|
|
FirstName = x.FirstName,
|
|
MiddleName = x.MiddleName,
|
|
LastName = x.LastName,
|
|
JobDescription = x.JobDescription,
|
|
GradeId = x.GradeId,
|
|
BasicSalary = x.BasicSalary,
|
|
SalaryBankName = x.SalaryBankName,
|
|
SalaryBankAccountName = x.SalaryBankAccountName,
|
|
SalaryBankAccountNumber = x.SalaryBankAccountNumber,
|
|
PlaceOfBirth = x.PlaceOfBirth,
|
|
DateOfBirth = x.DateOfBirth,
|
|
Gender = x.Gender,
|
|
MaritalStatus = x.MaritalStatus,
|
|
Religion = x.Religion,
|
|
BloodType = x.BloodType,
|
|
IdentityNumber = x.IdentityNumber,
|
|
TaxNumber = x.TaxNumber,
|
|
LastEducation = x.LastEducation,
|
|
JoinedDate = x.JoinedDate,
|
|
ResignedDate = x.ResignedDate,
|
|
EmployeeStatus = x.EmployeeStatus,
|
|
EmploymentType = x.EmploymentType,
|
|
StreetAddress = x.StreetAddress,
|
|
City = x.City,
|
|
StateProvince = x.StateProvince,
|
|
ZipCode = x.ZipCode,
|
|
Phone = x.Phone,
|
|
Email = x.Email,
|
|
BranchId = x.BranchId,
|
|
DepartmentId = x.DepartmentId,
|
|
DesignationId = x.DesignationId,
|
|
SocialMediaLinkedIn = x.SocialMediaLinkedIn,
|
|
SocialMediaX = x.SocialMediaX,
|
|
SocialMediaFacebook = x.SocialMediaFacebook,
|
|
SocialMediaInstagram = x.SocialMediaInstagram,
|
|
SocialMediaTikTok = x.SocialMediaTikTok,
|
|
OtherInformation1 = x.OtherInformation1,
|
|
OtherInformation2 = x.OtherInformation2,
|
|
OtherInformation3 = x.OtherInformation3,
|
|
CreatedAt = x.CreatedAt,
|
|
CreatedBy = x.CreatedBy,
|
|
UpdatedAt = x.UpdatedAt,
|
|
UpdatedBy = x.UpdatedBy
|
|
})
|
|
.FirstOrDefaultAsync(cancellationToken);
|
|
}
|
|
} |