Exemplo n.º 1
0
        public ActionResult WithPRG(PRGViewModel model)
        {
            if (ModelState.IsValid)
            {
                // Perform update
                if (model.DummyID.HasValue)
                {
                    DummyService.Edit(model.DummyID.Value, model.Name, model.Date, model.EmailAddress);
                    AddSuccessMessage("Edited successfully");
                }
                else
                {
                    model.DummyID = DummyService.Add(model.Name, model.Date, model.EmailAddress);
                    AddSuccessMessage("Added successfully");
                }

                // Follow Post-Redirect-Get pattern by redirecting to GET after successful POST update
                // Pass reload details via route for reloading in GET (this is always the preferred approach)
                return(RedirectToAction("WithPRG", new { id = model.DummyID }));
            }

            return(View(model));
        }