Вот мои методы «Удалить» и «DeleteConfirmed» RobotController код>
Код: Выделить всё
[HttpGet]
public async Task[i] Delete(string id)
{
if (id == null)
{
return NotFound();
}
var robot = await _robotRepo.GetRobotByIdAsync(id);
if (robot == null)
{
return NotFound();
}
var robotDetails = new RobotDetailsViewModel
{
Id = robot.Id,
Name = robot.Name
};
return View("Delete", robotDetails);
}
[HttpPost]
[ValidateAntiForgeryToken]
public async Task DeleteConfirmed(string id)
{
await _robotRepo.DeleteRobotByIdAsync(id);
TempData["SuccessMessage"] = "Robot deleted successfully";
return RedirectToAction("Index");
}
Код: Выделить всё
@model AnyTaskRobotStore.ViewModels.RobotDetailsViewModel
[img]@Model.Image[/img]
@* Lots of markup *@
@* Buttons *@
[/i] Delete
Код: Выделить всё
@model AnyTaskRobotStore.ViewModels.RobotDetailsViewModel
Delete Robot
Are you sure you want to delete this robot: @Model.Name?
Back to Details
Подробнее здесь: https://stackoverflow.com/questions/792 ... ete-action
Мобильная версия