#region Validation to Check-out request cannot be Approved #782
int PendingApproved = 0;
if (contactAssignment.ClientId == 2)
{
var CountPendingApproved = (from IWI in db.InvoiceWorkItems
join VIWI in db.vw_InvoiceWorkItemSummary on IWI.ContactID equals VIWI.ContactID
where VIWI.ContactAssignmentID == contactAssignment.ContactAssignmentID
join ST in db.ContractClaimStatusTypes on IWI.ContractClaimStatusTypeID equals ST.ContractClaimStatusTypeID
where
(VIWI.BranchID == IWI.BranchID && VIWI.DeploymentReportID == IWI.DeploymentReportId)
&& VIWI.ContactAssignmentID == contactAssignment.ContactAssignmentID
&& IWI.IsDeleted == false && (IWI.ContractClaimStatusTypeID == 3)
select (new
{
IWI.InvoiceWorkItemID,
IWI.ContractClaimStatusTypeID
})).Distinct().ToList();
if (CountPendingApproved != null)
{
PendingApproved = CountPendingApproved.Count(ka => ka.ContractClaimStatusTypeID == 3);
}
}
else
{
PendingApproved = db.ContractInvoicePerCases.Where(x => x.ContactAssignmentID == contactAssignment.ContactAssignmentID && x.ContractClaimStatusTypeID == 3 && (x.IsDeleted ?? false) == false)
.Select(x => new { InvoiceWorkItemID = x.ContractInvoicePerCaseID, ContractClaimStatusTypeID = x.ContractClaimStatusTypeID })
.Union(db.ContractInvoicePerCaseBMs.Where(x => x.ContactAssignmentID == contactAssignment.ContactAssignmentID && x.ContractClaimStatusTypeID == 3 && (x.IsDeleted ?? 0) == 0)
.Select(x => new { InvoiceWorkItemID = x.ContractInvoicePerCaseBMID, ContractClaimStatusTypeID = x.ContractClaimStatusTypeID }))?.Count() ?? 0;
}
if (PendingApproved > 0)
{
return this.ResponseMessage(Request.CreateResponse(HttpStatusCode.BadRequest, new
{
Status = Global.Status.Invalid.ToString(),
Message = contactAssignment.ClientId == 2 ? Global.StatusMessage.CheckOutPendingInvoiceError : Global.StatusMessage.CheckOutPendingInvoiceErrorGeneric
}));
}
#endregion
In this region of code i need to add a check for contractclaimstatustypeid=5 instead of contractclaimstatustypeid=3 which means 3 = submitted and 5= approved i my post api should succesfully hit if contractclaimstatustypeid=5 only pleasee help or share the feedback on this Thanks!
Jayraj ChhayaPosted Dec 15, 2023, 5:56 AM
Problem
The problem in the code is that it checks for
ContractClaimStatusTypeIDequal to 3 (IWI.ContractClaimStatusTypeID == 3) instead of 5 (IWI.ContractClaimStatusTypeID == 5) in theCountPendingApprovedquery.Cause
The cause of the problem is that the code is checking for the wrong
ContractClaimStatusTypeIDvalue. It should be checking for 5 (approved) instead of 3 (submitted).Solution
To fix the issue and add a check for
ContractClaimStatusTypeIDequal to 5, you need to modify the code in theCountPendingApprovedquery. ReplaceIWI.ContractClaimStatusTypeID == 3withIWI.ContractClaimStatusTypeID == 5in the query.Here's the modified code:
The code will now check for
ContractClaimStatusTypeIDequal to 5 (approved) instead of 3 (submitted).Adding a Check for ContractClaimStatusTypeID=5
To add a check for
ContractClaimStatusTypeIDequal to 5 (approved), you can modify the code in theifcondition wherePendingApprovedis checked.Replace
PendingApproved > 0withPendingApproved > 0 && contactAssignment.ContractClaimStatusTypeID == 5in theifcondition.Here's the modified code:
The code will only return a response if
PendingApprovedis greater than 0 andContractClaimStatusTypeIDis equal to 5 (approved).This change ensures that the post API will only be hit if
ContractClaimStatusTypeIDis 5 (approved), as requested.Remember to test the code thoroughly after making these modifications to ensure that it behaves as expected.