示例#1
0
        public IActionResult OnPost(int restaurantId)
        {
            var restaurant = restauranteData.Delete(restaurantId);

            restauranteData.Commit();
            if (restaurant == null)
            {
                return(RedirectToPage("./NotFound"));
            }
            TempData["Message"] = $"{restaurant.Name} deleted.";
            return(RedirectToPage("./List"));
        }
示例#2
0
        public IActionResult OnPost()
        {
            if (!ModelState.IsValid)
            {
                Cuisines = htmlHelper.GetEnumSelectList <TipoCozinha>();
                return(Page());
            }
            //Como a página Edit é reutilizada verifica se: update ou add a restaurant
            if (Restaurante.Id > 0)
            {
                restauranteData.Update(Restaurante);
            }
            else
            {
                restauranteData.Add(Restaurante);
            }

            restauranteData.Commit();
            return(RedirectToPage("./Detail", new { restaurantId = Restaurante.Id }));
        }