This commit is contained in:
Benjamin
2024-11-21 09:22:49 +01:00
parent bf6377168a
commit dabb7648e5
3 changed files with 15 additions and 3 deletions

View File

@@ -22,6 +22,13 @@ namespace pointMaster.Controllers
vm.points = await context.Points.Include(p => p.Patrulje).Include(p => p.Poster).ToListAsync(); vm.points = await context.Points.Include(p => p.Patrulje).Include(p => p.Poster).ToListAsync();
vm.AllowedToDelete = false;
if (HttpContext.User.Claims.FirstOrDefault(x => x.Value == Roles.Editor) != null)
{
vm.AllowedToDelete = true;
}
return View(vm); return View(vm);
} }
@@ -172,5 +179,6 @@ namespace pointMaster.Controllers
public class PointViewModel public class PointViewModel
{ {
public List<Point> points { get; set; } = null!; public List<Point> points { get; set; } = null!;
public bool AllowedToDelete { get; set; } = false;
} }
} }

View File

@@ -10,7 +10,9 @@
<th scope="col">Post</th> <th scope="col">Post</th>
<th scope="col">Point</th> <th scope="col">Point</th>
<th scope="col">Turnout</th> <th scope="col">Turnout</th>
<th scope="col"></th> @if (Model.AllowedToDelete) {
<th scope="col"></th>
}
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@@ -21,7 +23,9 @@
<td scope="row">@point.Poster.Name</td> <td scope="row">@point.Poster.Name</td>
<td scope="row">@point.Points</td> <td scope="row">@point.Points</td>
<td scope="row">@point.Turnout</td> <td scope="row">@point.Turnout</td>
<td scope="row"><a asp-action="DeletePoint" asp-controller="Point" asp-route-id="@point.Id" class="btn btn-danger">Slet point</a></td> @if (Model.AllowedToDelete) {
<td scope="row"><a asp-action="DeletePoint" asp-controller="Point" asp-route-id="@point.Id" class="btn btn-danger">Slet point</a></td>
}
</tr> </tr>
} }
</tbody> </tbody>

View File

@@ -23,7 +23,7 @@
<td scope="row" class="align-middle">@round.Description</td> <td scope="row" class="align-middle">@round.Description</td>
<td scope="row" class="align-middle">@round.Location</td> <td scope="row" class="align-middle">@round.Location</td>
<td scope="row" class="d-flex justify-content-end"> <td scope="row" class="d-flex justify-content-end">
<a asp-action="SletPost" asp-route-id="@round.Id" class="btn btn-danger">Slet runde</a> <a asp-action="SletPost" asp-route-id="@round.Id" class="btn btn-danger">Slet post</a>
</td> </td>
</tr> </tr>
} }