示例#1
0
        public ActionResult Page(int contentId, int groupId)
        {
            var model = ArticleManagement.FindArticle(contentId, Math.Abs(WebSecurity.CurrentUserId), groupId);

            ViewBag.Message = ArticleManagement.GetVoteGroup(groupId);
            return(View(model));
        }
示例#2
0
        /// <summary>
        /// 绑定数据源
        /// </summary>
        public void GetList()
        {
            ArticleManagement article = new ArticleManagement();
            DataSet           ds      = article.GetAllList();

            gvlist.DataSource = ds;
            gvlist.DataBind();
        }
示例#3
0
        /// <summary>
        /// 删除事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void gvlist_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int id = int.Parse(gvlist.DataKeys[e.RowIndex].Value.ToString());

            ArticleManagement article = new ArticleManagement();

            article.Delete(id);
            GetList();
        }
示例#4
0
        public ActionResult SubGroupResult(string voteGroup, int groupId)
        {
            ViewBag.Title = voteGroup;
            ResultModel model = new ResultModel()
            {
                Contents = ArticleManagement.ListSubGroupTitles(0, groupId), Page = 0, groupId = groupId, voteGroup = voteGroup
            };

            return(View("Result", model));
        }
示例#5
0
        public ActionResult Home()
        {
            var content = ArticleManagement.GetRandomVoteContent();

            if (content != null)
            {
                ViewBag.Title     = content.Title;
                ViewBag.contentId = content.ContentID;
                ViewBag.groupId   = content.GroupID;
            }
            return(View());
        }
示例#6
0
        public void GetPage(int id)
        {
            ArticleManagement article = new ArticleManagement();

            if (id > 0)
            {
                string where           = " id=" + id;
                IdLab.Text             = article.GetModel(id).Id.ToString(); //填充Id文本框
                txtTitle.Text          = article.GetModel(id).Title;         //填充title文本框
                txtKeyword.Text        = article.GetModel(id).Keyword;       //填充keyword文本框
                txtEditorContents.Text = article.GetModel(id).Content;       //填充内容框
            }
        }
示例#7
0
        //
        // GET: /Account/Manage

        public ActionResult Manage(ManageMessageId?message)
        {
            ViewBag.StatusMessage =
                message == ManageMessageId.ChangePasswordSuccess ? "Your password has been changed."
                : message == ManageMessageId.SetPasswordSuccess ? "Your password has been set."
                : message == ManageMessageId.RemoveLoginSuccess ? "The external login was removed."
                : "";
            ViewBag.HasLocalPassword = OAuthWebSecurity.HasLocalAccount(WebSecurity.GetUserId(User.Identity.Name));
            ViewBag.ReturnUrl        = Url.Action("Manage");
            ViewBag.groups           = new List <string>()
            {
                "Vote", "Article", "News"
            };
            ViewBag.Users = ArticleManagement.GetUsers();
            ViewBag.Roles = ArticleManagement.GetRoles();
            return(View());
        }
示例#8
0
        public ActionResult GroupResultPost(int page, string voteGroup)
        {
            ViewBag.Message = "We dont have more Entries";
            ViewBag.Title   = voteGroup;
            var contents = ArticleManagement.ListGroupTitles(page, voteGroup);

            if (contents.Count == 0)
            {
                return(View("EndOfArticle"));
            }
            var model = new ResultModel()
            {
                Contents = contents, Page = page, voteGroup = voteGroup
            };

            return(View("Result", model));
        }
示例#9
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            int id = HttpContext.Current.Request["id"] == null?0: int.Parse(HttpContext.Current.Request["id"]);

            if (id > 0)  //当它大于0的时候说明文本框有数据,则是修改操作
            {
                ArticleManagement article = new ArticleManagement();

                //实例化一个相同Id的model用于修改数据
                Model.ArticleManagement model = new Model.ArticleManagement();
                model.Id         = id;
                model.Title      = txtTitle.Text;
                model.Keyword    = txtKeyword.Text;
                model.Content    = txtEditorContents.Text;
                model.Image      = hidImagePath.Value;
                model.Uploadtime = Convert.ToDateTime(test1.Value);
                //执行修改
                bool a = article.Update(model);
                if (a == true)
                {
                    Response.Write("<script>alert('修改成功!');window.location.href='Article.aspx'</script>");
                }
            }
            else
            {
                ArticleManagement article = new ArticleManagement();

                //实例化一个对象用来新增操作
                Model.ArticleManagement NewModel = new Model.ArticleManagement();
                //Id是自增长不需要添加
                NewModel.Title      = txtTitle.Text;
                NewModel.Keyword    = txtKeyword.Text;
                NewModel.Content    = txtEditorContents.Text;
                NewModel.Image      = Request["hidImagePath"];
                NewModel.Uploadtime = Convert.ToDateTime(test1.Value);

                int a = article.Add(NewModel);
                if (a > 0)
                {
                    Response.Write("<script>alert('添加成功!');window.location.href='Article.aspx'</script>");
                }
            }
        }
