public ActionResult Create(WordDef wordDef) { ViewBag.currentWord = wordDef.wordId; if (ModelState.IsValid) { var currentUser = manager.FindById(User.Identity.GetUserId()); Word currentWord = db.Words.First(w => w.Id == wordDef.wordId); if (currentWord.User.Id == currentUser.Id) { ViewBag.redirectUrl = Url.Action("details", "words", new { id = wordDef.wordId }); db.WordDefs.Add(wordDef); db.SaveChanges(); return(PartialView("_RedirectPage")); } return(HttpNotFound()); } else { return(View()); } }
public ActionResult DeleteConfirmed(int id) { WordDef wordDef = db.WordDefs.Find(id); db.WordDefs.Remove(wordDef); db.SaveChanges(); return(Json(new { success = true })); }
public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } WordDef wordDef = db.WordDefs.Find(id); if (wordDef == null) { return(HttpNotFound()); } return(View(wordDef)); }
// GET: WordDefs/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } WordDef wordDef = db.WordDefs.Find(id); if (wordDef == null) { return(HttpNotFound()); } ViewBag.wordId = new SelectList(db.Words, "Id", "WContext", wordDef.wordId); return(View(wordDef)); }
// GET: WordDefs/Delete/5 //[ChildActionOnly] public ActionResult Delete(int?id) { var currentUser = manager.FindById(User.Identity.GetUserId()); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } WordDef wordDef = db.WordDefs.Find(id); if (wordDef == null) { return(HttpNotFound()); } if (wordDef.word.User != currentUser) { return(HttpNotFound()); } ViewBag.wContext = wordDef.word.WordDetail.WContext; return(View(wordDef)); }
public ActionResult Edit([Bind(Include = "id,wType,wDefinition,wExample")] WordDef wordDef) { if (wordDef.wDefinition != null) { WordDef defwordFound = db.WordDefs.Find(wordDef.id); if (defwordFound != null) { defwordFound.wType = wordDef.wType; defwordFound.wDefinition = wordDef.wDefinition; defwordFound.wExample = wordDef.wExample; db.Entry(defwordFound).State = EntityState.Modified; db.SaveChanges(); return(Json(new { success = true })); } else { return(View(wordDef)); } } ViewBag.wordId = new SelectList(db.Words, "Id", "WContext", wordDef.wordId); return(View(wordDef)); }