This commit is contained in:
@@ -4402,24 +4402,30 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
internal async Task<Contract> GetCurrentWorkOrderContractFromRelatedAsync(AyaType ayaType, long id)
|
internal async Task<Contract> GetCurrentWorkOrderContractFromRelatedAsync(AyaType ayaType, long id)
|
||||||
{
|
{
|
||||||
//instantiated method to save adding the context
|
|
||||||
if (mFetchedContractAlready == false)
|
if (mFetchedContractAlready == false)
|
||||||
{
|
{
|
||||||
mContractInEffect = await GetCurrentWorkOrderContractFromRelatedAsync(ayaType, id, ct);
|
long WoId = await GetWorkOrderIdFromRelativeAsync(ayaType, id, ct);
|
||||||
mFetchedContractAlready = true;
|
var WoContractId = await ct.WorkOrder.AsNoTracking().Where(z => z.Id == WoId).Select(z => z.ContractId).FirstOrDefaultAsync();
|
||||||
|
await GetCurrentContractFromContractIdAsync(WoContractId);
|
||||||
}
|
}
|
||||||
return mContractInEffect;
|
return mContractInEffect;
|
||||||
}
|
}
|
||||||
internal static async Task<Contract> GetCurrentWorkOrderContractFromRelatedAsync(AyaType ayaType, long id, AyContext ct)
|
|
||||||
|
|
||||||
|
internal async Task<Contract> GetCurrentContractFromContractIdAsync(long? id)
|
||||||
{
|
{
|
||||||
//static method
|
if (id == null) return null;
|
||||||
long WoId = await GetWorkOrderIdFromRelativeAsync(ayaType, id, ct);
|
if (mFetchedContractAlready == false)
|
||||||
var WoContractId = await ct.WorkOrder.AsNoTracking().Where(z => z.Id == WoId).Select(z => z.ContractId).FirstOrDefaultAsync();
|
|
||||||
if (WoContractId == null)
|
|
||||||
{
|
{
|
||||||
return null;
|
mContractInEffect = await ct.Contract.AsNoTracking()
|
||||||
|
.Include(c => c.ServiceRateItems)
|
||||||
|
.Include(c => c.TravelRateItems)
|
||||||
|
.Include(c => c.ContractPartOverrideItems)
|
||||||
|
.Include(c => c.ContractTravelRateOverrideItems)
|
||||||
|
.Include(c => c.ContractServiceRateOverrideItems)
|
||||||
|
.FirstOrDefaultAsync(z => z.Id == id);
|
||||||
}
|
}
|
||||||
return await ct.Contract.AsNoTracking().FirstOrDefaultAsync(z => z.Id == WoContractId);
|
return mContractInEffect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user