示例#1
0
 public MainPageViewModel(INavigationService navigationService)
     : base(navigationService)
 {
     Title        = "Blogs";
     _blogService = new BlogServices();
     Blogs        = new ObservableCollection <Blog>(_blogService.GetBlogs());
 }
示例#2
0
        public ActionResult Index(int?id)
        {
            string mine = string.IsNullOrEmpty(Request.QueryString["mine"])
               ? "false" : Request.QueryString["mine"];

            string categoryCode = string.IsNullOrEmpty(Request.QueryString["CategoryCode"])
               ? SystemConst.CategoryCode.Blog : Request.QueryString["CategoryCode"];
            string order = string.IsNullOrEmpty(Request.QueryString["order"])
                ? "default" : Request.QueryString["order"];

            string keyword = Request.QueryString["keyword"];

            int memberID = 0;

            if (mine == "true")
            {
                memberID = WebCookieHelper.GetUserId(0);
                if (memberID == 0)
                {
                    return(Redirect("/member/login?returnurl=" + Request.Url));
                }
            }
            string     categoryName = EnterRepository.GetRepositoryEnter().CategoryRepository.LoadEntities(m => m.Code == categoryCode).FirstOrDefault().Name;
            Pagination pagination   = new Pagination();
            int        page         = 1;

            if (id != null)
            {
                page = int.Parse(id.ToString());
            }

            int totalCount = 0;

            pagination.Size      = 30;
            pagination.ActionUrl = "blog/index";

            pagination.CurrentPageIndex = page;
            DateTime startTime = DateTime.Now;
            var      myblogs   = BlogServices.GetBlogs(keyword, memberID, categoryCode, order, page, pagination.Size, out totalCount);
            string   time      = (DateTime.Now - startTime).TotalSeconds.ToString();

            pagination.TotalCount   = totalCount;
            pagination.Order        = order;
            pagination.CategoryCode = categoryCode;
            pagination.CategoryName = categoryName;
            pagination.Keyword      = keyword;
            ViewBag.mine            = mine;
            ViewBag.time            = time;
            ViewBag.keyword         = keyword;
            ViewBag.myblogs         = myblogs;
            ViewBag.Pagination      = pagination;
            return(View());
        }
示例#3
0
 public IHttpActionResult GetBlogs(string title = "", int?status = null, int?categoryId = null, DateTime?startDate = null, DateTime?endDate = null, int?blogid = null, int?limit = null)
 {
     try
     {
         var result = oSvc.GetBlogs(title, status, categoryId, startDate, endDate, blogid, limit);
         return(Ok(result));
     }
     catch (Exception ex)
     {
         ExceptionModel oExc = oException.Set(ex);
         return(Ok(oExc));
     }
 }
示例#4
0
        //
        // GET: /Home/
        public ActionResult Index()
        {
            int    totalCount = 0;
            string order      = "latest";

            ViewBag.NewsGonggao  = ArticleServices.GetArticles(SystemConst.CategoryCode.NewsGongGao, order, 1, 10, out totalCount);
            ViewBag.NewsExamData = ArticleServices.GetArticles(SystemConst.CategoryCode.NewsExamData, order, 1, 10, out totalCount);
            ViewBag.NewsReview   = ArticleServices.GetArticles(SystemConst.CategoryCode.NewsReview, order, 1, 10, out totalCount);
            ViewBag.NewsScore    = ArticleServices.GetArticles(SystemConst.CategoryCode.NewsScore, order, 1, 10, out totalCount);
            ViewBag.Book         = BookServices.GetBooks(SystemConst.CategoryCode.Book, order, 1, 10, out totalCount);
            ViewBag.Train        = TrainServices.GetTrains(SystemConst.CategoryCode.Train, order, 1, 8, out totalCount);
            ViewBag.Hotel        = HotelServices.GetHotels(SystemConst.CategoryCode.Hotel, order, 1, 20, out totalCount);
            ViewBag.Blog         = BlogServices.GetBlogs(null, 0, SystemConst.CategoryCode.Blog, order, 1, 10, out totalCount);
            return(View());
        }