Exemplo n.º 1
0
        /// <summary>
        /// 首页
        /// </summary>
        /// <returns></returns>
        public ActionResult List(int?page)
        {
            var model = new NewsListModel
            {
                PageIndex = page.HasValue ? page.Value : 0
            };

            model.Newses = GetNewses(model);
            if (model.Newses == null || model.Newses.Count == 0)
            {
                return(Content(""));
            }
            return(View(GetViewPath("~/Views/News/_News.cshtml"), model));
        }
Exemplo n.º 2
0
        public ActionResult News()
        {
            var lngId = 1;

            if (Session["lngId"] != null)
            {
                lngId = (int)Session["lngId"];
            }

            NewsListModel model = NewsBuilder.BuildNews(Db);

            model.ContentRight = Db.Labels.Where(m => m.ViewId == "News" && m.ElementId == "ContentRight" && m.LanguageId == lngId).FirstOrDefault().Text;
            ViewBag.Link       = 4;
            return(View(model));
        }
Exemplo n.º 3
0
        /// <summary>
        /// 新闻列表
        /// </summary>
        public ActionResult List()
        {
            string newsTitle  = WebHelper.GetQueryString("newsTitle");
            int    newsTypeId = WebHelper.GetQueryInt("newsTypeId");
            int    page       = WebHelper.GetQueryInt("page");

            string        condition = News.GetNewsListCondition(newsTypeId, newsTitle);
            PageModel     pageModel = new PageModel(15, page, News.GetNewsCount(condition));
            NewsListModel model     = new NewsListModel()
            {
                PageModel    = pageModel,
                NewsList     = News.GetNewsList(pageModel.PageSize, pageModel.PageNumber, condition),
                NewsTitle    = newsTitle,
                NewsTypeId   = newsTypeId,
                NewsTypeList = News.GetNewsTypeList()
            };

            return(View(model));
        }
        public NewsListViewModel GetNewsList(string parentId, int page = 1, int pageSize = 6, List <string> filters = null, bool videosOnly = false, string queryFilter = "")
        {
            var vm = new NewsListViewModel();

            vm.PageSize    = pageSize;
            vm.CurrentPage = page;
            vm.VideosOnly  = videosOnly;
            vm.ParentPage  = parentId;

            var parentItem = context.Database.GetItem(parentId);
            var items      = this.Repository.Get(parentItem);

            if (filters == null)
            {
                filters = new List <string>();
            }

            PopulateCategories(vm, filters, parentItem, queryFilter);

            var articles = items.AsQueryable();

            if (filters?.Any() ?? false)
            {
                articles = articles.Where(a => filters.Any(f => a[Templates.NewsArticle.Fields.Category].Contains(f)));
            }

            if (videosOnly)
            {
                articles = articles.Where(a => !string.IsNullOrWhiteSpace(a[Templates.NewsArticle.Fields.MediaVideoLink]));
            }

            vm.Total = articles.Count();

            foreach (var article in articles.Skip(pageSize * (page - 1)).Take(vm.PageSize))
            {
                var model = new NewsListModel(article);
                vm.PagedItems.Add(model);
            }

            return(vm);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 新闻列表
        /// </summary>
        public ActionResult NewsList(string newsTitle, string sortColumn, string sortDirection, int newsTypeId = 0, int pageSize = 15, int pageNumber = 1)
        {
            string condition = AdminNews.AdminGetNewsListCondition(newsTypeId, newsTitle);
            string sort      = AdminNews.AdminGetNewsListSort(sortColumn, sortDirection);

            PageModel pageModel = new PageModel(pageSize, pageNumber, AdminNews.AdminGetNewsCount(condition));

            NewsListModel model = new NewsListModel()
            {
                NewsList      = AdminNews.AdminGetNewsList(pageModel.PageSize, pageModel.PageNumber, condition, sort),
                PageModel     = pageModel,
                SortColumn    = sortColumn,
                SortDirection = sortDirection,
                NewsTypeId    = newsTypeId,
                NewsTitle     = newsTitle
            };

            ShopUtils.SetAdminRefererCookie(string.Format("{0}?pageNumber={1}&pageSize={2}&sortColumn={3}&sortDirection={4}&newsTypeId={5}&newsTitle={6}",
                                                          Url.Action("newslist"),
                                                          pageModel.PageNumber,
                                                          pageModel.PageSize,
                                                          sortColumn,
                                                          sortDirection,
                                                          newsTypeId,
                                                          newsTitle));
            List <SelectListItem> list = new List <SelectListItem>();

            list.Add(new SelectListItem()
            {
                Text = "全部类型", Value = "0"
            });
            foreach (NewsTypeInfo newsTypeInfo in AdminNews.GetNewsTypeList())
            {
                list.Add(new SelectListItem()
                {
                    Text = newsTypeInfo.Name, Value = newsTypeInfo.NewsTypeId.ToString()
                });
            }
            ViewData["newsTypeList"] = list;
            return(View(model));
        }
Exemplo n.º 6
0
        //
        // GET: /News/


        public ActionResult Index()
        {
            BLLNews bll = new BLLNews();
            //获取所有新闻
            List <NewsInfo> listNews = bll.GetData();

            NewsListModel modelList = new NewsListModel(listNews);

            //判断用户是否登录
            if (Session["UserId"] != null)
            {
                ViewBag.IsLogOn = true;
            }
            else
            {
                ViewBag.IsLogOn = false;
            }

            //模型传递给视图
            return(View(modelList.NewsList));
        }
Exemplo n.º 7
0
        private void FillNews()
        {
            var currentLanguage = LanguageUtil.GetLanguage();

            var entities = (from n in DataContext.LP_News
                            where n.DateDeleted == null && (n.Language == currentLanguage || n.Language == null || n.Language == "")
                            orderby n.NewsDate descending
                            select n).ToList();

            var converter = new NewsEntityModelConverter(DataContext);

            var models = (from n in entities
                          let m = converter.Convert(n)
                                  select m).ToList();

            var model = new NewsListModel
            {
                List = models
            };

            newsListControl.Model = model;
        }
Exemplo n.º 8
0
        public ActionResult NewsModule(Int16 Nw_Type)
        {
            NewsListModel lmd = new NewsListModel();
            DataSet       ds  = new DataSet();

            Connection.Connection con = new Connection.Connection();
            ds          = con.NewsData(Nw_Type, 5);
            lmd.Nw_Type = Nw_Type;
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                lmd.NewsItems.Add(new NewsModel
                {
                    Nw_Id               = Convert.ToInt32(dr["Nw_Id"]),
                    Nw_Date             = Convert.ToDateTime(dr["Nw_Date"]),
                    Nw_ShortDescription = dr["Nw_ShortDescription"].ToString(),
                    Nw_Title            = dr["Nw_Title"].ToString(),
                    User_Name           = dr["User_Name"].ToString(),
                    Nw_Photo1           = dr["Nw_Photo1"].ToString()
                });
            }
            return(View(lmd));
        }
