/// <summary> /// List of navigation /// </summary> /// <returns>List<NavigationViewModel></returns> public static List <NavigationViewModel> GetListNavigation() { try { using (var _context = new TDHEntities()) { //Return list List <NavigationViewModel> _returnList = new List <NavigationViewModel>(); //Get data from database var _list = _context.PROC_WEB_VIEW_HOME_LISTNAVIGATION().ToList(); //Get list navigation var _listNav = _list.Where(m => m.title.Length > 0).Select(m => m.id).Distinct().ToList(); foreach (var item in _listNav) { var _nav = _list.FirstOrDefault(m => m.id == item); if (_nav.title.Length == 0) { continue; } _list.Remove(_nav); _returnList.Add(new NavigationViewModel() { Title = _nav.title, Alias = _nav.alias, Categories = _list.Where(m => m.title == _nav.title && m.title.Length > 0) .Select(m => new CategoryViewModel() { Title = m.category_title, Alias = m.category_alias }) .ToList() }); } //Return list return(_returnList); } } catch (Exception ex) { throw new UserException(FILE_NAME, MethodInfo.GetCurrentMethod().Name, 500, ErrorMessage.ErrorService, ex); } }