public CreateMenuItemResponse CreateMenuItem(CreateMenuItemRequest request)
        {
            CreateMenuItemResponse response = new CreateMenuItemResponse();
            MenuItem menuItem = new MenuItem();

            menuItem.MenuItemName = request.MenuItemName;
            menuItem.ParentId     = request.ParentId;
            menuItem.MenuItemUrl  = request.MenuItemUrl;

            if (menuItem.GetBrokenRules().Count() > 0)
            {
                response.Errors = menuItem.GetBrokenRules().ToList();
            }
            else
            {
                try {
                    _menuItemRepository.Add(menuItem);
                    _uow.Commit();
                    response.Errors = new List <BusinessRule>();
                } catch (Exception ex)
                {
                    List <BusinessRule> errors = new List <BusinessRule>();
                    do
                    {
                        errors.Add(new BusinessRule("DAL", "DAL_ERROR: " + ex.Message));
                        ex = ex.InnerException;
                    } while (ex != null);

                    response.Errors = errors;
                }
            }

            return(response);
        }
        public JsonResult Create(MenuItemDetailView vm)
        {
            CreateMenuItemRequest request = new CreateMenuItemRequest();

            request.MenuItemName = vm.MenuItemName;
            request.ParentId     = vm.ParentId;
            request.MenuItemUrl  = vm.MenuItemUrl;
            CreateMenuItemResponse response = _menuItemService.CreateMenuItem(request);

            return(Json(response));
        }