Ejemplo n.º 1
0
        public ActionResult Update(int id)
        {
            var vm = new ArtworkCreateUpdate();

            try
            {
                vm.Artwork        = _gateway.Read(id);
                vm.Languages      = _languageGateway.ReadAll();
                vm.GlobalGoalId   = vm.Artwork.GlobalGoalId;
                TempData["toast"] = "Dine ændringer er gemt!";
                return(PartialView("CreateUpdate", vm));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                TempData["toast"] = "Der skete en fejl. Prøv igen eller kontakt administrator!";
                return(PartialView("CreateUpdate", new ArtworkCreateUpdate()));
            }
        }
Ejemplo n.º 2
0
 public ActionResult Create(ArtworkCreateUpdate vm)
 {
     try
     {
         if (ModelState.IsValid)
         {
             _gateway.Create(vm.Artwork);
             TempData["toast"] = "Artwork er oprettet!";
             return(RedirectToAction("Index", new { id = vm.Artwork.GlobalGoalId }));
         }
         else
         {
             ModelState.AddModelError("Fejl i model", "Modellen er ugyldig, prøv igen!");
             return(RedirectToAction("Index", vm.Artwork.GlobalGoalId));
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         TempData["toast"] = "Den valgte Artwork kunne ikke oprettes. Prøv igen eller kontakt administrator";
         return(RedirectToAction("Index", vm));
     }
 }