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); }