public ActionResult Update(int id) { var vm = new ChildrensTextCreateUpdate(); try { vm.ChildrensText = _gateway.Read(id); vm.Languages = _languageServiceGateway.ReadAll(); vm.GlobalGoalId = vm.ChildrensText.GlobalGoalId; TempData["toast"] = "Dine ændringer er gemt!"; return(PartialView("CreateUpdate", vm)); } catch (Exception e) { Console.WriteLine(e); TempData["toast"] = "Fejl i indlæsning af ChildrensText. Prøv igen eller kontakt administrator"; return(PartialView("CreateUpdate", new ChildrensTextCreateUpdate())); } }
public ActionResult Update(ChildrensTextCreateUpdate vm) { try { if (ModelState.IsValid) { vm.ChildrensText = _gateway.Update(vm.ChildrensText); return(RedirectToAction("Index", new { id = vm.ChildrensText.GlobalGoalId })); } else { ModelState.AddModelError("Fejl i model", "Modellen er ugyldig, prøv igen!"); return(RedirectToAction("Index", new { id = vm.ChildrensText.GlobalGoalId })); } } catch (Exception e) { ModelState.AddModelError("error", e.Message); return(RedirectToAction("Index", vm.ChildrensText)); } }
public ActionResult Create(ChildrensTextCreateUpdate vm) { try { if (ModelState.IsValid) { var text = _gateway.Create(vm.ChildrensText); return(RedirectToAction("Index", new { id = vm.ChildrensText.GlobalGoalId })); } else { ModelState.AddModelError("Fejl i model", "Modellen er ugyldig, prøv igen!"); return(RedirectToAction("Index", new { id = vm.ChildrensText.GlobalGoalId })); } } catch (Exception e) { Console.WriteLine(e); TempData["toast"] = "Kunne ikke oprette den valgte ChildrensText. Prøv igen eller kontakt administrator"; return(RedirectToAction("Index", vm.ChildrensText)); } }