public BasicResponse <MenuInfo> GetMenuById(MenuGetRequest menurequest)
        {
            var result       = _Repository.GetMenuById(menurequest.Id);
            var menuInfo     = ObjectConverter.Copy <MenuModel, MenuInfo>(result);
            var menuresponse = new BasicResponse <MenuInfo>();

            menuresponse.Data = menuInfo;
            return(menuresponse);
        }
 public MenuGetResponse Get(MenuGetRequest request)
 {
     return(Execute <MenuGetRequest, MenuGetResponse>(
                request,
                response =>
     {
         response.Menu = _menuFacade.Get(request.Id);
     }
                ));
 }
        public async Task <MenuGetResponse> MenuGet(MenuGetRequest request)
        {
            MenuGetResponse response = new MenuGetResponse();

            try
            {
                RMenu[] menus = await _menuService.GetByLanguageId(request.LanguageCurrentId);

                if (menus.Length > 0)
                {
                    if (!string.IsNullOrEmpty(request.Id))
                    {
                        RMenu currentMenu = menus.FirstOrDefault(p => p.Id == request.Id);
                        if (currentMenu != null)
                        {
                            menus = RMenu.RemoveCurrentTree(menus, currentMenu);
                        }
                    }
                    response.Parents = menus?.Where(p => p.Position == request.Position).Select(p => p.ToModel()).ToArray();
                }
                RLanguage[] languages = await _languageService.Get();

                if (languages.Length > 0)
                {
                    response.Languages = languages.Select(p => p.ToKeyValueModel()).ToArray();
                }
                if (!string.IsNullOrEmpty(request.Id))
                {
                    RMenu menu = await _menuService.Get(request.Id);

                    if (menu == null)
                    {
                        response.SetFail(BaseResponse.ErrorCodeEnum.MenuNotFound);
                        return(response);
                    }
                    response.Menu = menu.ToModel();
                }
                else
                {
                    response.Menu = new MenuModel()
                    {
                        LanguageId = request.LanguageId,
                        Position   = request.Position
                    };
                }
                response.SetSucess();
            }
            catch (Exception e)
            {
                response.SetFail(e);
                _logger.LogError(e, e.Message, request);
            }
            return(response);
        }
 public async Task <IActionResult> Get([FromBody] MenuGetRequest request)
 {
     try
     {
         MenuGetResponse response = new MenuGetResponse();
         var             results  = MenuGetRequestValidator.ValidateModel(request);
         if (results.IsValid)
         {
             response = await _menuAppService.MenuGet(request);
         }
         else
         {
             response.SetFail(results.Errors.Select(p => p.ToString()));
         }
         return(Json(response));
     }
     catch (Exception e)
     {
         _logger.LogError(e, Common.Common.GetMethodName());
         throw;
     }
 }
 public BasicResponse <MenuInfo> GetMenuById(MenuGetRequest menurequest)
 {
     return(_menuService.GetMenuById(menurequest));
 }
        public BasicResponse <MenuInfo> GetMenuById(MenuGetRequest menurequest)
        {
            var responseStr = HttpClientHelper.Post(Webapi + "/v1/Menu/Get?token=" + Token, JSONHelper.ToJSONString(menurequest));

            return(JSONHelper.ParseJSONString <BasicResponse <MenuInfo> >(responseStr));
        }