Exemplo n.º 1
0
        public IActionResult OnPost(int islandId)
        {
            var island = islandDataService.Delete(islandId);

            islandDataService.Commit();
            if (island == null)
            {
                return(RedirectToPage("./NotFopund"));
            }

            TempData["Message"] = $"{island.Name} deleted.";
            return(RedirectToPage("./TopRated"));
        }
Exemplo n.º 2
0
        public IActionResult OnPost()
        {
            if (!ModelState.IsValid)
            {
                this.Climates = htmlHelper.GetEnumSelectList <ClimateType>();
                return(Page());
            }

            if (Island.Id > 0)
            {
                islandData.Update(Island);                              // Island = islandData.Update(Island); => "Island" can be ommitted here because it is automatically popultaed by model binding.
                TempData["Message"] = "Resaurant successfully updated"; // TempData only available for next request and not for subsequent requests.
            }
            else
            {
                islandData.Add(Island);
                TempData["Message"] = "Resaurant successfully added";
            }

            islandData.Commit();
            return(RedirectToPage("./Detail", new { islandId = Island.Id })); // Do not leave user on a page with post form after successful post: page refresh might lead to problems.
        }