Files
Backend-Api/CompanyManagment.EFCore/Repository/PersonalContractingPartyRepository.cs
2025-10-01 12:20:09 +03:30

750 lines
28 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using _0_Framework.Application;
using _0_Framework.Application.Enums;
using _0_Framework.Exceptions;
using _0_Framework.InfraStructure;
using AccountManagement.Application.Contracts.Account;
using AccountMangement.Infrastructure.EFCore;
using Company.Domain.ContarctingPartyAgg;
using CompanyManagment.App.Contracts.Employer;
using CompanyManagment.App.Contracts.PersonalContractingParty;
using Microsoft.EntityFrameworkCore;
namespace CompanyManagment.EFCore.Repository;
public class PersonalContractingPartyRepository : RepositoryBase<long, PersonalContractingParty>, IPersonalContractingPartyRepository
{
private readonly CompanyContext _context;
private readonly AccountContext _accountContext;
public PersonalContractingPartyRepository(CompanyContext context, AccountContext accountContext) : base(context)
{
_context = context;
_accountContext = accountContext;
}
public List<PersonalContractingPartyViewModel> GetPersonalContractingParties()
{
var res = _context.PersonalContractingParties.Select(x => new PersonalContractingPartyViewModel
{
id = x.id,
FName = x.FName,
LName = x.IsLegal == "حقیقی" ? $"{x.FName.Trim()} {x.LName.Trim()}" : $"{x.LName.Trim()}",
SureName = x.SureName.Trim(),
//Nationalcode = x.Nationalcode,
//IdNumber = x.IdNumber,
//RegisterId = x.RegisterId,
//NationalId = x.NationalId,
IsLegal = x.IsLegal,
//Phone = x.Phone,
//AgentPhone = x.AgentPhone,
}).ToList();
res = res.Select(x => new PersonalContractingPartyViewModel()
{
id = x.id,
FName = x.FName,
LName = !string.IsNullOrWhiteSpace(x.SureName) ? $"{x.LName} ({x.SureName})" : $"{x.LName}",
SureName = x.SureName,
FullName = !string.IsNullOrWhiteSpace(x.SureName) ? (x.LName + " " + x.SureName) : $"{x.LName}",
//Nationalcode = x.Nationalcode,
//IdNumber = x.IdNumber,
//RegisterId = x.RegisterId,
//NationalId = x.NationalId,
IsLegal = x.IsLegal,
}).ToList();
//var result = new List<PersonalContractingPartyViewModel>();
//foreach (var item in res)
//{
// item.FullName = $"{item.LName}";
// result.Add(item);
//}
return res;
}
public EditPersonalContractingParty GetDetails(long id)
{
var res = _context.PersonalContractingParties.Select(x => new EditPersonalContractingParty()
{
Id = x.id,
FName = x.FName,
LName = x.IsLegal == "حقیقی" ? $"{x.FName} {x.LName}" : $"{x.LName}",
SureName = x.SureName,
Nationalcode = x.Nationalcode,
IdNumber = x.IdNumber,
RegisterId = x.RegisterId,
NationalId = x.NationalId,
IsLegal = x.IsLegal,
Phone = x.Phone,
AgentPhone = x.AgentPhone,
Address = x.Address,
ArchiveCode = x.ArchiveCode,
RepresentativeId = x.RepresentativeId,
RepresentativeFullName = x.RepresentativeFullName,
State = x.State,
City = x.City,
Zone = x.Zone,
IsActiveString = x.IsActiveString,
IsBlock = x.IsBlock,
BlockTimes = x.BlockTimes,
})
.FirstOrDefault(x => x.Id == id);
if (res != null)
{
res.LName = !string.IsNullOrWhiteSpace(res.SureName) ? $"{res.LName} ({res.SureName})" : $"{res.LName}";
}
return res;
}
public EditPersonalContractingParty GetDetailsToEdit(long id)
{
return _context.PersonalContractingParties.Select(x => new EditPersonalContractingParty()
{
Id = x.id,
FName = x.FName,
LName = x.LName,
SureName = x.SureName,
Nationalcode = x.Nationalcode,
IdNumber = x.IdNumber,
RegisterId = x.RegisterId,
NationalId = x.NationalId,
IsLegal = x.IsLegal,
Phone = x.Phone,
AgentPhone = x.AgentPhone,
Address = x.Address,
ArchiveCode = x.ArchiveCode,
RepresentativeId = x.RepresentativeId,
RepresentativeFullName = x.RepresentativeFullName,
State = x.State,
City = x.City,
Zone = x.Zone,
IsActiveString = x.IsActiveString,
IsBlock = x.IsBlock,
BlockTimes = x.BlockTimes,
})
.FirstOrDefault(x => x.Id == id);
}
public string GetFullName(long id)
{
string FullName = "";
var res = _context.PersonalContractingParties.Select(x => new PersonalContractingPartyViewModel
{
id = x.id,
FName = x.FName,
LName = x.IsLegal == "حقیقی" ? $"{x.FName} {x.LName}" : $"{x.LName}",
SureName = x.SureName
}).FirstOrDefault(x => x.id == id);
if (res != null)
{
return FullName = !string.IsNullOrWhiteSpace(res.SureName)
? $"{res.LName} ({res.SureName})"
: $"{res.LName}";
}
else
{
return "";
}
}
public List<PersonalContractingPartyViewModel> Search(PersonalContractingPartySearchModel searchModel2)
{
var query = _context.PersonalContractingParties.Select(x => new PersonalContractingPartyViewModel
{
id = x.id,
FName = x.FName,
LName = !string.IsNullOrWhiteSpace(x.SureName) ? $"{x.LName} ({x.SureName})" : $"{x.LName}",
SureName = x.SureName,
Nationalcode = x.Nationalcode,
IdNumber = x.IdNumber,
RegisterId = x.RegisterId,
NationalId = x.NationalId,
IsLegal = x.IsLegal,
ArchiveCode = x.ArchiveCode,
State = x.State,
City = x.City,
Zone = x.Zone,
IsActiveString = x.IsActiveString,
IsBlock = x.IsBlock,
BlockTimes = x.BlockTimes,
CreationDate = x.CreationDate.ToString()
});
if (searchModel2.id > 0)
query = query.Where(x => x.id == searchModel2.id);
if (!string.IsNullOrWhiteSpace(searchModel2.FName))
query = query.Where(x => x.FName.Contains(searchModel2.FName));
if (!string.IsNullOrWhiteSpace(searchModel2.LName))
query = query.Where(x => x.LName.Contains(searchModel2.LName));
if (!string.IsNullOrWhiteSpace(searchModel2.Nationalcode))
query = query.Where(x => x.Nationalcode.Contains(searchModel2.Nationalcode));
if (!string.IsNullOrWhiteSpace(searchModel2.IdNumber))
query = query.Where(x => x.IdNumber.Contains(searchModel2.IdNumber));
if (!string.IsNullOrWhiteSpace(searchModel2.RegisterId))
query = query.Where(x => x.RegisterId.Contains(searchModel2.RegisterId));
if (!string.IsNullOrWhiteSpace(searchModel2.NationalId))
query = query.Where(x => x.NationalId.Contains(searchModel2.NationalId));
if (!string.IsNullOrWhiteSpace(searchModel2.IsLegal))
query = query.Where(x => x.IsLegal.Contains(searchModel2.IsLegal));
return query.OrderByDescending(x => x.id).ToList();
}
public int GetLastArchiveCode()
{
var res = _context.PersonalContractingParties.Max(x => x.ArchiveCode);
if (res > 0)
{
res += 1;
return res;
}
else
{
return 1;
}
}
#region Mahan
public List<string> SearchByName(string name)
{
var contractingParties = _context.PersonalContractingParties.Select(x => new PersonalContractingPartyViewModel()
{
FullName = x.IsLegal == "حقوقی" ? x.LName : $"{x.FName} {x.LName}"
}).ToList();
return contractingParties.Select(x => x.FullName).ToList();
}
public AccountViewModel GetAccountByPersonalContractingParty(long contractingPartyId)
{
long? accId = _context.ContractingPartyAccounts.FirstOrDefault(x => x.PersonalContractingPartyId == contractingPartyId)?.AccountId;
if (accId == null)
{
return new();
}
return _accountContext.Accounts.Where(x => x.id == accId && x.IsActiveString == "true").Select(x => new AccountViewModel()
{
Id = x.id,
Fullname = x.Fullname,
Mobile = x.Mobile,
ClientAreaPermission = x.ClientAriaPermission
}).FirstOrDefault();
}
#endregion
#region NewByHeydari
public List<PersonalContractingPartyViewModel> GetPersonalContractingPartiesForNationalcode(string searchText)
{
var result = _context.PersonalContractingParties.Where(x => (!string.IsNullOrEmpty(x.Nationalcode) && x.Nationalcode.StartsWith(searchText)))
.Select(x => new PersonalContractingPartyViewModel
{
id = x.id,
Nationalcode = x.Nationalcode,
}).Take(100).ToList();
return result;
}
public List<PersonalContractingPartyViewModel> SearchForMain(PersonalContractingPartySearchModel searchModel2)
{
var query = _context.PersonalContractingParties.Include(x => x.Employers).Select(x => new PersonalContractingPartyViewModel
{
id = x.id,
FName = x.FName,
LName = !string.IsNullOrWhiteSpace(x.SureName) ? $"{x.LName} ({x.SureName})" : $"{x.LName}",
SureName = x.SureName,
Nationalcode = x.Nationalcode,
IdNumber = x.IdNumber,
RegisterId = x.RegisterId,
NationalId = x.NationalId,
IsLegal = x.IsLegal,
ArchiveCode = x.ArchiveCode,
FullName = x.FName + " " + x.LName,
State = x.State,
City = x.City,
Zone = x.Zone,
IsActiveString = x.IsActiveString,
IsBlock = x.IsBlock,
BlockTimes = x.BlockTimes,
RepresentativeId = x.RepresentativeId,
CreationDate = x.CreationDate.ToString(),
EmployerList = x.Employers.Select(y => new EmployerViewModel() { Id = y.id, FullName = y.FullName }).ToList()
});
if (searchModel2.id > 0)
query = query.Where(x => x.id == searchModel2.id);
if (!string.IsNullOrWhiteSpace(searchModel2.Nationalcode) && searchModel2.Nationalcode != "0")
query = query.Where(x => x.Nationalcode.Contains(searchModel2.Nationalcode));
if (searchModel2.RepresentativeId > 0)
query = query.Where(x => x.RepresentativeId == searchModel2.RepresentativeId);
if (!string.IsNullOrWhiteSpace(searchModel2.IsLegal))
query = query.Where(x => x.IsLegal == searchModel2.IsLegal);
if (!string.IsNullOrWhiteSpace(searchModel2.IsActiveString) && searchModel2.IsActiveString != "both")
query = query.Where(x => x.IsActiveString == searchModel2.IsActiveString);
if (!string.IsNullOrEmpty(searchModel2.RepresentativeName))
{
var representativeIds = _context.RepresentativeSet.Where(x => !string.IsNullOrEmpty(x.FullName) && x.FullName.Contains(searchModel2.RepresentativeName)).Select(x => x.id).ToList();
query = query.Where(x => representativeIds.Contains(x.RepresentativeId));
}
if (!string.IsNullOrEmpty(searchModel2.EmployeeName))
{
query = query.Where(x => (x.IsLegal == "حقیقی" &&
((!string.IsNullOrWhiteSpace(x.FName) && x.FName.StartsWith(searchModel2.EmployeeName)) ||
(!string.IsNullOrWhiteSpace(x.LName) && x.LName.StartsWith(searchModel2.EmployeeName))))
|| (x.IsLegal == "حقوقی" && (!string.IsNullOrWhiteSpace(x.LName) && x.LName.Contains(searchModel2.EmployeeName))));
}
return query.OrderByDescending(x => x.id).ToList();
}
public OperationResult DeletePersonalContractingParties(long id)
{
var op = new OperationResult();
try
{
var personalContractingParties = _context.PersonalContractingParties.Where(x => x.id == id)?.FirstOrDefault();
_context.PersonalContractingParties.Remove(personalContractingParties);
_context.SaveChanges();
return op.Succcedded(-1, "حذف با موفقیت انجام شد.");
}
catch (Exception)
{
return op.Failed("حذف با خطا مواجه شد.");
}
}
public bool GetHasContract(long id)
{
return _context.InstitutionContractSet.Any(x => x.IsActiveString == "true" && x.ContractingPartyId == id);
}
public OperationResult DeActiveAll(long id)
{
OperationResult result = new OperationResult();
using (var transaction = _context.Database.BeginTransaction())
{
try
{
var personel = _context.PersonalContractingParties.FirstOrDefault(x => x.id == id);
personel.DeActive();
var employers = _context.Employers.Where(x => x.ContractingPartyId == id).ToList();
employers.ForEach(x => x.DeActive());
var employerIds = employers.Select(x => x.id).ToList();
var workshopIds = _context.WorkshopEmployers.Where(x => employerIds.Contains(x.EmployerId)).Select(x => x.WorkshopId).ToList();
var workshops = _context.Workshops.Where(x => workshopIds.Contains(x.id)).ToList();
workshops.ForEach(x => x.DeActive(x.ArchiveCode));
var contracts = _context.Contracts.Where(x => workshopIds.Contains(x.WorkshopIds)).ToList();
contracts.ForEach(x => x.DeActive());
var contractIds = contracts.Select(x => x.id).ToList();
var checkouts = _context.CheckoutSet.Where(x => contractIds.Contains(x.ContractId)).ToList();
checkouts.ForEach(x => x.DeActive());
_context.SaveChanges();
transaction.Commit();
result.Failed("DeActive");
}
catch (Exception)
{
result.Failed("غیرفعال کردن طرف حساب با خطا مواجه شد");
transaction.Rollback();
}
}
return result;
}
public OperationResult ActiveAll(long id)
{
OperationResult result = new OperationResult();
using (var transaction = _context.Database.BeginTransaction())
{
try
{
var personel = _context.PersonalContractingParties.FirstOrDefault(x => x.id == id);
personel.Active();
var employers = _context.Employers.Where(x => x.ContractingPartyId == id).ToList();
employers.ForEach(x => x.Active());
var employerIds = employers.Select(x => x.id).ToList();
var workshopIds = _context.WorkshopEmployers.Where(x => employerIds.Contains(x.EmployerId)).Select(x => x.WorkshopId).ToList();
var workshops = _context.Workshops.Where(x => workshopIds.Contains(x.id)).ToList();
workshops.ForEach(x => x.Active(x.ArchiveCode));
var contracts = _context.Contracts.Where(x => workshopIds.Contains(x.WorkshopIds)).ToList();
contracts.ForEach(x => x.Active());
var contractIds = contracts.Select(x => x.id).ToList();
var checkouts = _context.CheckoutSet.Where(x => contractIds.Contains(x.ContractId)).ToList();
checkouts.ForEach(x => x.Active());
_context.SaveChanges();
transaction.Commit();
result.Succcedded();
}
catch (Exception)
{
result.Failed("فعال کردن طرف حساب با خطا مواجه شد");
transaction.Rollback();
}
}
return result;
}
public string IsBlockByEmployerId(long employerId)
{
var emp = _context.Employers.FirstOrDefault(x => x.id == employerId);
if (emp != null)
{
var res = _context.PersonalContractingParties.FirstOrDefault(x => x.id == emp.ContractingPartyId);
if (res != null)
return res.IsBlock;
return $"NotFound";
}
return $"NotFound";
}
#region Insurance
public bool IsBlockCheckByWorkshopId(long workshopId)
{
var e = _context.WorkshopEmployers
.Where(x => x.WorkshopId == workshopId)
.Include(x => x.Employer)
.ThenInclude(x => x.ContractingParty)
.Select(c => c.Employer.ContractingParty);
return e.Any(x => x.IsBlock == "true");
}
#endregion
#region ForClients
public ContractingPartyAndStatmentIdViewModel GetContractingpartyIdByAccountId(long accountId)
{
var contractingPartId = _context.ContractingPartyAccounts.Any(x => x.AccountId == accountId) ?
_context.ContractingPartyAccounts.FirstOrDefault(x => x.AccountId == accountId)!.PersonalContractingPartyId : 0;
var financialStatmentId = _context.FinancialStatments
.Any(x => x.ContractingPartyId == contractingPartId) ? _context.FinancialStatments
.FirstOrDefault(x => x.ContractingPartyId == contractingPartId)!.id : 0;
var res = new ContractingPartyAndStatmentIdViewModel()
{
ContractingPartyId = contractingPartId,
FinancialStatmentId = financialStatmentId,
};
return res;
}
#endregion
#region Api
public async Task<ICollection<ContractingPartyGetListViewModel>> GetList(ContractingPartyGetListSearchModel searchModel)
{
var personalContractingPartiesQuery = _context.PersonalContractingParties
.Include(x => x.Representative)
.Include(x => x.Employers).AsQueryable();
if (!string.IsNullOrWhiteSpace(searchModel.NationalIdOrNationalCode))
personalContractingPartiesQuery = personalContractingPartiesQuery
.Where(x => x.Nationalcode.Contains(searchModel.NationalIdOrNationalCode) ||
x.NationalId.Contains(searchModel.NationalIdOrNationalCode));
if (searchModel.ContractingPartyType != LegalType.None)
{
string type = searchModel.ContractingPartyType switch
{
LegalType.Legal => "حقوقی",
LegalType.Real => "حقیقی",
_ => ""
};
personalContractingPartiesQuery = personalContractingPartiesQuery
.Where(x => x.IsLegal == type);
}
if (searchModel.ContractingPartyStatus != ActivationStatus.None)
{
string status = searchModel.ContractingPartyStatus switch
{
ActivationStatus.Active => "true",
ActivationStatus.DeActive => "false",
_ => ""
};
personalContractingPartiesQuery = personalContractingPartiesQuery
.Where(x => x.IsActiveString == status);
}
if (!string.IsNullOrWhiteSpace(searchModel.RepresentativeName))
{
personalContractingPartiesQuery = personalContractingPartiesQuery
.Where(x => x.Representative.FullName.Contains(searchModel.RepresentativeName));
}
if (!string.IsNullOrWhiteSpace(searchModel.FullNameOrCompanyName))
{
personalContractingPartiesQuery = personalContractingPartiesQuery.Where(x =>
(x.FName + " " + x.LName).Contains(searchModel.FullNameOrCompanyName));
}
var joinedQuery = personalContractingPartiesQuery
.GroupJoin(_context.InstitutionContractSet.Where(x => personalContractingPartiesQuery.Any(p => p.id == x.ContractingPartyId)),
contractingParty => contractingParty.id,
institution => institution.ContractingPartyId,
(contractingParty, institution) => new
{
contractingParty,
institution
});
var result = await joinedQuery.Skip(searchModel.PageIndex)
.Take(30).Select(x => new ContractingPartyGetListViewModel()
{
ArchiveCode = x.contractingParty.ArchiveCode,
BlockTimes = x.contractingParty.BlockTimes,
ContractingPartyName = x.contractingParty.IsLegal == "حقیقی" ?
x.contractingParty.SureName == null ? $"{x.contractingParty.FName} {x.contractingParty.LName}"
: $"{x.contractingParty.FName} {x.contractingParty.LName} {x.contractingParty.SureName}"
: x.contractingParty.SureName == null ? $"{x.contractingParty.LName}"
: $"{x.contractingParty.LName} {x.contractingParty.SureName}",
ContractingPartyType = x.contractingParty.IsLegal == "حقیقی" ? LegalType.Real : LegalType.Legal,
Employers = x.contractingParty.Employers.Take(11).Select(e => new ContractingPartyGetListEmployerViewModel(e.id, e.FullName)).ToList(),
Id = x.contractingParty.id,
IsBlock = x.contractingParty.IsBlock == "true",
HasInstitutionContract = x.institution.Any(i => i.IsActiveString == "true"),
NationalIdOrNationalCode = x.contractingParty.IsLegal == "حقیقی" ? x.contractingParty.Nationalcode : x.contractingParty.NationalId,
Status = x.contractingParty.IsActiveString == "true" ? ActivationStatus.Active : ActivationStatus.DeActive,
Address = x.contractingParty.Address,
NationalId = x.contractingParty.NationalId,
PhoneNumber = x.contractingParty.Phone,
RepresentativeName = x.contractingParty.RepresentativeFullName
}).ToListAsync();
return result;
}
public async Task<List<ContractingPartySelectListViewModel>> GetSelectList(string search,long id)
{
var query = _context.PersonalContractingParties.Select(x => new ContractingPartySelectListViewModel
{
Id = x.id,
Text = x.IsLegal == "حقیقی" ? x.SureName == null
? x.FName + " " + x.LName
: x.FName + " " + x.LName + " " + x.SureName
: x.SureName == null ? x.LName
: x.LName + " " + x.SureName
});
ContractingPartySelectListViewModel idSelected = null;
if (id > 0)
{
idSelected = await query.FirstOrDefaultAsync(x => x.Id == id);
}
if (!string.IsNullOrWhiteSpace(search))
{
query = query.Where(x => x.Text.Contains(search));
}
var list = await query.Take(100).ToListAsync();
if (idSelected != null)
list.Add(idSelected);
return list.DistinctBy(x => x.Id).ToList();
}
public async Task<List<GetContractingPartyNationalCodeOrNationalIdViewModel>> GetNationalCodeOrNationalId()
{
return await _context.PersonalContractingParties.Select(x => new GetContractingPartyNationalCodeOrNationalIdViewModel
{
NationalCodeOrNationalId = x.IsLegal == "true" ? x.NationalId : x.Nationalcode
}).ToListAsync();
}
public async Task<OperationResult<string>> DeactivateWithSubordinates(long id)
{
var op = new OperationResult<string>();
;
using (var transaction = await _context.Database.BeginTransactionAsync())
{
try
{
var contractingParty = await _context.PersonalContractingParties
.Include(x => x.Employers)
.ThenInclude(x => x.Contracts)
.Include(x => x.Employers)
.ThenInclude(x => x.WorkshopEmployers)
.ThenInclude(x => x.Workshop)
.ThenInclude(x => x.Checkouts).FirstOrDefaultAsync(x => x.id == id);
if (contractingParty == null)
{
return op.Failed("چنین آیتمی وجود ندارد");
}
var employers = contractingParty.Employers;
var workshops = employers.SelectMany(x => x.WorkshopEmployers).Select(x => x.Workshop).ToList();
var contracts = employers.SelectMany(x => x.Contracts).ToList();
var checkouts = workshops.SelectMany(x => x.Checkouts).ToList();
contractingParty.DeActive();
foreach (var employer in employers)
{
employer.DeActive();
}
foreach (var workshop in workshops)
{
workshop.DeActive(workshop.ArchiveCode);
}
foreach (var contract in contracts)
{
contract.DeActive();
}
foreach (var checkout in checkouts)
{
checkout.DeActive();
}
await _context.SaveChangesAsync();
await transaction.CommitAsync();
return op.Succcedded("DeActivate");
}
catch (Exception)
{
await transaction.RollbackAsync();
return op.Failed("غیرفعال کردن طرف حساب با خطا مواجه شد");
}
}
}
public async Task<GetRealContractingPartyDetailsViewModel> GetRealDetails(long id)
{
var res = await _context.PersonalContractingParties.Where(x => x.IsLegal == "حقیقی").Select(x =>
new GetRealContractingPartyDetailsViewModel()
{
Id = x.id,
IdNumber = x.IdNumber,
PhoneNumber = x.Phone,
AgentPhone = x.AgentPhone,
Address = x.Address,
FullName = x.SureName == null
? $"{x.FName} {x.LName}"
: $"{x.FName} {x.LName} {x.SureName}",
NationalCode = x.Nationalcode,
RepresentativeName = x.RepresentativeFullName,
ArchiveCode = x.ArchiveCode,
City = x.City,
FName = x.FName,
LName = x.LName,
SureName = x.SureName,
RepresentativeId = x.RepresentativeId,
State = x.State,
Zone = x.Zone
}).FirstOrDefaultAsync(x => x.Id == id);
if (res == null)
{
throw new BadRequestException("چنین طرف حسابی وجود ندارد");
}
return res;
}
public async Task<GetLegalContractingPartyDetailsViewModel> GetLegalDetails(long id)
{
var res = await _context.PersonalContractingParties.Where(x => x.IsLegal == "حقوقی").Select(x =>
new GetLegalContractingPartyDetailsViewModel()
{
Id = x.id,
PhoneNumber = x.Phone,
AgentPhone = x.AgentPhone,
Address = x.Address,
CompanyFullName = x.SureName == null
? $"{x.LName}"
: $"{x.LName} {x.SureName}",
NationalId = x.NationalId,
RegisterId = x.RegisterId,
RepresentativeName = x.RepresentativeFullName,
RepresentativeId = x.RepresentativeId,
State = x.State,
SureName = x.SureName,
Zone = x.Zone,
ArchiveCode = x.ArchiveCode,
City = x.City,
CompanyName = x.LName
}).FirstOrDefaultAsync(x => x.Id == id);
if (res == null)
{
throw new BadRequestException("چنین طرف حسابی وجود ندارد");
}
return res;
}
#endregion
}
#endregion