Example #1
0
        public bool MarkPickupLineAsPickedup(int?pickupLineId)
        {
            var result = false;

            try
            {
                var oldLine = _pickupManager.RetrievePickupLineById(pickupLineId);
                var newLine = _pickupManager.RetrievePickupLineById(pickupLineId);
                newLine.PickupStatus = true;
                result = _pickupManager.UpdatePickupLine(oldLine, newLine);

                //Checking to see if there are any pickup lines that haven't been picked up
                //Before updating the company order to show that the order has been fully picked up
                var pickupLines = _pickupManager.RetrievePickupLinesByPickupId(oldLine.PickupId);
                if (pickupLines.Count(l => l.PickupStatus == false) == 0)
                {
                    var pickup       = _pickupManager.RetrievePickupById(oldLine.PickupId);
                    var companyOrder = _companyOrderManager.RetrieveCompanyOrderWithLinesById((int)pickup.CompanyOrderId);
                    _companyOrderManager.UpdateCompanyOrderHasArrived(companyOrder.CompanyOrderID, companyOrder.HasArrived, true);
                }
            }
            catch
            {
                result = false;
            }

            return(result);
        }