Add delete action for bundles controller
This commit is contained in:
parent
e4b4105ec0
commit
b20759f205
@ -22,5 +22,15 @@ namespace MyDarling.Controllers
|
|||||||
{
|
{
|
||||||
return View(repository.Bundles.Where(b => b.Id == id).FirstOrDefault());
|
return View(repository.Bundles.Where(b => b.Id == id).FirstOrDefault());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ActionResult Delete(int id)
|
||||||
|
{
|
||||||
|
var bundle = repository.Bundles.Where(b => b.Id == id).FirstOrDefault();
|
||||||
|
if (bundle != null)
|
||||||
|
{
|
||||||
|
repository.Remove(bundle);
|
||||||
|
}
|
||||||
|
return RedirectToAction("Index");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -18,6 +18,7 @@
|
|||||||
<th scope="col">Name</th>
|
<th scope="col">Name</th>
|
||||||
<th scope="col">Descrition</th>
|
<th scope="col">Descrition</th>
|
||||||
<th scope="col">Price</th>
|
<th scope="col">Price</th>
|
||||||
|
<th scope="col">Actions</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -28,6 +29,7 @@
|
|||||||
<td><a asp-action="Edit" asp-route-id="@bundle.Id">@bundle.Name</a></td>
|
<td><a asp-action="Edit" asp-route-id="@bundle.Id">@bundle.Name</a></td>
|
||||||
<td>@bundle.Description</td>
|
<td>@bundle.Description</td>
|
||||||
<td>@bundle.Price</td>
|
<td>@bundle.Price</td>
|
||||||
|
<td><a asp-action="Delete" asp-route-id="@bundle.Id">Delete</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
Loading…
Reference in New Issue
Block a user