protected void listviewComment_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            if (e.Item != null)
            {
                ListViewDataItem dataItem    = (ListViewDataItem)e.Item;
                Label            lbCommentID = (Label)e.Item.FindControl("CommentID");
                try
                {
                    KLNewsComment com  = new KLNewsComment(int.Parse(lbCommentID.Text));
                    KLNews        news = new KLNews(com.NewsID, 0);
                    if (String.Equals(e.CommandName.ToLower(), "approve"))
                    {
                        news.CommentCount = news.CommentCount + 1;
                        com.IsPublish     = true;
                    }
                    else if (String.Equals(e.CommandName.ToLower(), "delete"))
                    {
                        int index = e.Item.DisplayIndex;
                        listviewComment.DeleteItem(index);
                        news.CommentCount = news.CommentCount - 1;
                        com.IsPublish     = false;
                        com.ISDel         = true;
                    }
                    news.Save();
                    com.Save();
                }
                catch (Exception)
                {
                }
            }

            WebUtils.SetupRedirect(this, Request.RawUrl);
        }
Beispiel #2
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();
            }
        }
Beispiel #3
0
        private int Save(string op = "")
        {
            Page.Validate("news");

            if (!Page.IsValid)
            {
                return(-1);
            }

            if (ddlnewtype.SelectedValue.Length == 0)
            {
                message.ErrorMessage = CustomResources.SelectTypeMessage;
                return(-1);
            }

            if (news == null)
            {
                news        = new News(siteSettings.SiteId, newsId);
                news.ZoneID = -1;
            }
            if (currentUser == null)
            {
                return(-1);
            }

            news.LastModUserGuid = currentUser.UserGuid;

            news.SiteId       = siteSettings.SiteId;
            news.FullContent  = fullcontent.Content;
            news.BriefContent = shortcontent.Content;
            news.Title        = newstitle.Text;
            news.UserGuid     = currentUser.UserGuid;

            if (news.Save())
            {
                if (newsId > 0)
                {
                    KLnews.NewType = Convert.ToInt32(ddlnewtypechild.SelectedValue);
                    LogActivity.Write("Update news", news.Title);
                    message.SuccessMessage = ResourceHelper.GetResourceString("Resource", "UpdateSuccessMessage");
                }
                else
                {
                    KLAuthor author = KLAuthor.GetKLAuthorByUserID(currentUser.UserId);

                    KLnews = new KLNews()
                    {
                        CommentCount   = 0,
                        AuthorID       = author.AuthorID,
                        LikeCount      = 0,
                        Newlsevel      = 1,
                        Newstotalpoint = 0,
                        NewsID         = news.NewsID,
                        ShareCount     = 0,
                        NewType        = Convert.ToInt32(ddlnewtypechild.SelectedValue),
                        ViewCount      = 0,
                    };
                }
                if (op == "draft")
                {
                    KLnews.Isdraft    = true;
                    KLnews.Isapproved = false;
                }
                else
                {
                    KLnews.Isdraft    = false;
                    KLnews.Isapproved = false;
                }
                if (KLnews.Save())
                {
                    LogActivity.Write("Create new news", news.Title);
                    message.SuccessMessage = ResourceHelper.GetResourceString("Resource", "InsertSuccessMessage");
                }
            }

            SiteUtils.QueueIndexing();

            return(news.NewsID);
        }
Beispiel #4
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);
            }
        }