Example #1
0
 public bool UpdatePurchaseOrderDetailItem(List <PurchaseOrderDetail> podlist)
 {
     try
     {
         foreach (PurchaseOrderDetail i in podlist) //updates all purchase order detail status
         {
             podrepo.UpdatePurchaseOrderDetail(i);
         }
         PurchaseOrder po = porepo.FindPOByPOid((int)podlist[0].PurchaseOrderId); //retrieving back the parent PO of the purchaseorderdetail
         int           receivedcounter = 0;
         foreach (PurchaseOrderDetail j in po.PurchaseOrderDetails)               //checking status of every purchaseorderdetail in the PO. if status is received, counter++
         {
             if (j.Status == Status.PurchaseOrderDetailStatus.received)
             {
                 receivedcounter++;
             }
         }
         if (receivedcounter == po.PurchaseOrderDetails.Count()) //if counter of received matches total purchaseorderdetail, means all items received. update PO status to completed
         {
             po.Status = Status.PurchaseOrderStatus.completed;
             porepo.UpdatePoStatus(po);
         }
         return(true);
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }