Add GetOCStaffAsync method to UserProfileRepository and create GetOcStaff response models
This commit is contained in:
parent
d3cc0781cf
commit
4f18a97d0b
3 changed files with 158 additions and 5 deletions
|
|
@ -6,6 +6,7 @@ using BMA.EHR.Application.Repositories.MessageQueue;
|
|||
using BMA.EHR.Application.Responses.Profiles;
|
||||
using BMA.EHR.Domain.Common;
|
||||
using BMA.EHR.Domain.Models.Leave.TimeAttendants;
|
||||
using BMA.EHR.Domain.Models.Notifications;
|
||||
using BMA.EHR.Domain.Shared;
|
||||
using BMA.EHR.Infrastructure.Persistence;
|
||||
using BMA.EHR.Leave.Service.DTOs.AdditionalCheck;
|
||||
|
|
@ -46,6 +47,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
private readonly DutyTimeRepository _dutyTimeRepository;
|
||||
private readonly LeaveDbContext _context;
|
||||
private readonly ApplicationDBContext _appDbContext;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly IWebHostEnvironment _hostingEnvironment;
|
||||
private readonly IConfiguration _configuration;
|
||||
|
|
@ -94,10 +96,12 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
PermissionRepository permission,
|
||||
NotificationRepository notificationRepository,
|
||||
CheckInJobStatusRepository checkInJobStatusRepository,
|
||||
HttpClient httpClient)
|
||||
HttpClient httpClient,
|
||||
ApplicationDBContext appDbContext)
|
||||
{
|
||||
_dutyTimeRepository = dutyTimeRepository;
|
||||
_context = context;
|
||||
_appDbContext = appDbContext;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_hostingEnvironment = hostingEnvironment;
|
||||
_configuration = configuration;
|
||||
|
|
@ -928,16 +932,31 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
if (profile == null)
|
||||
{
|
||||
await _checkInJobStatusRepository.UpdateToFailedAsync(taskId, "ไม่พบข้อมูลผู้ใช้");
|
||||
//var staffList = await _userProfileRepository.GetOCStaffAsync(profile)
|
||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||
}
|
||||
|
||||
var currentDate = data.CurrentDate ?? DateTime.Now;
|
||||
|
||||
if (data.CheckInFileName == "no-file")
|
||||
{
|
||||
//throw new Exception(GlobalMessages.NoFileToUpload);
|
||||
await _checkInJobStatusRepository.UpdateToFailedAsync(taskId, GlobalMessages.NoFileToUpload);
|
||||
|
||||
// send notification to user
|
||||
var noti1 = new Notification
|
||||
{
|
||||
Body = $"ประมวลผลการลงเวลาวันที่ {currentDate.ToString("dd-MM-yyyy")} ไม่สำเร็จ \r\nเนื่องจาก {GlobalMessages.NoFileToUpload}",
|
||||
ReceiverUserId = profile.Id,
|
||||
Type = "",
|
||||
Payload = "",
|
||||
};
|
||||
_appDbContext.Set<Notification>().Add(noti1);
|
||||
await _appDbContext.SaveChangesAsync();
|
||||
|
||||
return Error(GlobalMessages.NoFileToUpload, StatusCodes.Status400BadRequest);
|
||||
}
|
||||
var currentDate = data.CurrentDate ?? DateTime.Now;
|
||||
|
||||
|
||||
var check_status = data.CheckInId == null ? "check-in-picture" : "check-out-picture";
|
||||
|
||||
|
|
@ -951,6 +970,19 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
catch (Exception ex)
|
||||
{
|
||||
await _checkInJobStatusRepository.UpdateToFailedAsync(taskId, $"ไม่สามารถอัปโหลดรูปภาพได้: {ex.Message}");
|
||||
|
||||
// send notification to user
|
||||
var noti1 = new Notification
|
||||
{
|
||||
Body = $"ประมวลผลการลงเวลาวันที่ {currentDate.ToString("dd-MM-yyyy")} ไม่สำเร็จ \r\nเนื่องจากไม่สามารถอัปโหลดรูปภาพได้ {ex.Message}",
|
||||
ReceiverUserId = profile.Id,
|
||||
Type = "",
|
||||
Payload = "",
|
||||
};
|
||||
_appDbContext.Set<Notification>().Add(noti1);
|
||||
await _appDbContext.SaveChangesAsync();
|
||||
|
||||
|
||||
return Error($"ไม่สามารถอัปโหลดรูปภาพได้: {ex.Message}", StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
|
||||
|
|
@ -960,6 +992,16 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
if (defaultRound == null)
|
||||
{
|
||||
await _checkInJobStatusRepository.UpdateToFailedAsync(taskId, "ไม่พบรอบการลงเวลาทำงาน Default");
|
||||
// send notification to user
|
||||
var noti1 = new Notification
|
||||
{
|
||||
Body = $"ประมวลผลการลงเวลาวันที่ {currentDate.ToString("dd-MM-yyyy")} ไม่สำเร็จ \r\nเนื่องจากไม่พบรอบการลงเวลาทำงาน Default",
|
||||
ReceiverUserId = profile.Id,
|
||||
Type = "",
|
||||
Payload = "",
|
||||
};
|
||||
_appDbContext.Set<Notification>().Add(noti1);
|
||||
await _appDbContext.SaveChangesAsync();
|
||||
return Error("ไม่พบรอบการลงเวลาทำงาน Default", StatusCodes.Status404NotFound);
|
||||
}
|
||||
|
||||
|
|
@ -979,6 +1021,18 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
if (currentCheckIn != null)
|
||||
{
|
||||
await _checkInJobStatusRepository.UpdateToFailedAsync(taskId, "ไม่สามารถลงเวลาได้ เนื่องจากมีการลงเวลาในวันนี้แล้ว");
|
||||
|
||||
// send notification to user
|
||||
var noti1 = new Notification
|
||||
{
|
||||
Body = $"ประมวลผลการลงเวลาวันที่ {currentDate.ToString("dd-MM-yyyy")} ไม่สำเร็จ \r\nเนื่องจากมีการลงเวลาในวันนี้แล้ว",
|
||||
ReceiverUserId = profile.Id,
|
||||
Type = "",
|
||||
Payload = "",
|
||||
};
|
||||
_appDbContext.Set<Notification>().Add(noti1);
|
||||
await _appDbContext.SaveChangesAsync();
|
||||
|
||||
return Error(new Exception("ไม่สามารถลงเวลาได้ เนื่องจากมีการลงเวลาในวันนี้แล้ว!"), StatusCodes.Status400BadRequest);
|
||||
}
|
||||
|
||||
|
|
@ -1117,6 +1171,18 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
if (checkout == null)
|
||||
{
|
||||
await _checkInJobStatusRepository.UpdateToFailedAsync(taskId, "ไม่พบข้อมูลการลงเวลาทำงาน");
|
||||
|
||||
// send notification to user
|
||||
var noti1 = new Notification
|
||||
{
|
||||
Body = $"ประมวลผลการลงเวลาวันที่ {currentDate.ToString("dd-MM-yyyy")} ไม่สำเร็จ \r\nเนื่องจากไม่พบข้อมูลการลงเวลาทำงาน",
|
||||
ReceiverUserId = profile.Id,
|
||||
Type = "",
|
||||
Payload = "",
|
||||
};
|
||||
_appDbContext.Set<Notification>().Add(noti1);
|
||||
await _appDbContext.SaveChangesAsync();
|
||||
|
||||
return Error(new Exception(GlobalMessages.DataNotFound), StatusCodes.Status404NotFound);
|
||||
}
|
||||
|
||||
|
|
@ -1125,6 +1191,18 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
if (currentCheckInProcess == null)
|
||||
{
|
||||
await _checkInJobStatusRepository.UpdateToFailedAsync(taskId, "ไม่พบข้อมูลการประมวลผลเวลาทำงาน (CheckIn)");
|
||||
|
||||
// send notification to user
|
||||
var noti1 = new Notification
|
||||
{
|
||||
Body = $"ประมวลผลการลงเวลาวันที่ {currentDate.ToString("dd-MM-yyyy")} ไม่สำเร็จ \r\nเนื่องจากไม่พบข้อมูลการประมวลผลเวลาทำงาน (CheckIn)",
|
||||
ReceiverUserId = profile.Id,
|
||||
Type = "",
|
||||
Payload = "",
|
||||
};
|
||||
_appDbContext.Set<Notification>().Add(noti1);
|
||||
await _appDbContext.SaveChangesAsync();
|
||||
|
||||
return Error(new Exception(GlobalMessages.DataNotFound), StatusCodes.Status404NotFound);
|
||||
}
|
||||
|
||||
|
|
@ -1275,11 +1353,19 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
else
|
||||
{
|
||||
await _checkInJobStatusRepository.UpdateToFailedAsync(taskId, "ไม่พบข้อมูลการประมวลผลเวลาทำงาน");
|
||||
// send notification to user
|
||||
var noti1 = new Notification
|
||||
{
|
||||
Body = $"ประมวลผลการลงเวลาวันที่ {currentDate.ToString("dd-MM-yyyy")} ไม่สำเร็จ \r\nเนื่องจากไม่พบข้อมูลการประมวลผลเวลาทำงาน",
|
||||
ReceiverUserId = profile.Id,
|
||||
Type = "",
|
||||
Payload = "",
|
||||
};
|
||||
_appDbContext.Set<Notification>().Add(noti1);
|
||||
await _appDbContext.SaveChangesAsync();
|
||||
return Error(new Exception(GlobalMessages.DataNotFound), StatusCodes.Status404NotFound);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// อัปเดตสถานะเป็น COMPLETED
|
||||
if (taskId != Guid.Empty)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue