fix defect
This commit is contained in:
parent
be10c7ef95
commit
a167f5ec9e
3 changed files with 48 additions and 23 deletions
|
|
@ -1,5 +1,4 @@
|
|||
using Amazon.S3.Model.Internal.MarshallTransformations;
|
||||
using BMA.EHR.Application.Common.Interfaces;
|
||||
using BMA.EHR.Application.Common.Interfaces;
|
||||
using BMA.EHR.Application.Messaging;
|
||||
using BMA.EHR.Domain.Models.Leave.Commons;
|
||||
using BMA.EHR.Domain.Models.Leave.Requests;
|
||||
|
|
@ -7,7 +6,6 @@ using BMA.EHR.Domain.Models.Notifications;
|
|||
using BMA.EHR.Domain.Shared;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Query;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||
|
|
@ -23,6 +21,8 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
private readonly IConfiguration _configuration;
|
||||
private readonly EmailSenderService _emailSenderService;
|
||||
|
||||
private readonly IApplicationDBContext _appDbContext;
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Constructor and Destuctor "
|
||||
|
|
@ -32,7 +32,8 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
OrganizationCommonRepository organizationCommonRepository,
|
||||
UserProfileRepository userProfileRepository,
|
||||
IConfiguration configuration,
|
||||
EmailSenderService emailSenderService) : base(dbContext, httpContextAccessor)
|
||||
EmailSenderService emailSenderService,
|
||||
IApplicationDBContext appDbContext) : base(dbContext, httpContextAccessor)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
|
|
@ -40,6 +41,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
_userProfileRepository = userProfileRepository;
|
||||
_configuration = configuration;
|
||||
_emailSenderService = emailSenderService;
|
||||
_appDbContext = appDbContext;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
@ -121,7 +123,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
var rawData = _dbContext.Set<LeaveRequest>()
|
||||
.Include(x => x.Type)
|
||||
.AsQueryable();
|
||||
|
||||
|
||||
|
||||
|
||||
if (year != 0)
|
||||
|
|
@ -240,8 +242,8 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
Type = "",
|
||||
Payload = "",
|
||||
};
|
||||
_dbContext.Set<Notification>().Add(noti);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
_appDbContext.Set<Notification>().Add(noti);
|
||||
await _appDbContext.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task RejectCancelLeaveRequestAsync(Guid id, string Reason)
|
||||
|
|
@ -273,8 +275,8 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
Type = "",
|
||||
Payload = "",
|
||||
};
|
||||
_dbContext.Set<Notification>().Add(noti);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
_appDbContext.Set<Notification>().Add(noti);
|
||||
await _appDbContext.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task OfficerApproveLeaveRequest(Guid id)
|
||||
|
|
@ -286,7 +288,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
}
|
||||
|
||||
rawData.LeaveStatus = "PENDING";
|
||||
rawData.ApproveStep = "st1";
|
||||
rawData.ApproveStep = "st2";
|
||||
|
||||
await UpdateAsync(rawData);
|
||||
}
|
||||
|
|
@ -306,7 +308,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
|
||||
rawData.LeaveStatus = "PENDING";
|
||||
rawData.LeaveComment = reason;
|
||||
rawData.ApproveStep = "st2";
|
||||
rawData.ApproveStep = "st3";
|
||||
|
||||
await UpdateAsync(rawData);
|
||||
}
|
||||
|
|
@ -319,7 +321,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
throw new Exception(GlobalMessages.DataNotFound);
|
||||
}
|
||||
|
||||
if (rawData.ApproveStep != "st2")
|
||||
if (rawData.ApproveStep != "st3")
|
||||
{
|
||||
throw new Exception("คำขอนี้ยังไม่ได้รับการอนุมัติจากผู้บังคับบัญชา ไม่สามารถทำรายการได้");
|
||||
}
|
||||
|
|
@ -332,7 +334,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
|
||||
rawData.LeaveStatus = "APPROVE";
|
||||
rawData.LeaveDirectorComment = reason;
|
||||
rawData.ApproveStep = "st2";
|
||||
rawData.ApproveStep = "st4";
|
||||
|
||||
await UpdateAsync(rawData);
|
||||
|
||||
|
|
@ -344,8 +346,8 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
Type = "",
|
||||
Payload = "",
|
||||
};
|
||||
_dbContext.Set<Notification>().Add(noti);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
_appDbContext.Set<Notification>().Add(noti);
|
||||
await _appDbContext.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task RejectLeaveRequest(Guid id, string reason)
|
||||
|
|
@ -356,7 +358,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
throw new Exception(GlobalMessages.DataNotFound);
|
||||
}
|
||||
|
||||
if (rawData.ApproveStep != "st2")
|
||||
if (rawData.ApproveStep != "st3")
|
||||
{
|
||||
throw new Exception("คำขอนี้ยังไม่ได้รับการอนุมัติจากผู้บังคับบัญชา ไม่สามารถทำรายการได้");
|
||||
}
|
||||
|
|
@ -369,7 +371,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
|
||||
rawData.LeaveStatus = "REJECT";
|
||||
rawData.LeaveDirectorComment = reason;
|
||||
rawData.ApproveStep = "st2";
|
||||
rawData.ApproveStep = "st5";
|
||||
|
||||
await UpdateAsync(rawData);
|
||||
|
||||
|
|
@ -381,8 +383,8 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
Type = "",
|
||||
Payload = "",
|
||||
};
|
||||
_dbContext.Set<Notification>().Add(noti);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
_appDbContext.Set<Notification>().Add(noti);
|
||||
await _appDbContext.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task<int> GetSumSendLeaveByTypeForUserAsync(Guid keycloakUserId, Guid leaveTypeId, int year)
|
||||
|
|
@ -425,7 +427,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
|
||||
if (data.Count > 0)
|
||||
return data.Sum(x => x.LeaveTotal);
|
||||
else
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -441,7 +443,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
|
||||
if (data.Count > 0)
|
||||
return data.Sum(x => x.LeaveTotal);
|
||||
else
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue