public ActionResult SubmitArticle(tbl_Article a) { a.User_Id = db.tbl_Users.SingleOrDefault(x => x.Username == HttpContext.User.Identity.Name).User_Id; MyService.ServiceController myServiceController = new MyService.ServiceController(); myServiceController.SubmitNewArticle(a.Article_Name, a.Article_Description, a.Article_PublishDate, a.User_Id, a.MedaManager_Id, a.ArticleStatus_Id, a.Article_State_Id, Convert.ToInt32(a.ArticleComment_Id), "TextArticle"); ViewBag.MediaManager_ID = new SelectList( db.tbl_Users.Where( x => x.Role_Id == 2), "User_Id", "Username"); return View(); }
public ActionResult UpdateArticle(tbl_Article a) { a.User_Id = db.tbl_Users.SingleOrDefault(x => x.Username == HttpContext.User.Identity.Name).User_Id; tbl_Comments com = new tbl_Comments(); com = db.tbl_Comments.SingleOrDefault(x => x.Article_Id == a.Article_Id); if (com == null) { com = new tbl_Comments(); } string commentContent = ""; if (com.ArticleComment_Id != 0) { a.ArticleComment_Id = com.ArticleComment_Id; commentContent = com.ArticleComment_Content; } else { a.ArticleComment_Id = null; commentContent = ""; } MyService.ServiceController myServiceController = new MyService.ServiceController(); myServiceController.SubmitUpdatedArticle(a.Article_Id, a.Article_Name, a.Article_Description, a.Article_PublishDate, a.User_Id, a.MedaManager_Id, a.ArticleStatus_Id, a.Article_State_Id, commentContent, Convert.ToInt32(a.ArticleComment_Id), "TextArticle"); return View(); }
public ActionResult Edit(tbl_Article a) { //if (ModelState.IsValid) //{ // db.Entry(tbl_Article).State = EntityState.Modified; // db.SaveChanges(); // return RedirectToAction("Index"); //} //ViewBag.ArticleStatus_Id = new SelectList(db.tbl_ArticleStatus, "ArticleStatus_Id", "ArticleStatus_Type", tbl_Article.ArticleStatus_Id); //ViewBag.User_Id = new SelectList(db.tbl_Users, "User_Id", "First_Name", tbl_Article.User_Id); //return View(tbl_Article); tbl_Users curretUser = db.tbl_Users.SingleOrDefault(x => x.Username == HttpContext.User.Identity.Name); //tbl_Article currArt = db.tbl_Article.SingleOrDefault(x => x.Article_Id == a.Article_Id); //a.Article_State_Id = currArt.Article_State_Id; if (curretUser.Role_Id == 1) //Reviewer { MyService.ServiceController myServiceController = new MyService.ServiceController(); myServiceController.AcceptOrRejectArticleByReviewer(a.Article_Id, a.Article_Name, a.Article_Description, a.Article_PublishDate, a.User_Id, a.MedaManager_Id, a.ArticleStatus_Id, a.Article_State_Id, a.tbl_Comments.ArticleComment_Content, Convert.ToInt32(a.ArticleComment_Id), "TextArticle"); ViewBag.ArticleStatus_Id = new SelectList(db.tbl_ArticleStatus, "ArticleStatus_Id", "ArticleStatus_Type"); ViewBag.User_Id = new SelectList(db.tbl_Users, "User_Id", "First_Name"); return View(); } else if (curretUser.Role_Id == 2) //Media Manager { MyService.ServiceController myServiceController = new MyService.ServiceController(); myServiceController.AcceptOrRejectArticleByMediaManager(a.Article_Id, a.Article_Name, a.Article_Description, a.Article_PublishDate, a.User_Id, a.MedaManager_Id, a.ArticleStatus_Id, a.Article_State_Id, a.tbl_Comments.ArticleComment_Content, Convert.ToInt32(a.ArticleComment_Id), "TextArticle"); ViewBag.ArticleStatus_Id = new SelectList(db.tbl_ArticleStatus, "ArticleStatus_Id", "ArticleStatus_Type"); ViewBag.User_Id = new SelectList(db.tbl_Users, "User_Id", "First_Name"); return View(); } return View(); }