Пример #1
0
        /// <summary>
        /// Cancelling bank clearance
        /// </summary>
        /// <param name="hostUnit"></param>
        public void Cancel_Clearance(HostingUnit hostUnit)
        {
            List <HostingUnit> hostsList  = Dal.Get_Hosting_Unit_List();
            List <Order>       ordersList = Dal.Get_Order_List();

            foreach (var unit in hostsList)
            {
                if (unit.HostingUnitKey == hostUnit.HostingUnitKey) //We found the hosting unit
                {
                    foreach (var order in ordersList)               //Checking if there is an open order connected to it
                    {
                        if (order.HostingUnitKey == hostUnit.HostingUnitKey)
                        {
                            if (order.Status == Order_Status.Not_Handled)
                            {
                                throw new Can_tEraseException("Can't cancel bank clearance.There is an order connected to it ! From BL");
                            }
                        }
                    }
                    //Updating the host (cancelling the clearance)
                    try
                    {
                        unit.Owner.CollectionClearance = Clearance.No;
                        Dal.Update_Hosting_Unit(unit.Clone());
                    }
                    catch (KeyNotFoundException ex)
                    {
                        throw new KeyNotFoundException(ex.Message);
                    }
                    return;
                }
            }
        }