Added delete functionality
This commit is contained in:
@@ -1,9 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Tv7Playlist.Core;
|
|
||||||
using Tv7Playlist.Data;
|
using Tv7Playlist.Data;
|
||||||
using Tv7Playlist.Models;
|
|
||||||
|
|
||||||
namespace Tv7Playlist.Controllers
|
namespace Tv7Playlist.Controllers
|
||||||
{
|
{
|
||||||
@@ -56,5 +54,35 @@ namespace Tv7Playlist.Controllers
|
|||||||
|
|
||||||
return View(updatedEntry);
|
return View(updatedEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||||
|
public async Task<IActionResult> Delete(Guid? id)
|
||||||
|
{
|
||||||
|
if (id == null) return NotFound();
|
||||||
|
|
||||||
|
var entry = await _playlistContext.PlaylistEntries.FindAsync(id);
|
||||||
|
if (entry == null) return NotFound();
|
||||||
|
|
||||||
|
return View(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||||
|
[ValidateAntiForgeryToken]
|
||||||
|
public async Task<IActionResult> DeleteConfirmed(Guid? id)
|
||||||
|
{
|
||||||
|
if (id == null) return NotFound();
|
||||||
|
|
||||||
|
var entry = await _playlistContext.PlaylistEntries.FindAsync(id);
|
||||||
|
if (entry == null) return NotFound();
|
||||||
|
|
||||||
|
_playlistContext.PlaylistEntries.Remove(entry);
|
||||||
|
|
||||||
|
await _playlistContext.SaveChangesAsync();
|
||||||
|
|
||||||
|
return RedirectToAction("Index", "Home");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -25,7 +25,10 @@
|
|||||||
foreach (var track in Model.PlaylistEntries)
|
foreach (var track in Model.PlaylistEntries)
|
||||||
{
|
{
|
||||||
<tr>
|
<tr>
|
||||||
<td><a class="btn btn-secondary" asp-area="" asp-controller="PlaylistEntry" asp-action="Edit" asp-route-id="@track.Id">Edit</a></td>
|
<td>
|
||||||
|
<a class="btn btn-secondary" asp-area="" asp-controller="PlaylistEntry" asp-action="Edit" asp-route-id="@track.Id">Edit</a>
|
||||||
|
<a class="btn btn-danger" asp-area="" asp-controller="PlaylistEntry" asp-action="Delete" asp-route-id="@track.Id">Delete</a>
|
||||||
|
</td>
|
||||||
<td>@track.ChannelNumberImport</td>
|
<td>@track.ChannelNumberImport</td>
|
||||||
<td>@track.ChannelNumberExport</td>
|
<td>@track.ChannelNumberExport</td>
|
||||||
<td>@track.Position</td>
|
<td>@track.Position</td>
|
||||||
|
65
Tv7Playlist/Views/PlaylistEntry/Delete.cshtml
Normal file
65
Tv7Playlist/Views/PlaylistEntry/Delete.cshtml
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
@model Tv7Playlist.Data.PlaylistEntry;
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = $"Delete channel {Model.ChannelNumberExport} - {Model.Name}";
|
||||||
|
}
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col offset-2 col-8">
|
||||||
|
<h3>Delete channel @Model.ChannelNumberExport - @Model.Name ?</h3>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr/>
|
||||||
|
|
||||||
|
<form asp-action="DeleteConfirmed">
|
||||||
|
<input type="hidden" asp-for="Id"/>
|
||||||
|
|
||||||
|
<div class="form-group row">
|
||||||
|
<div class="offset-sm-2 col-sm-2">
|
||||||
|
<label asp-for="ChannelNumberExport" class="control-label">Channel number export:</label>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-4">
|
||||||
|
<input asp-for="ChannelNumberExport" readonly class="form-control"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group row">
|
||||||
|
<div class="offset-sm-2 col-sm-2">
|
||||||
|
<label asp-for="EpgMatchName" class="control-label">EPG Name:</label>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-4">
|
||||||
|
<input asp-for="EpgMatchName" readonly class="form-control"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group row">
|
||||||
|
<div class="offset-sm-2 col-sm-2">
|
||||||
|
<label asp-for="IsAvailable" class="control-label form-check-label">Available</label>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-1 form-check">
|
||||||
|
<input asp-for="IsAvailable" class="form-control form-control-sm" readonly disabled="true"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group row">
|
||||||
|
<div class="offset-sm-2 col-sm-2">
|
||||||
|
<label asp-for="UrlOriginal" class="control-label">Original URL</label>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-4">
|
||||||
|
<input asp-for="UrlOriginal" readonly class="form-control"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr/>
|
||||||
|
|
||||||
|
<div class="form-group row">
|
||||||
|
<div class="col offset-sm-4 col-sm-4">
|
||||||
|
<input type="submit" value="Delete" class="btn btn-danger"/>
|
||||||
|
<a asp-action="Index" asp-controller="Home" class="btn btn-secondary">Cancel</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
@section Scripts {
|
||||||
|
@{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
|
||||||
|
}
|
@@ -4,7 +4,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col col-12">
|
<div class="col offset-2 col-8">
|
||||||
<h3>Edit channel @Model.ChannelNumberExport - @Model.Name</h3>
|
<h3>Edit channel @Model.ChannelNumberExport - @Model.Name</h3>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Reference in New Issue
Block a user