Exemplo n.º 9
0
        /// <summary>
        /// 新闻列表
        /// </summary>
        public ActionResult NewsList(string newsTitle, int newsTypeId = 0, int pageSize = 15, int pageNumber = 1)
        {
            string condition = AdminNews.AdminGetNewsListCondition(newsTypeId, newsTitle);

            PageModel pageModel = new PageModel(pageSize, pageNumber, AdminNews.AdminGetNewsCount(condition));

            List <SelectListItem> newsTypeList = new List <SelectListItem>();

            newsTypeList.Add(new SelectListItem()
            {
                Text = "全部类型", Value = "0"
            });
            foreach (NewsTypeInfo newsTypeInfo in AdminNews.GetNewsTypeList())
            {
                newsTypeList.Add(new SelectListItem()
                {
                    Text = newsTypeInfo.Name, Value = newsTypeInfo.NewsTypeId.ToString()
                });
            }

            NewsListModel model = new NewsListModel()
            {
                NewsList     = AdminNews.AdminGetNewsList(pageModel.PageSize, pageModel.PageNumber, condition),
                PageModel    = pageModel,
                NewsTypeId   = newsTypeId,
                NewsTypeList = newsTypeList,
                NewsTitle    = newsTitle
            };

            MallUtils.SetAdminRefererCookie(string.Format("{0}?pageNumber={1}&pageSize={2}&newsTypeId={3}&newsTitle={4}",
                                                          Url.Action("newslist"),
                                                          pageModel.PageNumber,
                                                          pageModel.PageSize,
                                                          newsTypeId,
                                                          newsTitle));

            return(View(model));
        }
