public virtual async Task ReloadData() { //TODO: Normalize news pull var parser = new HtmlParser(); var news = await ServiceBus.NewsService.CompanyNews(0, 10); if (ListNews.Count > 0) { ListNews.Clear(); } foreach (var newsDto in news) { var parseObj = parser.Parse(newsDto.body); var image = string.Empty; if (parseObj.Images.Length > 0) { image = parseObj.Images[0].Source; } var title = newsDto.title; var author = ServiceBus.ListUsers.FirstOrDefault(user => user.ServerUserId == newsDto.authorId); ListNews.Add(new NewsPreviewViewModel <NewsDto> { ImageUri = image, Title = title, Subtitle = $"{author.Name} {author.Surname} on {TimeConvertHelper.ConvertFromUnixTimestamp(newsDto.date)}", Dto = newsDto }); } }
public ActionResult Index() { var portalSearchNews = new PortalSearchNewsIndex { Start = 1, End = 4, Id = 0 }; var pTotal = 0; var ds = _newsDa.GetForPortalDetail(portalSearchNews, ref pTotal); var list = CBO.Fill2ListFromDataSet <News>(ds, typeof(News)); var listView = new ListNews { Collection = list }; ds = _projectDa.GetSpecial(); var listProject = CBO.Fill2ListFromDataSet <Project>(ds, typeof(Project)); var indexPortal = new IndexPortal() { LstNews = new ListNews() { Collection = list }, LstProject = new ListProject() { Collection = listProject } }; return(View(indexPortal)); }
private ListNews SearchNewsForPortal(PortalSearchNews portalSearchNews, out News news) { news = new News(); var total = 0; var ds = _newsDa.GetForPortalIndex(portalSearchNews, ref total); //var list = CBO.Fill2ListFromDataSet<News>(ds, typeof(News)); List <News> list = CBO <News> .FillCollectionFromDataSet(ds); var totalPage = Math.Ceiling((decimal)total / ConfigInfo.RecordOnPageIndex); var paging = HtmlControllHelpers.WritePagingPortal(totalPage, portalSearchNews.CurrentPage, total, ConfigInfo.RecordOnPageIndex); var listNews = new ListNews { Start = portalSearchNews.Start, Collection = list, Paging = paging, TotalRecord = total, TotalPage = totalPage, CurrentPage = portalSearchNews.CurrentPage }; ds = _newsDa.GetSpecialNews(); news = (News)CBO.FillObjectFromDataSet(ds, typeof(News)); return(listNews); }
protected void Doldur(string Code) { int newsID = (from n in db.News where n.IsActive == true join l in db.Language on n.LanguageID equals l.ID where l.Code == Code select n.ID).FirstOrDefault(); if (newsID == 0) { Code = "tr-TR"; } ListNews.DataSource = (from n in db.News where n.IsActive == true join l in db.Language on n.LanguageID equals l.ID where l.Code == Code orderby n.ID descending select new { BigWriting = (n.BigWriting.Length > 180) ? n.SmallWriting.Substring(0, 179) : n.SmallWriting, Title = n.Title, Image = n.Image, ID = n.ID }).ToList(); ListNews.DataBind(); }
public ListViewModel() { try { var parserService = new ParserService(); var count = parserService.Span.Count; Data = new ListNews[count]; Title = new string[count]; Span = new string[count]; for (int i = 0; i < count; i++) { Title[i] = Regex.Replace(parserService.Title[i].Groups["text"].Value, @"&#[8][2][2][0-1];", @"""").Replace("–", "—"); Span[i] = Regex.Replace(parserService.Span[i].Groups["text"].Value, @"&#[8][2][2][0-1];", @"""").Replace("–", "—"); Data[i] = new ListNews { Title = Title[i], Span = Span[i] }; } Lists = new List <ListNews>(count); Lists.AddRange(Data); } catch { } }
// [Authorize] public ActionResult Index(string sort) { ViewBag.DateSortParam = String.IsNullOrEmpty(sort) ? "Date" : ""; ViewBag.AuthorSortParam = sort == "Author" ? "author_desc" : "Author"; IEnumerable <News> ListNews; ListNews = mapper.Map <IEnumerable <NewsViewModel>, IEnumerable <News> >(MainService.NewsService.GetAllNews()); switch (sort) { case "author_desc": ListNews = ListNews.OrderByDescending(s => s.Author.Username); break; case "Author": ListNews = ListNews.OrderBy(s => s.Author.Username); break; case "Date": ListNews = ListNews.OrderBy(s => s.NewsCreated); break; default: ListNews = ListNews.OrderByDescending(s => s.NewsCreated); break; } return(View(ListNews)); }
private void ListNews_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { int i = ListNews.IndexFromPoint(e.X, e.Y); Console.WriteLine(i); if (i != -1) { selectedIndexForNewsContextMenu = i; ContextMenuForNews.Items[0].Text = CreateTitle(CurrentFeed.Items[i].Title); ContextMenuForNews.Show(MousePosition); } } }
public TableViewModel() { var image = new ParserService(); var count = image.Image.Count; Data = new ListNews[count]; Stroka = new string[count]; for (var i = 0; i < count; i++) { Stroka[i] = Regex.Replace(image.Image[i].Value, " [0-9][0-9][0-9][0-9][a-z]", "").Replace("srcset=\"", ""); Data[i] = new ListNews { SorceImage = Stroka[i] }; } ImageList = new List <ListNews>(count); ImageList.AddRange(Data); }
private ListNews SearchNews(SearchNewsRequest request) { var total = 0; var ds = _newsDa.Search(request, ref total); var lstNew = CBO.Fill2ListFromDataSet <News>(ds, typeof(News)); decimal totalPage = Math.Ceiling(((decimal)total / (decimal)ConfigInfo.RecordOnPage)); var paging = HtmlControllHelpers.WritePaging(totalPage, request.CurrentPage, total, ConfigInfo.RecordOnPage, "Tin tức"); var listNews = new ListNews { Start = request.Start, Collection = lstNew, Paging = paging, TotalRecord = total, TotalPage = totalPage, CurrentPage = request.CurrentPage }; return(listNews); }
public ActionResult GetSuggestNews(int id) { var portalSearchNews = new PortalSearchNewsIndex { Start = 1, End = 3, Id = id }; var pTotal = 0; var ds = _newsDa.GetForPortalDetail(portalSearchNews, ref pTotal); var list = CBO.Fill2ListFromDataSet <News>(ds, typeof(News)); var listView = new ListNews { Collection = list }; return(PartialView("_newsSuggest", listView)); }
public void AddListNews(ClassNews classNews) { ListNews.Add(classNews); }
protected void Doldur(string code, int ID) { ListService.DataSource = (from s in db.Services where s.IsActive == true join l in db.Language on s.LanguageID equals l.ID where l.Code == code orderby s.ID ascending select new { BigWriting = (s.BigWriting.Length > 150) ? s.BigWriting.Substring(0, 149) : s.BigWriting, Title = s.Title, Img = s.Image }).Take(4).ToList(); ListService.DataBind(); listReferance.DataSource = (from r in db.Referance where r.IsActive == true join l in db.Language on r.LanguageID equals l.ID where l.Code == code select r).ToList(); listReferance.DataBind(); ListNews.DataSource = (from n in db.News where n.IsActive == true join l in db.Language on n.LanguageID equals l.ID where l.Code == code orderby n.ID descending select new { SmallWriting = (n.SmallWriting.Length > 150) ? n.SmallWriting.Substring(0, 149) : n.SmallWriting, Title = n.Title, Image = n.Image, ID = n.ID }).Take(3).ToList(); ListNews.DataBind(); ListSolution.DataSource = (from s in db.Solution where s.IsActive == true join l in db.Language on s.LanguageID equals l.ID where l.Code == code orderby s.ID ascending select new { Title = s.Title, SmallWriting = (s.SmallWriting.Length > 150) ? s.SmallWriting.Substring(0, 149) : s.SmallWriting }).Take(4).ToList(); ListSolution.DataBind(); int firstSliderID = (from s in db.Slider where s.IsActive == true join l in db.Language on s.LanguageID equals l.ID where l.Code == code select s.ID).FirstOrDefault(); AnalitikBilisimSite.Model.Entities.Slider slider1 = (from s in db.Slider where s.ID == (firstSliderID) && s.IsActive == true && s.LanguageID == ID select s).FirstOrDefault(); AnalitikBilisimSite.Model.Entities.Slider slider2 = (from s in db.Slider where s.ID == (firstSliderID + 1) && s.IsActive == true && s.LanguageID == ID select s).FirstOrDefault(); AnalitikBilisimSite.Model.Entities.Slider slider3 = (from s in db.Slider where s.ID == (firstSliderID + 2) && s.IsActive == true && s.LanguageID == ID select s).FirstOrDefault(); ImageSlider1.ImageUrl = slider1.SliderURL; lblSliderTitle1.Text = slider1.sliderTitle; lblSliderWriting1.Text = slider1.SliderWriting; ImageSlider2.ImageUrl = slider2.SliderURL; lblSliderTitle2.Text = slider2.sliderTitle; lblSliderWriting2.Text = slider2.SliderWriting; ImageSlider3.ImageUrl = slider3.SliderURL; lblSliderTitle3.Text = slider3.sliderTitle; lblSliderWriting3.Text = slider3.SliderWriting; }