public ActionResult Index(string searchString, string currentFilter, int?pageSize, int?page) { int topicsPerPage = (pageSize ?? 3); int pageNumber = (page ?? 1); var topics = topicBO.Get().Result; var model = new TopicListViewModel { PageSize = topicsPerPage, PageSizeList = new SelectList(new int[] { 3, 5, 10 }), PagedTopics = topics.ToPagedList(pageNumber, topicsPerPage) }; if (searchString != null) { page = 1; } else { searchString = currentFilter; } ViewBag.CurrentFilter = searchString; if (!string.IsNullOrEmpty(searchString)) { model.PageSize = topicsPerPage; model.PagedTopics = topics.Where(t => t.User.Name.Contains(searchString) || t.Title.Contains(searchString)).ToPagedList(pageNumber, topicsPerPage); } return(View(model)); }
public IActionResult Index(int page = 1) { if (page <= 1) { page = 1; } var list = _topicService.GetLastedList(page, 15); var model = new TopicListViewModel(); model.List = list.ReplaceTo(t => t.ToTopicListItemModel()); var lastReplyList = _replyService.GetLastByTopicIds(list.Select(t => t.Id).ToArray()); foreach (var item in model.List) { var reply = lastReplyList.FirstOrDefault(t => t.TopicId == item.Id); if (reply != null) { item.LastReply = reply.ToModel(); } } return(View(model)); }
public HomeViewModel() { Overview = new OverviewViewModel(); Topics = new TopicListViewModel(); UpcomingSessions = new UpcomingSessionsViewModel(); Tweets = new TweetsViewModel(); }
public HomeViewModel() { Overview = new OverviewViewModel(); Topics = new TopicListViewModel(); UpcomingSessions = new UpcomingSessionsViewModel(); Tweets = new TweetsViewModel(); }
public ActionResult Index() { TopicListViewModel viewModel = new TopicListViewModel { ListTopic = _topicServic.GetList(10, 1) }; return(View(viewModel)); }
// GET: Admin/AdminTopic public ActionResult Index() { using (UnitOfWorkManager.NewUnitOfWork()) { TopicListViewModel viewModel = new TopicListViewModel { ListTopic = _topicServic.GetList(10, 1) }; return(View(viewModel)); } }
public ActionResult Index(string s, int?p) { int limit = 12; var count = _topicServic.GetCount(s); var Paging = CalcPaging(limit, p, count); var model = new TopicListViewModel { Paging = Paging, ListTopic = _topicServic.GetList(s, limit, Paging.Page) }; return(View(model)); }
public ActionResult PopupSelect(string seach, string cat, int?p) { int limit = 10; var count = _topicServic.GetCount(); var Paging = CalcPaging(limit, p, count); var viewModel = new TopicListViewModel { Paging = Paging, ListTopic = _topicServic.GetList(limit, Paging.Page) }; return(PartialView(viewModel)); }
public ActionResult List([FromQuery] int?page = null) { var topicCount = _topicRepo.All().Count(); var actualPage = NormalizePaging(page, topicCount, out var allPage); var topicList = _topicRepo.All() .OrderByDescending(topic => topic.CreatedAtUtc) .Skip((actualPage - 1) * PageSize) .Take(PageSize) .ToList(); var listModel = new TopicListViewModel { Topics = topicList, CurrentPage = actualPage, HasPreviousPage = actualPage > 1, HasNextPage = actualPage < allPage }; return(View(listModel)); }
public IViewComponentResult Invoke() { int count = 10; if (!User.Identity.IsAuthenticated) { return(Content("")); } var userId = User.Identity.GetUserId <int>(); var list = _topicService.GetLastedList(1, count, userId: userId); TopicListViewModel model = new TopicListViewModel(); model.List = list.ReplaceTo((s) => { return(s.ToTopicListItemModel()); }); return(View(model)); }
// GET: topic public async Task <IActionResult> Index(long?tid, string title, int?id) { int pagenumber = 1; if (id != null) { pagenumber = (int)id; } if (tid == null) { return(Redirect(Config.GetUrl("forums"))); } var model = new TopicListViewModel(); model.isAllowed = true; model.isAdmin = false; model.DisablePost = false; if (title != "") { model.TopicTitle = UtilityBLL.UppercaseFirst(UtilityBLL.ReplaceHyphinWithSpace(title), true); } else { model.TopicTitle = "default-topic"; } model.TopicID = (long)tid; model.QueryOptions = new ForumTopicEntity() { pagenumber = pagenumber, pagesize = Jugnoon.Settings.Configs.GeneralSettings.pagesize }; model.TotalRecords = await ForumTopicPostsBLL.Count(_context, new ForumTopicEntity() { id = model.TopicID, ispublic = true, loadall = true }); if (model.TotalRecords == 0) { model.isAllowed = false; model.DetailMessage = SiteConfig.forumLocalizer["norecordfound"].Value; return(View(model)); } model.DisablePost = false; var _lst = await ForumTopicPostsBLL.LoadItems(_context, new ForumTopicEntity() { id = model.TopicID, loadall = true, pagenumber = model.QueryOptions.pagenumber, pagesize = model.QueryOptions.pagesize, singlepost = false }); if (_lst.Count > 0) { if (_lst[0].isadult == 1) { // 1:-> adult content, 0:-> non adult content var getValue = HttpContext.Session.GetString("adultmember"); if (getValue == null) { string surl = Forum_Urls.Prepare_Topic_Url(_lst[0].id, _lst[0].title, false); return(Redirect(Config.GetUrl("home/validateadult?surl=" + WebUtility.UrlEncode(surl) + ""))); } } // increment views await ForumTopicBLL.Increment_Views(_context, model.TopicID, _lst[0].views); // other settings model.ForumID = _lst[0].forumid; string forumtitle = _lst[0].forum_title; model.ForumTitle = forumtitle; // load topic and posts model.Topics = _lst; model.DefaultUrl = "topic/" + model.TopicID + "/" + title; model.PaginationUrl = "topic/" + model.TopicID + "/" + title + "/[p]"; string _title = _lst[0].title; if (model.QueryOptions.pagenumber > 1) { _title = _title + " Page: " + model.QueryOptions.pagenumber; } string _desc = UtilityBLL.StripHTML(_lst[0].description); if (_desc.Length > 80) { _desc = _desc.Substring(0, 80); } model.HeadingTitle = _title; ViewBag.title = _title; ViewBag.description = _desc; } else { model.isAllowed = false; model.DetailMessage = SiteConfig.forumLocalizer["norecordfound"].Value; return(View(model)); } return(View(model)); }
public async Task <IActionResult> post(long?id) { if (id == null) { return(Redirect(Config.GetUrl("forums"))); } var model = new TopicListViewModel(); model.isAllowed = true; model.isAdmin = false; model.DisablePost = true; model.TopicTitle = ForumTopicBLL.Return_Value(_context, (long)id, "title"); model.TopicID = (long)id; model.QueryOptions = new ForumTopicEntity() { singlepost = true, id = model.TopicID, ispublic = true, loadall = true, pagenumber = 1 }; model.DisablePost = false; var _lst = await ForumTopicPostsBLL.LoadItems(_context, model.QueryOptions); if (_lst.Count > 0) { /*if (_lst[0].isadult == 1) * { * // 1:-> adult content, 0:-> non adult content * if (Session["adultmember"] == null) * { * string surl = Forum_Urls.Prepare_Topic_Url(_lst[0].topicid, _lst[0].title, false); * return Redirect(Config.GetUrl("home/validateadult?surl=" + WebUtility.UrlEncode(surl) + "")); * } * }*/ // increment views await ForumTopicBLL.Increment_Views(_context, model.TopicID, _lst[0].views); // other settings int forumid = _lst[0].forumid; string forumtitle = _lst[0].forum_title; model.ForumTitle = forumtitle; // load topic and posts model.Topics = _lst; string _title = _lst[0].title + " Post: " + model.TopicID; string _desc = UtilityBLL.StripHTML(_lst[0].description); if (_desc.Length > 80) { _desc = _desc.Substring(0, 80); } model.HeadingTitle = _title; ViewBag.title = _title; ViewBag.description = _desc + " Post: " + model.TopicID; } else { model.isAllowed = false; model.DetailMessage = SiteConfig.forumLocalizer["norecordfound"].Value; return(View(model)); } return(View(model)); }