Exemplo n.º 1
0
        public bool DeleteRestaurant(int id)
        {
            try
            {
                var menus = _menuService.GetMenusByRestaurant(id);

                foreach (var menu in menus)
                {
                    //delete menuItem
                    var menuItems = _menuService.GetMenuItemByMenu(menu.Id);
                    foreach (var menuItem in menuItems)
                    {
                        _menuService.DeleteMenuItem(menuItem.Id);
                    }
                    //delete menu
                    _menuService.DeleteMenu(menu.Id);
                }
                //delete restaurant
                return(_restaurantService.DeleteRestaurant(id));
            }
            catch (EnterpriseException enterpriseException)
            {
                throw new FaultException <EnterpriseException>(enterpriseException, enterpriseException.Message, new FaultCode(enterpriseException.ErrorCode));
            }
            catch (Exception exception)
            {
                throw new FaultException <Exception>(exception, exception.Message);
            }
        }
        public bool DeleteMenu(int id)
        {
            try
            {
                //delete all menu item first
                var menuItems = _menuService.GetMenuItemByMenu(id);
                foreach (var menuItem in menuItems)
                {
                    _menuService.DeleteMenuItem(menuItem.Id);
                }

                //delete menu
                return(_menuService.DeleteMenu(id));
            }
            catch (EnterpriseException enterpriseException)
            {
                throw new FaultException <EnterpriseException>(enterpriseException, enterpriseException.Message, new FaultCode(enterpriseException.ErrorCode));
            }
            catch (Exception exception)
            {
                throw new FaultException <Exception>(exception, exception.Message);
            }
        }