Ejemplo n.º 1
0
        public async Task <IActionResult> Delete(PageViewModel viewModel)
        {
            var menuViewModel = await _pageService.GetByIdAsync(viewModel.Id);

            if (menuViewModel == null)
            {
                ModelState.AddModelError("", RequestNotFound);
            }
            else
            {
                var result = await _pageService.DeleteAsync(menuViewModel.Id);

                if (result)
                {
                    _searchManager.DeleteFromIndex(menuViewModel);
                    return(Json(new { success = true }));
                }

                ModelState.AddModelError("", RequestNotFound);
            }

            return(PartialView("_Delete", model: viewModel));
        }