...
This commit is contained in:
@@ -60,7 +60,12 @@ namespace Hushian.Application.Services
|
||||
var entity = await _GroupRepository.Get().Where(f => f.CompanyID == CompanyID).ToListAsync();
|
||||
return _mapper.Map<List<Read_GroupDto>>(entity);
|
||||
}
|
||||
public async Task UpdateGroup(Update_GroupDto model, int CompanyID)
|
||||
public async Task<List<Read_GroupDto>> GetGroupsExper(int ExperID)
|
||||
{
|
||||
var entity = await _GroupRepository.Get().Where(f => f.EG.Any(a=>a.ExperID==ExperID)).ToListAsync();
|
||||
return _mapper.Map<List<Read_GroupDto>>(entity);
|
||||
}
|
||||
public async Task<ResponseBase<bool>> UpdateGroup(Update_GroupDto model, int CompanyID)
|
||||
{
|
||||
ResponseBase<bool> Response = new();
|
||||
if (!model.Name.IsOnlyPersianLetters())
|
||||
@@ -91,6 +96,8 @@ namespace Hushian.Application.Services
|
||||
Response.Errors.Add("خطای سیستمی");
|
||||
}
|
||||
}
|
||||
|
||||
return Response;
|
||||
}
|
||||
public async Task<bool> ChangeAvailableGroup(ChangeAvailable_GroupDto model, int CompanyID)
|
||||
{
|
||||
@@ -106,26 +113,70 @@ namespace Hushian.Application.Services
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public async Task<bool> JoinExperInGroup(int GroupID, int ExperID, int CompanyID)
|
||||
public async Task<ResponseBase<bool>> DeleteGroup(int GroupID,int CompanyID)
|
||||
{
|
||||
ResponseBase<bool> Response = new();
|
||||
|
||||
var Group = await _GroupRepository.Get().FirstOrDefaultAsync(a => a.CompanyID == CompanyID && a.ID == GroupID);
|
||||
if (Group!=null) Response.Value=Response.Success= await _GroupRepository.DELETE(Group);
|
||||
else Response.Errors.Add("یافت نشد");
|
||||
|
||||
return Response;
|
||||
}
|
||||
public async Task<ResponseBase<bool>> JoinExperInGroup(int GroupID, int ExperID, int CompanyID)
|
||||
{
|
||||
ResponseBase<bool> Response = new();
|
||||
|
||||
if (await CHeckGroupMemberCompany(GroupID,CompanyID))
|
||||
{
|
||||
if (await _experService.CheckExperInCompany(CompanyID,ExperID))
|
||||
{
|
||||
return await _EGRepository.ADDBool(new ExperGroup()
|
||||
Response.Value=Response.Success= await _EGRepository.ADDBool(new ExperGroup()
|
||||
{
|
||||
ExperID = ExperID,
|
||||
GroupID = GroupID
|
||||
});
|
||||
}
|
||||
else Response.Errors.Add("کارشناس یافت نشد");
|
||||
|
||||
}
|
||||
return false;
|
||||
else Response.Errors.Add("گروه یافت نشد");
|
||||
|
||||
return Response;
|
||||
}
|
||||
public async Task<ResponseBase<bool>> UnJoinExperInGroup(int GroupID, int ExperID, int CompanyID)
|
||||
{
|
||||
ResponseBase<bool> Response = new();
|
||||
|
||||
if (await CHeckGroupMemberCompany(GroupID, CompanyID))
|
||||
{
|
||||
if (await _experService.CheckExperInCompany(CompanyID, ExperID))
|
||||
{
|
||||
try
|
||||
{
|
||||
var eg =await _EGRepository.Get().FirstOrDefaultAsync(w=>w.GroupID==GroupID && w.ExperID==ExperID);
|
||||
Response.Value = Response.Success = eg==null ? true : await _EGRepository.DELETE(eg);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
else Response.Errors.Add("کارشناس یافت نشد");
|
||||
|
||||
}
|
||||
else Response.Errors.Add("گروه یافت نشد");
|
||||
|
||||
return Response;
|
||||
}
|
||||
public async Task<bool> AnyGroup(int GroupID) =>
|
||||
await _GroupRepository.Get().AnyAsync(a=>a.ID==GroupID);
|
||||
public async Task<bool> CHeckGroupMemberCompany(int GroupID, int CompanyID)=>
|
||||
await _GroupRepository.Get().AnyAsync(a => a.CompanyID == CompanyID && a.ID == GroupID);
|
||||
|
||||
public async Task<List<Read_ExperDto>> GetExpersFromGroupID(int GroupID)
|
||||
=> _mapper.Map<List<Read_ExperDto>>( await _EGRepository.Get().Where(w => w.GroupID == GroupID).Select(s=>s.Exper).ToListAsync());
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user