Exemplo n.º 10
0
        public static NewsListModel BuildNews(DASEntities db)
        {
            NewsListModel model = new NewsListModel();


            int languageId = (int)HttpContext.Current.Session["lngId"];

            model.NewsList = db.News.Where(l => l.LanguageId == languageId && l.Archive == false).Select(n => new NewsModel()
            {
                NewsId = n.NewsId, Name = n.Name, Text = n.Text, Year = n.Year, Ord = n.Ord, Archive = n.Archive, LanguageId = n.LanguageId
            }).OrderByDescending(l => l.Year).ThenByDescending(l => l.Ord).ToList();

            IList <int> pomArch = db.News.Include("Archive").Where(l => l.LanguageId == languageId && l.Archive == true).Select(k => k.Archives.FirstOrDefault().ArchiveId).Distinct().ToList();

            string archiveLbl = LabelCache.GetLabel("Home", "lblArchive");
            string newsLbl    = LabelCache.GetLabel("Home", "lblNovosti");

            var list = db.Archives.OrderByDescending(l => l.Year).ToList();

            model.ArchiveList = new List <ArchiveModel>();
            foreach (var item in pomArch)
            {
                Archive temp = list.OrderByDescending(m => m.Year).FirstOrDefault(b => b.ArchiveId == item);
                model.ArchiveList.Add(new ArchiveModel()
                {
                    ArchiveId = temp.ArchiveId, Name = archiveLbl + " " + temp.Year
                });
            }

            model.ArchiveList.Add(new ArchiveModel()
            {
                ArchiveId = 0, Name = newsLbl
            });
            model.ArchiveList       = model.ArchiveList.OrderByDescending(m => m.ArchiveId).ToList();
            model.SelectedArchiveId = 0;

            return(model);
        }
        private NewsListViewModel GetNewsListInternal(string parentId, int page = 1, int pageSize = 6, List <string> tags = null, bool videosOnly = false)
        {
            var vm = new NewsListViewModel();

            for (var i = 0; i < pageSize; i++)
            {
                var model = new NewsListModel();
                model.Title            = $"News Item {i + 1}";
                model.Summary          = "Lorem ipsum summary for news item in list view.";
                model.BackgroundImage  = "https://dummyimage.com/400x300/000/fff&text=News+Image";
                model.DetailsLink.Text = "Read More";
                model.DetailsLink.Url  = "#";

                vm.PagedItems.Add(model);
            }

            vm.CurrentPage = page;
            vm.PageSize    = pageSize;
            vm.Total       = 64;

            vm.Tags.Add(new NewsFilterItem()
            {
                Name = "Hunting Tactics", Key = "hunting-tactics"
            });
            vm.Tags.Add(new NewsFilterItem()
            {
                Name = "Gun Maintenance", Key = "gun-maintenance"
            });
            vm.Tags.Add(new NewsFilterItem()
            {
                Name = "Shooting Tips", Key = "shooting-tips"
            });

            vm.VideosOnly = videosOnly;

            return(vm);
        }
