Esempio n. 1
0
        /// <summary>
        /// Get two navigation item to show on footer
        /// Get top 2 navigation
        /// Get top 3 posts for each navigation.
        /// </summary>
        /// <returns>List<NavigationViewModel></returns>
        public static List <NavigationViewModel> Get2NavigationOnFooter()
        {
            try
            {
                using (var _context = new TDHEntities())
                {
                    //Return list
                    List <NavigationViewModel> _returnList = new List <NavigationViewModel>();

                    //Get data
                    var _list = _context.PROC_WEB_VIEW_HOME_2NavigationOnFooter().ToList();

                    //Get list navigation
                    var _listNav = _list.Where(m => m.title.Length > 0);
                    foreach (var item in _listNav)
                    {
                        _returnList.Add(new NavigationViewModel()
                        {
                            Title = item.title,
                            Alias = item.alias,
                            Posts = _list.Where(m => m.id == item.id && m.title.Length == 0)
                                    .Select(m => new PostViewModel()
                            {
                                Title      = m.post_title,
                                Alias      = m.post_alias,
                                Image      = m.post_image,
                                CreateDate = m.post_create_date
                            })
                                    .ToList()
                        });
                    }

                    //Return list
                    return(_returnList);
                }
            }
            catch (Exception ex)
            {
                throw new UserException(FILE_NAME, MethodInfo.GetCurrentMethod().Name, 500, ErrorMessage.ErrorService, ex);
            }
        }