Ejemplo n.º 1
0
        public async Task <ActionResult> DeleteConfirmed(Guid id)
        {
            NewsColumn newscolumn = await db.NewsColumn.FindAsync(id);

            db.NewsColumn.Remove(newscolumn);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> Edit([Bind(Include = "ColumnID,ColumnPID,ColumnName,CreateTime,CreateBy,IsDeleted")] NewsColumn newscolumn)
        {
            if (ModelState.IsValid)
            {
                db.Entry(newscolumn).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(newscolumn));
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> Create([Bind(Include = "ColumnID,ColumnPID,ColumnName,CreateTime,CreateBy,IsDeleted")] NewsColumn newscolumn)
        {
            if (ModelState.IsValid)
            {
                newscolumn.ColumnID = Guid.NewGuid();
                db.NewsColumn.Add(newscolumn);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(newscolumn));
        }
Ejemplo n.º 4
0
        // GET: /Test/NewsColumn/Delete/5
        public async Task <ActionResult> Delete(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            NewsColumn newscolumn = await db.NewsColumn.FindAsync(id);

            if (newscolumn == null)
            {
                return(HttpNotFound());
            }
            return(View(newscolumn));
        }
Ejemplo n.º 5
0
 /// <summary>
 /// There are no comments for NewsColumn in the schema.
 /// </summary>
 public void AddToNewsColumn(NewsColumn newsColumn)
 {
     base.AddObject("NewsColumn", newsColumn);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Create a new NewsColumn object.
 /// </summary>
 /// <param name="ID">Initial value of ID.</param>
 public static NewsColumn CreateNewsColumn(int ID)
 {
     NewsColumn newsColumn = new NewsColumn();
     newsColumn.ID = ID;
     return newsColumn;
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Create a new NewsColumn object.
 /// </summary>
 /// <param name="id">Initial value of ID.</param>
 public static NewsColumn CreateNewsColumn(int id)
 {
     NewsColumn newsColumn = new NewsColumn();
     newsColumn.ID = id;
     return newsColumn;
 }
Ejemplo n.º 8
0
        public void ArticleUpdate()
        {
            //int newsclumnid = GetInt("newscolumnid");
            int ID = GetInt("newsid");
            string Content = GetString("NewsContent");
            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");
                news.PubAuthor = GetString("PubAuthor");
                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 (GetUserID() == news.UserID)
                {
                    news.IsApproval = false;
                    news.Status = (int?)NewsStatus.Publised;
                }

                CQGJ.SaveChanges();

            }
            SetFlashPic();
            RedirectToAction("ArticleEdit/"+ID);
        }
Ejemplo n.º 9
0
        public void ArticleSave()
        {
            string Title = GetString("Title");
            string Content = GetString("NewsContent");
            //string PubAuthor = GetString("PubAuthor");
            string PubSource = GetString("PubSource");
            //int IsImportance = GetInt("IsImportance");
            if (Title != "" && Content != "" && GetString("Column") != "")
            {
                News news = new News();
                news.Title = Title;
                news.PubAuthor = GetUserName(GetUserID());
                news.Content = Content;
                news.PubDate = DateTime.Now;
                news.PubSource = PubSource;
                //设置查看次数
                news.UserID = (int?)GetUserID();
                news.ViewNum = 0;
                news.Status = (int?)NewsStatus.Publised;
                news.IsNotify = false;
                news.IsApproval = false;
                news.IsImportant = false;
                //if (IsImportance == 1)
                //{
                //    news.IsImportant = true;
                //}
                //else
                //{
                //    news.IsImportant = false;
                //}
                news.IsApproval = 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页面
                //跳转页面都需要问题
                RedirectToAction("ArticleAllList/1");
            }
            else
            {
                //TempData["Message"] = "字段不能留空!";
                RedirectToAction("ArticleAdd");
            }
        }