public bool UpdateDeliveryStatus(int deliveryId, string newDeliveryStatus, [FromBody] string verificationImage)
        {
            bool result = false;

            try
            {
                Delivery oldDelivery = _deliveryManager.RetrieveDeliveryById(deliveryId);
                Delivery newDelivery = _deliveryManager.RetrieveDeliveryById(deliveryId);
                newDelivery.StatusId = newDeliveryStatus;
                try
                {
                    byte[] verificationAsBytes = Encoding.ASCII.GetBytes(verificationImage);
                    newDelivery.Verification = verificationAsBytes;
                }
                catch
                {
                    byte[] verificationAsBytes = null;
                    newDelivery.Verification = verificationAsBytes;
                }

                if (_deliveryManager.UpdateDelivery(oldDelivery, newDelivery))
                {
                    result = true;
                }
                else
                {
                    result = false;
                }

                List <Delivery> ordersDeliveries = _deliveryManager.RetrieveDeliveriesByOrderId((int)oldDelivery.OrderId);
                bool            allDelivered     = true;
                foreach (Delivery d in ordersDeliveries)
                {
                    if (d.StatusId != "Delivered")
                    {
                        allDelivered = false;
                    }
                }

                if (allDelivered)
                {
                    ProductOrder oldOrder = _orderManager.retrieveProductOrderDetails((int)oldDelivery.OrderId);
                    ProductOrder newOrder = _orderManager.retrieveProductOrderDetails((int)oldDelivery.OrderId);
                    newOrder.OrderStatusId = "Delivered";
                    newOrder.HasArrived    = true;
                    _orderManager.UpdateProductOrder(oldOrder, newOrder);
                }
            }
            catch
            {
                result = false;
            }

            return(result);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Victor Algarin
 /// Created: 2017/03/23
 /// </summary>
 /// <summary>
 /// Alissa Duffy
 /// Updated: 2017/04/24
 ///
 ///
 /// Displays Product Order Details.
 /// Standardized method.
 /// </summary>
 public void displayDetails()
 {
     try
     {
         _prodOrd             = _ordMgr.retrieveProductOrderDetails(orderID);
         txtOrderId.Text      = _prodOrd.OrderId.ToString();
         txtCustomerId.Text   = _prodOrd.CustomerId.ToString();
         txtOrderType.Text    = _prodOrd.OrderTypeId;
         txtAddressType.Text  = _prodOrd.AddressType;
         txtDeliveryType.Text = _prodOrd.DeliveryTypeId;
         txtAmount.Text       = _prodOrd.Amount.ToString();
         txtOrderDate.Text    = _prodOrd.OrderDate.ToString();
         txtExpectedDate.Text = _prodOrd.DateExpected.ToString();
         txtDiscount.Text     = _prodOrd.Discount.ToString();
         txtOrderStatus.Text  = _prodOrd.OrderStatusId;
         txtUserAddress.Text  = _prodOrd.UserAddressId.ToString();
         txtHasArrived.Text   = _prodOrd.HasArrived.ToString();
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message);
     }
 }