This commit is contained in:
mmrbnjd
2025-07-28 17:41:14 +03:30
parent 43b6e4e746
commit ea152671d6
13 changed files with 691 additions and 12 deletions

View File

@@ -11,6 +11,7 @@ namespace Hushian.Application.Services
{
public class ExperService
{
private readonly IGenericRepository<Company> _CompanyRepository;
private readonly IGenericRepository<Exper> _ExperRepository;
private readonly VerificationService _VerificationService;
private readonly IMapper _mapper;
@@ -62,6 +63,30 @@ namespace Hushian.Application.Services
}
public async Task<Read_ExperDto?> GetInfoExper(int ExperID)
=> _mapper.Map<Read_ExperDto>(await _ExperRepository.Get().FirstOrDefaultAsync(w => w.ID == ExperID));
public async Task<CurrentUserInfo?> GetCurrentUserInfo(int CompanyID, int? ExperID)
{
if (ExperID.HasValue)
{
return await _ExperRepository.Get().Where(w => w.ID == ExperID).Select(s => new CurrentUserInfo
{
CompanyID = CompanyID,
ExperID = ExperID,
Username = s.UserName,
Role = "Exper"
}).FirstOrDefaultAsync();
}
else
{
return await _CompanyRepository.Get().Where(w => w.ID == CompanyID).Select(s => new CurrentUserInfo
{
CompanyID = CompanyID,
ExperID = null,
Username = s.Mobile,
Role = "Company"
}).FirstOrDefaultAsync();
}
}
public async Task<List<Read_ExperDto>> GetExpersInCompany(int companyID)
=> _mapper.Map<List<Read_ExperDto>>(await _ExperRepository.Get().Where(w => w.CompanyID == companyID).ToListAsync());
public async Task<Read_ExperDto?> GetExpersInGroup(int GroupID)
@@ -72,15 +97,15 @@ namespace Hushian.Application.Services
exper.FullName = model.FullName;
return await _ExperRepository.UPDATEBool(exper);
}
public async Task<bool> ChangeAvailableExper(int ExperID,int CompanyID,bool Available)
public async Task<bool> ChangeAvailableExper(int ExperID, int CompanyID, bool Available)
{
var exper = await _ExperRepository.Get().FirstOrDefaultAsync(w => w.ID == ExperID && w.CompanyID==CompanyID);
var exper = await _ExperRepository.Get().FirstOrDefaultAsync(w => w.ID == ExperID && w.CompanyID == CompanyID);
if (exper == null) return false;
exper.Available = Available;
return await _ExperRepository.UPDATEBool(exper);
}
public async Task<bool> CheckExperInCompany(int CompanyID, int ExperID)
=>await _ExperRepository.Get().AnyAsync(w => w.ID == ExperID && w.CompanyID==CompanyID);
=> await _ExperRepository.Get().AnyAsync(w => w.ID == ExperID && w.CompanyID == CompanyID);
public async Task<bool> DeleteExper(int ExperID, int CompanyID)
{
var exper = await _ExperRepository.Get().FirstOrDefaultAsync(w => w.ID == ExperID && w.CompanyID == CompanyID);
@@ -151,7 +176,7 @@ namespace Hushian.Application.Services
}
public async Task<bool> AvailableExperInCompany(int ExperID)
{
return await _ExperRepository.Get().AnyAsync(w => w.ID == ExperID && w.Available);
return await _ExperRepository.Get().AnyAsync(w => w.ID == ExperID && w.Available);
}
}