Ejemplo n.º 1
0
        protected KLAuthor GetAuthor(int newsID)
        {
            var News   = KLNews.GetAll().Where(n => n.NewsID == newsID).SingleOrDefault();
            var author = new KLAuthor(News.AuthorID);

            return(author);
        }
Ejemplo n.º 2
0
        private string UpdateLike(int newsID)
        {
            bool isSuccess   = false;
            var  newsHistory = KLLikeHistory.GetAll().Where(h => h.NewsID == newsID && h.AuthorID == GetAuthor(currentUser.UserId)).SingleOrDefault();

            if (newsHistory == null)
            {
                newsHistory            = new KLLikeHistory();
                newsHistory.NewsID     = newsID;
                newsHistory.AuthorID   = GetAuthor(currentUser.UserId);
                newsHistory.CreateDate = DateTime.Now;
                newsHistory.Save();
                var news = KLNews.GetAll().Where(n => n.NewsID == newsID).SingleOrDefault();
                news.LikeCount += 1;
                isSuccess       = news.Save();
            }
            else
            {
                KLLikeHistory.Delete(newsHistory.LikeID);
                var news = KLNews.GetAll().Where(n => n.NewsID == newsID).SingleOrDefault();
                news.LikeCount -= 1;
                isSuccess       = news.Save();
            }
            return(isSuccess ? "success" : "fail");
        }
Ejemplo n.º 3
0
        private string UpdateShare(int newsID)
        {
            var news = KLNews.GetAll().Where(n => n.NewsID == newsID).SingleOrDefault();

            news.ShareCount += 1;
            bool res = news.Save();

            return(res ? "success" : "fail");
        }
Ejemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            LoadSettings();
            //totalPages = News.GetCountBySearch(siteSettings.SiteId, zoneId.ToString(), config.NewsType, -1, null, -1, -1, -1, null, null, null, null, null, string.Empty);
            int totalRow = News.GetCount(siteSettings.SiteId, -1, -1, -1, -1);

            lstNewsTop5          = News.GetPageBySearch(siteSettings.SiteId, null, 0, 1, null, -1, -1, -1, null, null, null, null, null, -1, -1, string.Empty, 1, totalRow).OrderByDescending(n => n.Viewed).Take(5).ToList();
            lstNewsMostOfWeek    = GetNewsMostOfWeek();
            lstAuthorMostArticle = KLAuthor.GetAll().Where(a => a.IsActive == true).OrderByDescending(n => n.ArticleCount).Take(10).ToList();
            if (like > 0)
            {
                KLNews news = KLNews.GetAll().Where(n => n.NewsID == like).SingleOrDefault();
                news.LikeCount += 1;
                news.Save();
            }
        }
Ejemplo n.º 5
0
        void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                if (!NewsPermission.CanUpdate)
                {
                    SiteUtils.RedirectToEditAccessDeniedPage();
                    return;
                }

                bool isUpdated = false;
                foreach (GridDataItem data in grid.Items)
                {
                    //TextBox txtDisplayOrder = (TextBox)data.FindControl("txtDisplayOrder");
                    //TextBox txtViewed = (TextBox)data.FindControl("txtViewed");
                    CheckBox cbIsPublished = (CheckBox)data.FindControl("cbPublished");
                    int      newsId        = Convert.ToInt32(data.GetDataKeyValue("NewsID"));
                    int      number_news   = 0;
                    //int displayOrder = Convert.ToInt32(data.GetDataKeyValue("DisplayOrder"));
                    //int viewed = Convert.ToInt32(data.GetDataKeyValue("Viewed"));
                    bool isPublished = Convert.ToBoolean(data.GetDataKeyValue("IsPublished"));

                    //int displayOrderNew = displayOrder;
                    //int.TryParse(txtDisplayOrder.Text, out displayOrderNew);

                    //int viewedNew = viewed;
                    //int.TryParse(txtViewed.Text, out viewedNew);
                    //|| viewed != viewedNew
                    //displayOrder != displayOrderNew ||

                    if (cbIsPublished.Checked != isPublished)
                    {
                        News     objNews = new News(SiteId, newsId);
                        KLNews   klNews  = KLNews.GetAll().Where(n => n.NewsID == newsId).FirstOrDefault();
                        KLAuthor author  = new KLAuthor(klNews.AuthorID);
                        if (objNews != null && objNews.NewsID > -1)
                        {
                            if (cbIsPublished.Checked == true)
                            {
                                if (author != null && author.AuthorID > -1 && objNews.IsPublished == false)
                                {
                                    number_news        = author.ArticleCount = (author.ArticleCount + 1);
                                    author.LevelAuthor = UpdateLevel(number_news);
                                    author.Save();
                                    klNews.Isapproved = true;
                                    klNews.Save();
                                }
                                ApproveArticle(objNews.NewsID);
                            }
                            else
                            {
                                if (objNews.IsPublished == true)
                                {
                                    number_news        = author.ArticleCount = (author.ArticleCount - 1);
                                    author.LevelAuthor = UpdateLevel(number_news);
                                    author.Save();
                                    klNews.Isapproved = false;
                                    insertnotify(author.UserID, klNews.NewsID, objNews.Title);
                                    klNews.Save();
                                }
                            }
                            objNews.IsPublished = cbIsPublished.Checked;
                            // objNews.DisplayOrder = displayOrderNew;
                            //objNews.Viewed = viewedNew;
                            objNews.Save();

                            LogActivity.Write("Resort news", objNews.Title);

                            isUpdated = true;
                        }
                    }
                }

                if (isUpdated)
                {
                    grid.Rebind();
                    message.SuccessMessage = ResourceHelper.GetResourceString("Resource", "UpdateSuccessMessage");
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
            }
        }