Exemplo n.º 12
0
        /// <summary>
        /// 新闻列表
        /// </summary>
        public ActionResult List()
        {
            string newsTitle  = WebHelper.GetQueryString("newsTitle");
            int    newsTypeId = WebHelper.GetQueryInt("newsTypeId");
            int    page       = WebHelper.GetQueryInt("page");

            if (!SecureHelper.IsSafeSqlString(newsTitle))
            {
                return(PromptView(WorkContext.UrlReferrer, "您搜索的新闻不存在"));
            }

            string        condition = News.GetNewsListCondition(newsTypeId, newsTitle);
            PageModel     pageModel = new PageModel(10, page, News.GetNewsCount(condition));
            NewsListModel model     = new NewsListModel()
            {
                PageModel    = pageModel,
                NewsList     = News.GetNewsList(pageModel.PageSize, pageModel.PageNumber, condition),
                NewsTitle    = newsTitle,
                NewsTypeId   = newsTypeId,
                NewsTypeList = News.GetNewsTypeList()
            };

            return(View(model));
        }
        private NewsPromoSectionViewModel GetNewsSection(int page = 1, int pageSize = 3, List <string> filters = null, List <string> types = null)
        {
            var vm = new NewsPromoSectionViewModel();

            for (var i = 0; i < pageSize; i++)
            {
                var model = new NewsListModel();
                model.Title            = $"News Item {i + 1}";
                model.Summary          = "Lorem ipsum summary for news item in list view.";
                model.BackgroundImage  = "https://dummyimage.com/600x400/000/fff&text=News+Image";
                model.DetailsLink.Text = "Read More";
                model.DetailsLink.Url  = "/expert-advice";

                vm.Articles.Add(model);
            }

            vm.DetailsPage = new Glass.Mapper.Sc.Fields.Link()
            {
                Text = "More", Url = "/expert-advice"
            };
            vm.Title = "Section Title";

            return(vm);
        }
Exemplo n.º 14
0
        private async void loadNewsListdata(string CategoryId, string CId)
        {
            //MainFrame.IsVisible = false;

            try
            {
                HttpRequestWrapper wrapper = new HttpRequestWrapper();
                List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >();
                parameters.Add(new KeyValuePair <string, string>("company_code", Constant.CompanyID));
                if (AppData.UserId != "")
                {
                    parameters.Add(new KeyValuePair <string, string>("user_id", AppData.UserId));
                }
                parameters.Add(new KeyValuePair <string, string>("category_id", string.IsNullOrEmpty(CategoryId) ? "1" : CategoryId));
                if (CategoryId == "2")
                {
                    parameters.Add(new KeyValuePair <string, string>("city_id", CId));
                }
                else
                {
                    parameters.Add(new KeyValuePair <string, string>("city_id", ""));
                }
                var jsonstr = await wrapper.GetResponseAsync(Constant.APIs[(int)Constant.APIName.NewsList], parameters);

                if (jsonstr.ToString() == "NoInternet")
                {
                    NoInternet.IsVisible   = true;
                    MainFrame.IsVisible    = false;
                    CarouselZoos.IsVisible = false;
                    NoDataPage.IsVisible   = false;
                }
                else
                {
                    try
                    {
                        Items = JsonConvert.DeserializeObject <NewsListModel>(jsonstr);
                    }
                    catch
                    {
                        NoInternet.IsVisible   = false;
                        MainFrame.IsVisible    = false;
                        lstView.IsVisible      = false;
                        CarouselZoos.IsVisible = false;
                        NoDataPage.IsVisible   = true;
                    }
                    if (Items.data.total_news <= 0)
                    {
                        NoDataPage.IsVisible = true;
                        MainFrame.IsVisible  = false;
                    }
                    MainFrame.IsVisible = true;
                    //lstView.ItemsSource = Items.data.news_list;
                    ObservableCollection <BreaingNews> featured_news_list = new ObservableCollection <BreaingNews>();
                    if (Items.data.featured_news_list.Count() > 0)
                    {
                        foreach (News_List news in Items.data.featured_news_list)
                        {
                            featured_news_list.Add(new BreaingNews
                            {
                                ImageUrl = news.banner_image,
                                Name     = news.news_title,
                                Id       = news.news_id.ToString()
                            });
                        }

                        CarouselZoos.IsVisible = true;
                    }
                    else
                    {
                        CarouselZoos.IsVisible = false;
                    }

                    lstView.ItemsSource = Items.data.news_list;
                    //lstView.HeightRequest = (Items.data.news_list.Count() * lstView.RowHeight) + 5;
                    if (Items.data.total_news > 0)
                    {
                        if (featured_news_list.Count() > 0)
                        {
                            model.breaingNews      = featured_news_list;
                            BindingContext         = model;
                            CarouselZoos.IsVisible = true;
                        }
                    }
                    else
                    {
                        CarouselZoos.IsVisible = false;
                    }

                    lstView.ItemAppearing += (sender, e) =>
                    {
                        if (isLoading || Items.data.news_list.Count() == 0)
                        {
                            return;
                        }
                        var listitem = e.Item.ToString();

                        if (((News_List)e.Item).news_id.ToString() == Items.data.news_list[(Items.data.news_list.Count() - 1)].news_id.ToString())
                        {
                            if (currentPage == Items.data.current_page)
                            {
                                if (Items.data.total_pages != Items.data.current_page)
                                {
                                    currentPage++;
                                    LoadItems();
                                }
                            }
                        }
                    };
                    MainFrame.IsVisible = true;
                }
            }
            catch (Exception ex)
            {
            }


            Loader.IsVisible = false;
            lstView.IsPullToRefreshEnabled = true;
            lstView.RefreshCommand         = PullToRefreshCommand;
            lstView.IsRefreshing           = IsRefreshing;
            lstView.SetBinding(ListView.IsRefreshingProperty, "IsRefreshing");
        }
