Example #1
0
        public ActionResult ArticleUpdate()
        {
            //int newsclumnid = GetInt("newscolumnid");
            int ID = GetInt("newsid");
            if (ID != 0)
            {
                News news = (from c in CQGJ.News
                             where c.NewsID == ID
                             select c).First();
                news.Title = GetString("Title");
                news.PubSource = GetString("PubSource");
                if (GetString("PubAuthor") != "")
                {
                    //news.PubAuthor = GetString("PubAuthor");
                }
                news.Content = GetString("NewsContent");
                if (GetInt("IsImportant") == 1)
                {
                    news.IsImportant = true;
                }
                string[] arraycolumnid = GetString("Column").Split(',');
                var newsColumns = (from n in CQGJ.News
                                   from nc in n.NewsColumn
                                   where n.NewsID == ID
                                   select nc);
                foreach (var c in newsColumns)
                {
                    CQGJ.DeleteObject(c);
                }
                foreach (var s in arraycolumnid)
                {
                    int columnid = int.Parse(s);
                    Column column = (from c in CQGJ.Column
                                     where c.ColumnID == columnid
                                     select c).First();
                    NewsColumn newsColumn = new NewsColumn();
                    newsColumn.Column = column;
                    newsColumn.News = news;
                    CQGJ.AddToNewsColumn(newsColumn);
                }
                if (GetAdmin().AdminID != 1)
                {
                    news.IsApproved = false;
                    news.Status = (int?)NewsStatus.Publised;
                }
                CQGJ.SaveChanges();

            }
            SetFlashPic();
            return RedirectToAction("ArticleEdit/" + ID);
        }
Example #2
0
        public ActionResult ArticleSave()
        {
            string Title = GetString("Title");
            string Content = GetString("NewsContent");
            string PubSource = GetString("PubSource");
            if (Title != "" && Content != "" && GetString("Column") != "")
            {
                News news = new News();
                news.Title = Title;
                news.PubAuthor = GetAdmin().Username;
                news.Content = Content;
                news.PubDate = DateTime.Now;
                news.PubSource = PubSource;
                news.OrgID = GetOrg().OrgID;
                news.ViewNum = 0;
                news.Status = (int?)NewsStatus.Publised;
                news.IsNotify = false;
                news.IsApproved = false;
                news.IsImportant = false;
                //if (IsImportance == 1)
                //{
                //    news.IsImportant = true;
                //}
                //else
                //{
                //    news.IsImportant = false;
                //}
                news.IsApproved = false;
                CQGJ.AddToNews(news);
                //
                string[] arraycolumnid = GetString("Column").Split(',');
                foreach (var s in arraycolumnid)
                {
                    int columnid = int.Parse(s);
                    Column column = (from c in CQGJ.Column
                                     where c.ColumnID == columnid
                                     select c).First();
                    NewsColumn newsColumn = new NewsColumn();
                    newsColumn.Column = column;
                    newsColumn.News = news;
                    CQGJ.AddToNewsColumn(newsColumn);
                }

                CQGJ.SaveChanges();
                //更新首页Flash图片
                SetFlashPic();
                //跳转回List页面
                //跳转页面都需要问题
                return RedirectToAction("ArticleAllList/1");
            }
            else
            {
                //TempData["Message"] = "字段不能留空!";
                return RedirectToAction("ArticleAdd");
            }
        }