Basit Nisar

Basit Nisar

  • 1.6k
  • 84
  • 11.3k

i want to add a check for [contractclaimstatustypeid=5]

Dec 14 2023 7:31 AM
#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!


Answers (1)