public ActionResult Submit(article article, string details = "", string video = "", HttpPostedFileBase image = null)
        {
            article.AuthorId = (int)Session["id"];
            article.dateTime = DateTime.Now;
            article.IP       = Request.UserHostAddress;

            if (!string.IsNullOrEmpty(details))
            {
                if (ModelState.IsValid)
                {
                    db.articles.Add(article);
                    db.SaveChanges();
                    if (video != "")
                    {
                        ArticleVideo av = new ArticleVideo()
                        {
                            ArticleId = article.id, VideoLink = video
                        };
                        db.ArticleVideos.Add(av);
                        db.SaveChanges();
                    }
                    System.IO.StreamWriter sr = new System.IO.StreamWriter(Server.MapPath("../AllArticles/" + article.title.ToLower().Trim().Replace(" ", "_") + ".html"));
                    sr.Write(details);
                    sr.Close();

                    return(RedirectToAction("MyArticle"));
                }
            }

            ViewBag.SubscriptionTypeId = new SelectList(db.SubscriptionTypes, "id", "Name", article.SubscriptionTypeId);
            ViewBag.categoryId         = new SelectList(db.Categories, "id", "Name", article.categoryId);
            return(View(article));
        }
示例#2
0
        public ActionResult DeleteConfirmed(int id)
        {
            ArticleVideo articleVideo = db.ArticleVideos.Find(id);

            db.ArticleVideos.Remove(articleVideo);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#3
0
 public ActionResult Edit([Bind(Include = "id,ArticleId,VideoLink")] ArticleVideo articleVideo)
 {
     if (ModelState.IsValid)
     {
         db.Entry(articleVideo).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ArticleId = new SelectList(db.articles, "id", "title", articleVideo.ArticleId);
     return(View(articleVideo));
 }
示例#4
0
        public ActionResult Create([Bind(Include = "id,ArticleId,VideoLink")] ArticleVideo articleVideo)
        {
            if (ModelState.IsValid)
            {
                db.ArticleVideos.Add(articleVideo);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ArticleId = new SelectList(db.articles, "id", "title", articleVideo.ArticleId);
            return(View(articleVideo));
        }
示例#5
0
        // GET: ArticleVideo/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ArticleVideo articleVideo = db.ArticleVideos.Find(id);

            if (articleVideo == null)
            {
                return(HttpNotFound());
            }
            return(View(articleVideo));
        }
示例#6
0
        // GET: ArticleVideo/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ArticleVideo articleVideo = db.ArticleVideos.Find(id);

            if (articleVideo == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ArticleId = new SelectList(db.articles, "id", "title", articleVideo.ArticleId);
            return(View(articleVideo));
        }
示例#7
0
        public override Guid GetArticleId()
        {
            if (qsAct == ConfigFormAction.add)
            {
                return(qsArtId);
            }

            ArticlePublisherLogic artPub = new ArticlePublisherLogic();
            ArticleVideo          att    = artPub.GetArticleVideoDataForBackend(qsVidId);
            Guid articleId = Guid.Empty;

            if (att != null)
            {
                articleId = att.ArticleId.Value;
            }

            return(articleId);
        }
    private void DisplayArticleVideoData()
    {
        if (c.qsAct == ConfigFormAction.edit)
        {
            ArticleVideo video = artPub.GetArticleVideoDataForBackend(c.qsVidId);

            if (video != null)
            {
                txtSortNo.Text        = video.SortNo.ToString();
                txtVidLinkUrl.Text    = video.VidLinkUrl;
                txtSourceVideoId.Text = video.SourceVideoId;
                ltrPostAccount.Text   = video.PostAccount;
                ltrPostDate.Text      = string.Format("{0:yyyy-MM-dd HH:mm:ss}", video.PostDate);
                string   mdfAccount = video.MdfAccount;
                DateTime mdfDate    = DateTime.MinValue;

                if (video.MdfDate.HasValue)
                {
                    mdfDate = video.MdfDate.Value;
                }

                //zh-TW
                if (LangManager.IsEnableEditLangZHTW())
                {
                    ArticleVideoMultiLang vidZhTw = artPub.GetArticleVideoMultiLangDataForBackend(c.qsVidId, LangManager.CultureNameZHTW);

                    if (vidZhTw != null)
                    {
                        txtVidSubjectZhTw.Text      = vidZhTw.VidSubject;
                        chkIsShowInLangZhTw.Checked = vidZhTw.IsShowInLang;
                        txtVidDescZhTw.Text         = vidZhTw.VidDesc;

                        if (vidZhTw.MdfDate.HasValue && vidZhTw.MdfDate.Value > mdfDate)
                        {
                            mdfAccount = vidZhTw.MdfAccount;
                            mdfDate    = vidZhTw.MdfDate.Value;
                        }
                    }
                }

                //en
                if (LangManager.IsEnableEditLangEN())
                {
                    ArticleVideoMultiLang vidEn = artPub.GetArticleVideoMultiLangDataForBackend(c.qsVidId, LangManager.CultureNameEN);

                    if (vidEn != null)
                    {
                        txtVidSubjectEn.Text      = vidEn.VidSubject;
                        chkIsShowInLangEn.Checked = vidEn.IsShowInLang;
                        txtVidDescEn.Text         = vidEn.VidDesc;

                        if (vidEn.MdfDate.HasValue && vidEn.MdfDate.Value > mdfDate)
                        {
                            mdfAccount = vidEn.MdfAccount;
                            mdfDate    = vidEn.MdfDate.Value;
                        }
                    }
                }

                if (mdfDate != DateTime.MinValue)
                {
                    ltrMdfAccount.Text = mdfAccount;
                    ltrMdfDate.Text    = string.Format("{0:yyyy-MM-dd HH:mm:ss}", mdfDate);
                }

                btnSave.Visible = true;
            }
        }
        else if (c.qsAct == ConfigFormAction.add)
        {
            int newSortNo = artPub.GetArticleVideoMaxSortNo(c.qsArtId) + 10;
            txtSortNo.Text = newSortNo.ToString();

            btnSave.Visible = true;
        }
    }