public ActionResult GetTranslationById(TranslationViewModel t, int? id) { if (t == null) { return View("NotFound"); } // If model is valid, then update the model. if(ModelState.IsValid) { translationRepo.Update(t.Translation.translationText, id); string returnUrl = "/GetTranslationById/" + id.ToString(); return RedirectToAction(returnUrl); } return View(t); }
public ActionResult GetTranslationById(int? id) { // Prevents the user from crashing the site if(id == null || !translationRepo.isIdValid(id)) { return View("NotFound"); } var model = (from translation in translationRepo.GetAllTranslations() where translation.ID == id select translation).SingleOrDefault(); // Fetch comments for the translation in question. var comments = (from comm in commentRepo.GetAllComments() where comm.tID == id select comm); TranslationViewModel tViewModel = new TranslationViewModel(); tViewModel.Translation = model; tViewModel.Comments = comments; return View(tViewModel); }