Пример #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 IList <Menu> GetMenusByRestaurant(int restaurantId)
 {
     try
     {
         return(_menuService.GetMenusByRestaurant(restaurantId));
     }
     catch (EnterpriseException enterpriseException)
     {
         throw new FaultException <EnterpriseException>(enterpriseException, enterpriseException.Message, new FaultCode(enterpriseException.ErrorCode));
     }
     catch (Exception exception)
     {
         throw new FaultException <Exception>(exception, exception.Message);
     }
 }