示例#10
0
        /// <summary>
        /// saves the new current site to the database
        /// no check of permissions for this action as it requires a site ID which may not work
        /// </summary>
        /// <returns>pass/fail</returns>
        public bool AddSite()
        {
            SqlConnection cn  = new SqlConnection(Utility.dbConnectionString);
            SqlCommand    cmd = new SqlCommand("wse_SiteAdd", cn);

            cmd.CommandType = CommandType.StoredProcedure;

            try
            {
                cmd.Parameters.AddWithValue("@Site_Name", this.Site_Name);
                cmd.Parameters.AddWithValue("@URL", this.URL);
                cmd.Parameters.AddWithValue("@Secure_URL", this.Secure_URL);
                cmd.Parameters.AddWithValue("@SiteOwner", this.SiteOwner);
                cmd.Parameters.AddWithValue("@SiteOwnerEmail", this.SiteOwnerEmail);
                cmd.Parameters.AddWithValue("@StartDate", this.StartDate);
                //cmd.Parameters.AddWithValue("@Approved_By", this.Approved_By);
                cmd.Parameters.AddWithValue("@Create_By", this.Create_By);
                cmd.Parameters.AddWithValue("@Create_Date", DateTime.Now);
                cmd.Parameters.AddWithValue("@Edit_By", this.Create_By);
                cmd.Parameters.AddWithValue("@Edit_Date", DateTime.Now);

                cn.Open();
                //new site id
                this._id_Site = Convert.ToInt32(cmd.ExecuteScalar());

                //with each new site we also add a primary category and home page article
                CategoryManagement newCat = new CategoryManagement();
                newCat.Active          = true;
                newCat.Cat_Name        = "Home Category";
                newCat.Created_By      = this.Create_By;
                newCat.Cat_Description = "Home category for " + this.Site_Name;
                newCat.Edit_by         = this.Create_By;
                //newCat.id_Parent left blank as this is home category
                newCat.id_Site = this.id_Site;
                newCat.AddCategory();

                //get the username
                Page newPage = new Page();
                //now the article
                ArticleManagement newArt = new ArticleManagement();
                newArt.Article_Description = "Home page for " + this.Site_Name;
                newArt.Article_Text        = "Home page for " + this.Site_Name + "&lt;br /&gt; Under contruction... &lt;br /&gt; Please add pages to this site.";
                newArt.Article_Title       = "Home Page";
                newArt.Author      = newPage.User.Identity.Name;
                newArt.Create_By   = this.Create_By;
                newArt.Edit_By     = this.Create_By;
                newArt.Expire_Date = DateTime.Now.AddMonths(3);
                newArt.id_Category = newCat.id_Categories;
                newArt.id_Site     = this.id_Site;
                newArt.Pub_Date    = DateTime.Now;
                newArt.AddArticle();
                return(true);
            }
            catch (Exception err)
            {
                Guid UserID = new Guid(HttpContext.Current.Session["UserID"].ToString());
                Errors.LogError(UserID, "Site.cs", err.Source, "Site Add had an issue", err.Message, err.InnerException, err.StackTrace);
                //throw new Exception("SiteAdd had an issue: " + err.Message + err.Source);
                return(false);
            }
            finally
            {
                cn.Close();
                cmd.Dispose();
            }
        }
示例#11
0
 public ActionResult DeleteGroup(ManageModel model)
 {
     ArticleManagement.DeleteGroup(model);
     return(PartialView("_AdminPartial"));
 }
示例#12
0
 public ActionResult PostVoteSections(ManageModel model, IEnumerable <VotingModel> voteSections)
 {
     ArticleManagement.PostVoteSections(model, voteSections);
     return(PartialView("_AdminPartial"));
 }
示例#13
0
 public ActionResult GetTitles(string group)
 {
     return(Json(ArticleManagement.ListAllSubGroupTitles(Convert.ToInt32(group)).Select(x => new { value = x.ContentID, text = x.Title }), JsonRequestBehavior.AllowGet));
 }
示例#14
0
 public ActionResult SubGroups(string group)
 {
     return(Json(ArticleManagement.GetGroups(group).Select(x => new { value = x.GroupID, text = x.SubGroupName }), JsonRequestBehavior.AllowGet));
 }
示例#15
0
 public ActionResult PostArticles(ManageModel model)
 {
     ArticleManagement.PostArticles(model);
     return(PartialView("_AdminPartial"));
 }
示例#16
0
 public ActionResult VotingPage(int contentId, string voteRadioButton, int groupId)
 {
     ArticleManagement.AddVote(Convert.ToInt32(voteRadioButton), WebSecurity.CurrentUserId, contentId);
     return(RedirectToAction("Page", new { contentId = contentId, groupId = groupId }));
 }