Exemplo n.º 15
0
        //
        // GET: /NewsList/

        public ActionResult NewsList(NewsListModel model)
        {
            return(View(model));
        }
 public ActionResult SaveNews(NewsListModel Lmd)
 {
     return(View());
 }
Exemplo n.º 17
0
        /// <summary>
        /// 首页
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            var model = new NewsListModel();

            return(View(GetViewPath("~/Views/News/index.cshtml"), model));
        }
        private async void loadNewsListdata(string CategoryId)
        {
            NoInternet.IsVisible = false;
            NoDataPage.IsVisible = false;
            MainFrame.IsVisible  = false;
            Loader.IsVisible     = true;
            await Task.Delay(1000);

            try
            {
                HttpRequestWrapper wrapper = new HttpRequestWrapper();
                List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >();
                parameters.Add(new KeyValuePair <string, string>("company_code", Constant.CompanyID));
                parameters.Add(new KeyValuePair <string, string>("user_id", AppData.UserId));
                parameters.Add(new KeyValuePair <string, string>("category_id", string.IsNullOrEmpty(CategoryId) ? "1" : CategoryId));
                parameters.Add(new KeyValuePair <string, string>("city_id", AppData.UserCityId));
                var jsonstr = await wrapper.GetResponseAsync(Constant.APIs[(int)Constant.APIName.NewsList], parameters);

                if (jsonstr.ToString() == "NoInternet")
                {
                    NoInternet.IsVisible = true;
                    MainFrame.IsVisible  = false;
                }
                else
                {
                    Items = JsonConvert.DeserializeObject <NewsListModel>(jsonstr);
                    if (Items.data.total_news <= 0)
                    {
                        NoDataPage.IsVisible = true;
                        MainFrame.IsVisible  = false;
                    }
                }


                //lstView.ItemsSource = Items.data.news_list;
                ObservableCollection <BreaingNews> featured_news_list = new ObservableCollection <BreaingNews>();
                foreach (News_List news in Items.data.featured_news_list)
                {
                    featured_news_list.Add(new BreaingNews
                    {
                        ImageUrl = news.banner_image,
                        Name     = news.news_title,
                        Id       = news.news_id.ToString()
                    });
                }

                lstView.ItemsSource = Items.data.news_list;
                if (featured_news_list.Count() > 0)
                {
                    model.breaingNews      = featured_news_list;
                    BindingContext         = model;
                    CarouselZoos.IsVisible = true;
                }
                else
                {
                    CarouselZoos.IsVisible = false;
                }
            }
            catch (Exception ex)
            {
            }

            MainFrame.IsVisible = true;
            Loader.IsVisible    = false;
        }