public ActionResult DeleteConfirmed(int id) { M_MessageBoard m_MessageBoard = db.M_MessageBoard.Find(id); db.M_MessageBoard.Remove(m_MessageBoard); db.SaveChanges(); return(RedirectToAction("Detial", "Class", new { id = Convert.ToInt32(Request.Cookies["classid"].Value) })); }
// GET: M_MessageBoard/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } M_MessageBoard m_MessageBoard = db.M_MessageBoard.Find(id); if (m_MessageBoard == null) { return(HttpNotFound()); } return(PartialView(m_MessageBoard)); }
// GET: M_MessageBoard/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } M_MessageBoard m_MessageBoard = db.M_MessageBoard.Find(id); if (m_MessageBoard == null) { return(HttpNotFound()); } ViewBag.ClassID = new SelectList(db.C_Class, "ClassID", "ClassName", m_MessageBoard.ClassID); //ViewBag.LessonID = new SelectList(db.C_Lesson, "LessonID", "LessonName", m_MessageBoard.LessonID); ViewBag.PostTypeID = new SelectList(db.M_PostType, "PostTypeID", "PostTypeName", m_MessageBoard.PostTypeID); ViewBag.UserID = new SelectList(db.U_User, "UserID", "UserAccount", m_MessageBoard.UserID); return(PartialView(m_MessageBoard)); }
public ActionResult _Create([Bind(Include = "MessageBoardID,MessageBoardContent,PostTime,Status,UserID,ClassID,LessonID,PostTypeID")] M_MessageBoard m_MessageBoard) { if (ModelState.IsValid) { db.M_MessageBoard.Add(m_MessageBoard); db.Entry(m_MessageBoard).Entity.PostTime = DateTime.Now.Date; db.Entry(m_MessageBoard).Entity.Status = true; db.Entry(m_MessageBoard).Entity.PostTypeID = 5; db.Entry(m_MessageBoard).Entity.UserID = Convert.ToInt32(Request.Cookies["UserID"].Value); db.Entry(m_MessageBoard).Entity.ClassID = Convert.ToInt32(Request.Cookies["classid"].Value); db.SaveChanges(); return(RedirectToAction("Detial", "Class", new { id = Convert.ToInt32(Request.Cookies["classid"].Value) })); } ViewBag.ClassID = new SelectList(db.C_Class, "ClassID", "ClassName", m_MessageBoard.ClassID); //ViewBag.LessonID = new SelectList(db.C_Lesson, "LessonID", "LessonName", m_MessageBoard.LessonID); ViewBag.PostTypeID = new SelectList(db.M_PostType, "PostTypeID", "PostTypeName", m_MessageBoard.PostTypeID); ViewBag.UserID = Convert.ToInt32(Request.Cookies["UserID"].Value); return(PartialView(m_MessageBoard)); }