// GET: Admin/Article
        public ActionResult Index(int page = 1, int pageSize = 10)
        {
            try
            {
                if (Session[CommonConstants.USER_SESSION] != null)
                {
                    var session = new UserLogin();
                    session = (UserLogin)Session[CommonConstants.USER_SESSION]; // lấy từ session
                    var name = new UserDao().GetName(session.userName);
                    ViewBag.session = name;
                }

                var posts = new PostDao().GetPagedListPost(page, pageSize);
                return(View(posts));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #2
0
        // GET: Client/Category
        public ActionResult Index(string slug)
        {
            //Lấy thể loại tin hiện lên header
            var cates = new CateDao().GetAllCate();

            ViewBag.cates = cates;

            //Lấy thông tin cate được chọn
            var            theloai_id = new CateDao().GetId(slug);
            var            cateName   = new CateDao().GetName(theloai_id);
            List <baiviet> posts      = new List <baiviet>();

            if (theloai_id != -1)
            {
                posts = new PostDao().GetAllPost(theloai_id);
            }
            ViewBag.posts    = posts;
            ViewBag.cateName = cateName;
            ViewBag.cateSlug = slug;
            return(View());
        }
Exemple #3
0
        // GET: Admin/Home
        public ActionResult Index()
        {
            if (Session[CommonConstants.USER_SESSION] != null)
            {
                var session = new UserLogin();
                session = (UserLogin)Session[CommonConstants.USER_SESSION]; // lấy từ session
                var name = new UserDao().GetName(session.userName);
                ViewBag.session = name;
            }

            var user_count    = new UserDao().CountUser();
            var post_count    = new PostDao().CountPost();
            var cate_count    = new CateDao().CountCate();
            var comment_count = new CommentDao().CountComment();

            ViewBag.user_count    = user_count;
            ViewBag.post_count    = post_count;
            ViewBag.cate_count    = cate_count;
            ViewBag.comment_count = comment_count;
            return(View());
        }
        /// <summary>
        /// 取得Post By PostId No Lazy
        /// </summary>
        /// <param name="postId">PostId</param>
        /// <returns>Post</returns>
        public PostVO GetPostByIdNoLazy(int postId)
        {
            PostVO postVO = PostDao.GetPostById(postId);

            if (postVO != null && postVO.ParentPost != null)
            {
                NHibernateUtil.Initialize(postVO.ParentPost);

                if (postVO.ParentPost.ParentPost != null)
                {
                    NHibernateUtil.Initialize(postVO.ParentPost.ParentPost);
                }
            }

            if (postVO.Node != null)
            {
                NHibernateUtil.Initialize(postVO.Node);
            }

            return(postVO);
        }
Exemple #5
0
        public JsonResult Searching()
        {
            try
            {
                var data  = Request.Form;
                var posts = new PostDao().SearchPost(data["search"]);

                return(Json(new
                {
                    status = true,
                    data = posts
                }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new
                {
                    status = false
                }, JsonRequestBehavior.AllowGet));
            }
        }
Exemple #6
0
 public ActionResult UpdatePost(BAIDANG tk)
 {
     if (ModelState.IsValid)      //f9 de debug. thu di. f10 se debug tung buoc
     {
         var DAO = new PostDao(); //f12 hoac contine se nhay toi buoc debug ke tiep.
         //neu ke tiep k co debug thi se chạy xog luon.ok
         //gio contine se chay xog luon vi da het debug
         //var passmd5 = Encryptor.MD5Hash(tk.MatKhau);
         //tk.MatKhau = passmd5;
         var result = DAO.updatePost(tk);
         if (result)
         {
             return(RedirectToAction("MyPost", "PostManager"));
         }
         else
         {
             ModelState.AddModelError("", "Cập nhật thất bại");
         }
     }
     return(View("Index"));
 }
Exemple #7
0
        public ActionResult Index(string cateslug, string postslug)
        {
            //Lấy thể loại tin hiện lên header
            var cates = new CateDao().GetAllCate();

            ViewBag.cates = cates;

            //Lấy thông tin cate được chọn
            int     cateId = new CateDao().GetId(cateslug);
            baiviet post   = new PostDao().GetSinglePost(postslug, cateId);

            ViewBag.post = post;

            string cateName = new CateDao().GetName(post.theloai_id.Value);

            ViewBag.cateName = cateName;
            string cateSlug = new CateDao().GetSlug(post.theloai_id.Value);

            ViewBag.cateSlug = cateSlug;
            //tang luot xem moi khi vao bai viet
            var view = new PostDao().IncViews(postslug, post.theloai_id.Value);
            //loc ra hot-news
            var cate_posts = new PostDao().GetAllPost(cateId);
            var hotNews    = cate_posts.Where(x => x.noibat == true && x.id != post.id).OrderByDescending(x => x.soluotxem).Take(6).ToList(); //100 25 20 15

            foreach (var hotNew in hotNews)
            {
                hotNew.theloaitin = new CateDao().GetSingleCate(hotNew.theloai_id.Value);
            }
            ViewBag.hotNews = hotNews;
            var relatedNews = cate_posts.Where(x => x.id != post.id).OrderByDescending(x => x.ngaytao).Take(6).ToList();

            ViewBag.relatedNews = relatedNews;

            var comments = new CommentDao().GetAllComment(post.id);

            ViewBag.comments = comments;

            return(View());
        }
Exemple #8
0
        public ActionResult Create(BAIDANG bd)
        {
            if (bd.TenBaiDang == null || bd.AnhDaiDien == null || bd.NoiDung == null)
            {
                GetTypeForPost();
                return(View("Create"));
            }

            if (ModelState.IsValid)
            {
                var DAO = new PostDao();
                bd.UrlRequire       = RewriteURL.RewriteUrl(bd.TenBaiDang);
                bd.TrangThaiBaiDang = "chờ duyệt";

                int idtk = int.Parse(Session["USER_ID"].ToString());
                bd.IDTaiKhoan = idtk;
                bd.NgayDang   = DateTime.Now;
                bd.IDBaiDang  = 0;
                long idpost = DAO.CreatePost(bd);
            }
            return(Redirect("MyPost"));
        }
        public IActionResult Adiciona(Post novoPost)
        {
            //if (string.IsNullOrEmpty(novoPost.Titulo) ||
            //    string.IsNullOrEmpty(novoPost.Categoria) ||
            //    string.IsNullOrEmpty(novoPost.Resumo))
            //{

            //    return View("Novo");

            //}

            if (ModelState.IsValid)
            {
                PostDao dao = new PostDao();

                dao.Adicionar(novoPost);

                return(RedirectToAction("Index", "Post"));
            }

            return(View("Novo", novoPost));
        }
        private string GetPromoteSellPrice(double?sellPrice, string warrantySuppliers)
        {
            string result = "特價中";

            //搜尋條件
            Dictionary <string, string> conditions = new Dictionary <string, string>();

            conditions.Add("NodeId", "5");
            conditions.Add("ProductKeyWord", warrantySuppliers);
            conditions.Add("PageIndex", "0");
            conditions.Add("PageSize", "1");
            conditions.Add("IsPromote", "true");
            conditions.Add("Order", string.Format("order by {0}", "p.WarrantySuppliers, p.Type, p.SortNo, p.PostId"));

            IList <PostVO> discountList = PostDao.GetPostList(conditions);

            if (discountList != null && discountList.Count > 0)
            {
                PostVO discount      = discountList[0];
                double discountPrice = 0;

                if (sellPrice.HasValue && double.TryParse(discount.CustomField1, out discountPrice))
                {
                    double finalPrice = sellPrice.Value - discountPrice;

                    if (finalPrice > 0)
                    {
                        result = finalPrice.ToString();
                    }
                    else
                    {
                        result = "0";
                    }
                }
            }

            return(result);
        }
        /// <summary>
        /// 抓出推薦的手機折扣
        /// <param name="count">數量</param>
        /// <returns>搜尋結果</returns>
        public IList <PromoteVO> GetPromoteList(int count)
        {
            IList <PromoteVO> result = new List <PromoteVO>();

            //50強手機
            Dictionary <string, string> conditionsPhone = new Dictionary <string, string>();

            conditionsPhone.Add("IsPromote", "true");
            conditionsPhone.Add("NodeId", "3");
            conditionsPhone.Add("PageIndex", "0");
            conditionsPhone.Add("PageSize", count.ToString());
            conditionsPhone.Add("Order", string.Format("order by {0}", "p.WarrantySuppliers, p.SortNo, p.Title"));

            IList <PostVO> phoneList = PostDao.GetPostList(conditionsPhone);

            if (phoneList != null && phoneList.Count > 0)
            {
                foreach (PostVO vo in phoneList)
                {
                    PromoteVO promoteVO = new PromoteVO();
                    promoteVO.Id = vo.PostId;
                    promoteVO.WarrantySuppliers = vo.WarrantySuppliers;
                    promoteVO.SortNo            = vo.SortNo;
                    promoteVO.Title             = vo.Title;
                    promoteVO.SellPrice         = vo.SellPrice.ToString();
                    promoteVO.SellPriceW1       = GetPromoteSellPrice(vo.SellPrice, "中華電信");
                    promoteVO.SellPriceW2       = GetPromoteSellPrice(vo.SellPrice, "遠傳");
                    promoteVO.SellPriceW3       = GetPromoteSellPrice(vo.SellPrice, "台哥大");
                    promoteVO.SellPriceW4       = GetPromoteSellPrice(vo.SellPrice, "亞太電信");
                    promoteVO.SellPriceW5       = GetPromoteSellPrice(vo.SellPrice, "台灣之星");

                    result.Add(promoteVO);
                }
            }


            return(result);
        }
Exemple #12
0
        // GET: News
        public ActionResult Index(long id)
        {
            var dao = new PostDao();

            ViewBag._k_news = dao.NewsFindByID(id);


            //Lấy 10 bài đăng cùng thể loại
            ViewBag._k_relative = dao.top10Relative(id);

            //Lấy 10 bài đăng cùng người đăng
            ViewBag._k_poster = dao.top10CungNguoiDang(id);

            //Lấy tên thể loại để hiển thị ra trang đọc báo
            ViewBag.vbtentheloai = dao.theloaibaidang(id);

            //Lấy thông tin người đăng
            ViewBag.getinfoposter = dao.GetInfoPoster(id);

            //var dao1 = new ViewsDao();
            //dao1.AddViews(id);
            return(View());
        }
        public IActionResult Categoria([Bind(Prefix = "id")] string nomeCategoria)
        {
            PostDao registros = new PostDao();

            return(View("Index", registros.ListarPostCategoria(nomeCategoria)));
        }
        public IActionResult Index()
        {
            PostDao registros = new PostDao();

            return(View(registros.ListarPost()));
        }
Exemple #15
0
 public HomeController(PostDao _db)
 {
     this.db = _db;
 }
 public PostApiController(PostDao _dao)
 {
     dao = _dao;
 }
 /// <summary>
 /// 取得數量
 /// </summary>
 /// <param name="conditions"></param>
 /// <returns></returns>
 public int GetTotalQuantity(IDictionary <string, string> conditions)
 {
     return(PostDao.GetTotalQuantity(conditions));
 }
Exemple #18
0
 public BlogService(AuthorDao authorDao, BlogDao blogDao, PostDao postDao)
 {
     _authorDao = authorDao;
     _blogDao   = blogDao;
     _postDao   = postDao;
 }
 /// <summary>
 /// 動態查詢Post
 /// </summary>
 /// <param name="where">搜尋語法,用Where...order by ...</param>
 /// <param name="pageIndex">分頁索引</param>
 /// <param name="pageSize">分頁大小</param>
 /// <returns>搜尋結果</returns>
 public IList <PostVO> SearchPostByWhere(string where, int pageIndex, int pageSize)
 {
     return(PostDao.SearchPostByWhere(where, pageIndex, pageSize));
 }
 /// <summary>
 /// 取得Post清單
 /// </summary>
 /// <param name="conditions">搜尋條件</param>
 /// <returns>電子Post清單</returns>
 public IList <PostVO> GetPostList(IDictionary <string, string> conditions)
 {
     return(PostDao.GetPostList(conditions));
 }
 /// <summary>
 /// 取得Node By 父層Id
 /// </summary>
 /// <param name="parentId">父層Id</param>
 /// <returns>Node清單</returns>
 public IList <NodeVO> GetNodeListByParentId(int parentId)
 {
     return(PostDao.GetNodeListByParentId(parentId));
 }
 /// <summary>
 /// 取得Node By NodeId
 /// </summary>
 /// <param name="nodeId">NodeId</param>
 /// <returns>Node</returns>
 public NodeVO GetNodeById(int nodeId)
 {
     return(PostDao.GetNodeById(nodeId));
 }
 /// <summary>
 /// 取得Node By Name
 /// </summary>
 /// <param name="name">Name</param>
 /// <returns>Node</returns>
 public NodeVO GetNodeByName(string name)
 {
     return(PostDao.GetNodeByName(name));
 }
        public IActionResult Index()
        {
            PostDao registros = new PostDao(new BlogContext());

            return(View(registros.ListarPostPublicado()));
        }
Exemple #25
0
 public PostController(PostDao dao)
 {
     this._dao = dao;
 }
 /// <summary>
 /// 取得Post By PostId
 /// </summary>
 /// <param name="postId">PostId</param>
 /// <returns>Post</returns>
 public PostVO GetPostById(int postId)
 {
     return(PostDao.GetPostById(postId));
 }
 /// <summary>
 /// 動態查詢筆數Post
 /// </summary>
 /// <param name="where">搜尋語法,用Where...order by ...</param>
 /// <returns>筆數</returns>
 public int CountPostByWhere(string where)
 {
     return(PostDao.CountPostByWhere(where));
 }
 /// <summary>
 /// 取得Post數量
 /// </summary>
 /// <param name="conditions"></param>
 /// <returns></returns>
 public int GetPostCount(IDictionary <string, string> conditions)
 {
     return(PostDao.GetPostCount(conditions));
 }
 /// <summary>
 /// 取得Node By 父層Name
 /// </summary>
 /// <param name="name">父層Name</param>
 /// <returns>Node清單</returns>
 public IList <NodeVO> GetNodeListByParentName(string name)
 {
     return(PostDao.GetNodeListByParentName(name));
 }
 /// <summary>
 /// 取得Node By RootNode
 /// </summary>
 /// <returns>Node清單</returns>
 public IList <NodeVO> GetNodeListByRoot()
 {
     return(PostDao.GetNodeListByParentId(this.RootNodeId));
 }