This commit is contained in:
mmrbnjd
2025-07-05 14:17:54 +03:30
parent 23043dd094
commit e15790488e
7 changed files with 149 additions and 12 deletions

View File

@@ -1,4 +1,5 @@
using Common.Dtos;
using AutoMapper;
using Common.Dtos;
using Common.Dtos.Exper;
using Hushian.Application.Contracts.Persistence;
using Hushian.Application.Models;
@@ -18,6 +19,7 @@ namespace Hushian.Application.Services
private readonly IGenericRepository<Company> _CompanyRepository;
private readonly IGenericRepository<Exper> _ExperRepository;
private readonly VerificationService _VerificationService;
private readonly IMapper _mapper;
public async Task<ResponseBase<bool>> ADDExper(ADD_ExperDto dto, int CompanyID)
{
var Response = new ResponseBase<bool>();
@@ -56,8 +58,20 @@ namespace Hushian.Application.Services
return Response;
}
//Get Info
// Update
public async Task<Read_ExperDto?> GetInfoExper(int ExperID)
=> _mapper.Map<Read_ExperDto>(await _ExperRepository.Get().FirstOrDefaultAsync(w => w.ID == ExperID));
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)
=> _mapper.Map<Read_ExperDto>(await _ExperRepository.Get().Where(w => w.EG.Any(a => a.GroupID == GroupID)).ToListAsync());
public async Task<bool> UpdateExper(Update_ExperDto model, int ExperID)
{
var exper = await _ExperRepository.Get().FirstOrDefaultAsync(w => w.ID == ExperID);
exper.FullName = model.FullName;
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);
public async Task<ResponseBase<bool>> ChangePasswordExperFromExper(ChangePasswordDto model, int ExperID)
{
ResponseBase<bool> Response = new();
@@ -72,8 +86,8 @@ namespace Hushian.Application.Services
exper.Password = model.NewPassWord.GetHash();
Response.Value = await _ExperRepository.UPDATEBool(exper);
if (!Response.Value) Response.Errors.Add("خطا در ذخیره سازی");
else Response.Success = true;
else Response.Success = true;
}
return Response;
}