public ActionResult Create() { var model = new ActicleViewModel() { ParentCategory = db.Categories.Where(x => x.ParentId == null) }; return(View(model)); }
public ActionResult Update(int id, ActicleViewModel model) { var article = db.Articles.FirstOrDefault(x => x.Id == id); if (article != null) { if (ModelState.IsValid) { service.Update(model.Article); return(RedirectToAction("Index")); } } return(View(model)); }
public ActionResult Create(ActicleViewModel model, FormCollection fc) { model.ParentCategory = cate.AllList(); if (ModelState.IsValid) { model.Article.CreateBy = User.Identity.Name; var u = service.Create(model.Article); return(RedirectToAction("Index")); } model.ParentCategory = db.Categories.Where(c => c.ParentId == 0); return(View(model)); }
public ActionResult Update(int id) { var article = db.Articles.FirstOrDefault(x => x.Id == id); if (article == null) { return(HttpNotFound()); } var model = new ActicleViewModel { Article = article, ParentCategory = db.Categories.Where(x => x.ParentId == null) }; return(View(model)); }