|
@@ -144,6 +144,66 @@ namespace MTWorkHR.Application.Services
|
|
|
response.IsCheckedOut = attendance != null && attendance.CheckOutTime.HasValue;
|
|
|
return response;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ public async Task<EmployeeInfoDto> GetEmployeeInfo(string id)
|
|
|
+ {
|
|
|
+ var entity = await _userManager.Users
|
|
|
+ .Include(x => x.UserRoles)
|
|
|
+ .Include(x => x.UserAddress).ThenInclude(x => x.City)
|
|
|
+ .Include(x => x.UserAddress).ThenInclude(x => x.Country)
|
|
|
+ .Include(x => x.UserAttachments)
|
|
|
+ .Include(x => x.JobTitle)
|
|
|
+ .Include(x => x.Industry)
|
|
|
+ .Include(x => x.University)
|
|
|
+ .Include(x => x.Country)
|
|
|
+ .Include(x => x.Qualification)
|
|
|
+ .FirstOrDefaultAsync(x => x.Id == id);
|
|
|
+ if(entity == null)
|
|
|
+ {
|
|
|
+ throw new AppException(ExceptionEnum.RecordNotExist);
|
|
|
+ }
|
|
|
+ var response = MapperObject.Mapper.Map<EmployeeInfoDto>(entity);
|
|
|
+ if (entity.UserAttachments != null)
|
|
|
+ foreach (var attach in entity.UserAttachments.Where(a => a.Content != null))
|
|
|
+ {
|
|
|
+ //var stream = new MemoryStream(attach.Content);
|
|
|
+ //IFormFile file = new FormFile(stream, 0, stream.Length, Path.GetFileNameWithoutExtension(attach.FileName), attach.FileName);
|
|
|
+
|
|
|
+ using (var stream = new MemoryStream(attach.Content))
|
|
|
+ {
|
|
|
+ var file = new FormFile(stream, 0, stream.Length, Path.GetFileNameWithoutExtension(attach.FileName), attach.FilePath)
|
|
|
+ {
|
|
|
+ Headers = new HeaderDictionary(),
|
|
|
+ ContentType = attach.ContentType,
|
|
|
+
|
|
|
+ };
|
|
|
+ System.Net.Mime.ContentDisposition cd = new System.Net.Mime.ContentDisposition
|
|
|
+ {
|
|
|
+ FileName = file.FileName
|
|
|
+ };
|
|
|
+ file.ContentDisposition = cd.ToString();
|
|
|
+ switch (attach.AttachmentTypeId)
|
|
|
+ {
|
|
|
+ case 1:
|
|
|
+ response.CVAttach = file;
|
|
|
+ break;
|
|
|
+ case 4:
|
|
|
+ response.ExperienceCertificateAttach = file;
|
|
|
+ break;
|
|
|
+ case 5:
|
|
|
+ response.ProfCertificateAttach = file;
|
|
|
+ break;
|
|
|
+ case 9:
|
|
|
+ response.ProfileImage = file;
|
|
|
+ response.ProfileImagePath = attach.FilePath;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ attach.Content = new byte[0];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return response;
|
|
|
+ }
|
|
|
public async Task<UserDto> GetUserById(string id)
|
|
|
{
|
|
|
var entity = await _userManager.Users
|