コード例 #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;
     }
 }
        public IHttpActionResult UpdatePODetail(PurchaseOrderDetailModel podetail)
        {
            string error = "";
            PurchaseOrderDetailModel ordm =
                PurchaseOrderDetailRepo.UpdatePurchaseOrderDetail(podetail, out error);

            if (error != "" || ordm == null)
            {
                if (error == ConError.Status.NOTFOUND)
                {
                    return(Content(HttpStatusCode.NotFound, "PO Not Found"));
                }
                return(Content(HttpStatusCode.BadRequest, error));
            }
            return(Ok(ordm));
        }