Esempio n. 1
0
        public IActionResult Edit(AuthorViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (model.Author.Id == 0)
                {
                    model.Author        = personData.Create(model.Author);
                    TempData["Message"] = "The Object is created!";
                }
                else
                {
                    model.Author        = personData.Update(model.Author);
                    TempData["Message"] = "The Object is updated!";
                }

                personData.Commit();
                return(RedirectToAction("Index"));
            }

            return(View(model));
        }
        public IActionResult OnPost()
        {
            if (ModelState.IsValid)
            {
                if (Author.Id == 0)
                {
                    Author = personData.Create(Author);
                    TempData["Message"] = "The Object is created!";
                }
                else
                {
                    Author = personData.Update(Author);
                    TempData["Message"] = "The Object is updated!";
                }

                personData.Commit();
                return(RedirectToPage("./List"));
            }

            return(Page());
        }