summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Controllers/BundlesController.cs10
-rw-r--r--Views/Bundles/Index.cshtml2
2 files changed, 12 insertions, 0 deletions
diff --git a/Controllers/BundlesController.cs b/Controllers/BundlesController.cs
index 8b66139..1f5c212 100644
--- a/Controllers/BundlesController.cs
+++ b/Controllers/BundlesController.cs
@@ -22,5 +22,15 @@ namespace MyDarling.Controllers
{
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");
+ }
}
} \ No newline at end of file
diff --git a/Views/Bundles/Index.cshtml b/Views/Bundles/Index.cshtml
index 6c36cb7..e93edb2 100644
--- a/Views/Bundles/Index.cshtml
+++ b/Views/Bundles/Index.cshtml
@@ -18,6 +18,7 @@
<th scope="col">Name</th>
<th scope="col">Descrition</th>
<th scope="col">Price</th>
+ <th scope="col">Actions</th>
</tr>
</thead>
<tbody>
@@ -28,6 +29,7 @@
<td><a asp-action="Edit" asp-route-id="@bundle.Id">@bundle.Name</a></td>
<td>@bundle.Description</td>
<td>@bundle.Price</td>
+ <td><a asp-action="Delete" asp-route-id="@bundle.Id">Delete</a></td>
</tr>
}
</tbody>