コード例 #1
0
        // GET: ProductDetail
        public ActionResult ProductDetail(int ProductId)
        {
            //登入的會員資訊
            CMember member = (CMember)Session[CMemberSession.Session_Login_User];

            //防止未登入者進入
            if (member == null)
            {
                return(RedirectToAction("../Member/Login"));
            }
            //所有會員資訊
            List <CMember> lsMember = CMemberFactory.fn會員查詢().ToList();

            List <CMember> Isbanned = CMemberFactory.fn會員查詢().Where(n => n.fMemberId == member.fMemberId).ToList();
            //所選到的商品
            CProduct product = CProductFactory.fn商品查詢().FirstOrDefault(p => p.fProductId == ProductId);

            //該商品的賣家資訊
            CMember memberseller = CMemberFactory.fn會員查詢().FirstOrDefault(m => m.fMemberId == product.fMemberSellerId);

            //該商品的圖片(多個)
            List <CProductPicture> lsProductPicture = CProductPictureFactory.fn商品圖片查詢().Where(p => p.fProductId == ProductId).ToList();

            //該商品的類別(多個)
            List <CProductCompare> lsCategory = CProductCompareFactory.fn商品類別對照查詢().Where(c => c.fProductId == ProductId).ToList();

            //該商品的留言(多個)
            List <CComment> lsProductComment = CCommentFactory.fn留言查詢().Where(c => c.fProductId == ProductId).ToList();

            List <CProductRank> lsProductRank = CProductRankFactory.fn評價查詢(ProductId).ToList();

            //新增瀏覽紀錄
            CProductBrowse productBrowse = new CProductBrowse()
            {
                fBrowseDataTime = DateTime.UtcNow.AddHours(08),
                fProductId      = ProductId
            };

            CProductBrowseFactory.fn商品瀏覽紀錄新增(product, productBrowse);

            List <CProductDetailVM> lsProductDetail = new List <CProductDetailVM>();

            CProductDetailVM productDetailVM = new CProductDetailVM()
            {
                lsMember          = lsMember,
                MemberSeller      = memberseller,
                Product           = product,
                lsProductPicture  = lsProductPicture,
                lsProductCategory = lsCategory,
                lsProductComment  = lsProductComment,
                lsProductRank     = lsProductRank,
                Isbanned          = Isbanned
            };

            return(View(productDetailVM));
        }
コード例 #2
0
        public int DislikeProductDetial(int fCommentId)
        {
            CComment comment = CCommentFactory.fn留言查詢().FirstOrDefault(p => p.fCommentId == fCommentId);

            comment.fLikeCount -= 1;
            CCommentFactory.fn留言更新(comment);

            int result = comment.fLikeCount;

            return(result);
        }
コード例 #3
0
        //留言板頁面
        public ActionResult MessageBoardView()
        {
            CAdmin admin = Session[CAdminSession.Session_Login_User] as CAdmin;

            if (admin == null)
            {
                return(RedirectToAction("../Member/AdminLogin"));
            }

            var board = CCommentFactory.fn留言查詢().ToList();

            return(View(board));
        }
コード例 #4
0
        //將選取的對象加入黑名單
        public string commentboard(int commentid, string content, int memberid)
        {
            CAdmin admin = Session[CAdminSession.Session_Login_User] as CAdmin;

            var comment = CCommentFactory.fn留言查詢().FirstOrDefault(m => m.fCommentId == commentid);

            comment.fContent  = content;
            comment.fIsBanned = true;
            CCommentFactory.fn留言更新(comment);
            var member = CMemberFactory.fn會員查詢().FirstOrDefault(n => n.fMemberId == memberid);

            CNotice c = new CNotice();

            c.fNoticeDatetime = DateTime.UtcNow.AddHours(08);
            c.fNoticeContent  = "此留言因涉及違規發言已被遮蔽";
            c.fCategoryType   = "管理員";
            c.fLink           = "超連結";
            c.fMemberId       = member.fMemberId;
            CNoticeFactory.fn通知訂單訊息新增(c);

            return("遮蔽原因更新成功!");
        }