Startpunkten
This commit is contained in:
44
Views/Sport/Create.cshtml
Normal file
44
Views/Sport/Create.cshtml
Normal file
@@ -0,0 +1,44 @@
|
||||
@model Sport
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Lägg till sport";
|
||||
}
|
||||
|
||||
<div class="container mb-5">
|
||||
<h2 class="text-center mt-3 mb-4">@ViewData["Title"]</h2>
|
||||
|
||||
<form action="Create" method="post" enctype="multipart/form-data">
|
||||
<div class="form-group">
|
||||
<label asp-for="@Model.SportNamn" class="control-label"></label>
|
||||
<input type="text" class="form-control" asp-for="SportNamn" tabindex="1" placeholder="Sportens namn">
|
||||
<span asp-validation-for="SportNamn" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="@Model.Ingress" class="control-label"></label>
|
||||
<input type="text" class="form-control" asp-for="Ingress" tabindex="2" placeholder="Ingresstext">
|
||||
<span asp-validation-for="Ingress" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="@Model.DetaljText" class="control-label"></label>
|
||||
<textarea class="form-control" asp-for="DetaljText" tabindex="3" placeholder="Detaljerad text"></textarea>
|
||||
<span asp-validation-for="DetaljText" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="@Model.Traningstider" class="control-label"></label>
|
||||
<input type="text" class="form-control" asp-for="Traningstider" tabindex="4" placeholder="Träningstider">
|
||||
<span asp-validation-for="Traningstider" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="@Model.Bakgrundsbild" class="control-label"></label>
|
||||
<input type="file" class="form-control" asp-for="Bakgrundsbild" tabindex="5">
|
||||
<span asp-validation-for="Bakgrundsbild" class="text-danger"></span>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary">Lägg till</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
|
||||
}
|
||||
|
||||
27
Views/Sport/Details.cshtml
Normal file
27
Views/Sport/Details.cshtml
Normal file
@@ -0,0 +1,27 @@
|
||||
@model Sport
|
||||
@{
|
||||
ViewData["Title"] = "Mina Sporter";
|
||||
}
|
||||
|
||||
<div class="container mt-2 mb-5">
|
||||
<img src="~/images/sport/@Model.Bakgrundsbild" alt="@Model.SportNamn" class="img-fluid maxad mb-5" />
|
||||
<h2>@Model.SportNamn</h2>
|
||||
<p class="lead font-weight-bold">@Model.Ingress</p>
|
||||
<p>@Model.DetaljText</p>
|
||||
|
||||
<h2>Träningstider</h2>
|
||||
<p>@Model.Traningstider</p>
|
||||
|
||||
|
||||
@if (Context.User.Identity.IsAuthenticated) {
|
||||
<a href="/Sport" class="btn btn-success mt-3">Tillbaka till sporterna</a>
|
||||
}
|
||||
else {
|
||||
<a href="/Sport/Utbud" class="btn btn-success mt-3">Tillbaka till utbudet</a>
|
||||
}
|
||||
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
|
||||
}
|
||||
40
Views/Sport/Edit.cshtml
Normal file
40
Views/Sport/Edit.cshtml
Normal file
@@ -0,0 +1,40 @@
|
||||
@model Sport
|
||||
@{
|
||||
ViewData["Title"] = "Editera en Sport";
|
||||
}
|
||||
<h2 class="text-center mt-3 mb-4">@ViewData["Title"]</h2>
|
||||
|
||||
<form action="Edit" method="post" enctype="multipart/form-data">
|
||||
<input type="hidden" asp-for="SportId" value="@Model.SportId" />
|
||||
<div class="form-group">
|
||||
<label>SportNamn</label>
|
||||
<input type="text" class="form-control" asp-for="SportNamn" tabindex="1">
|
||||
<span asp-validation-for="SportNamn" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Ingress" class="control-label"></label>
|
||||
<input type="text" class="form-control" asp-for="Ingress" value="@Model.Ingress">
|
||||
<span asp-validation-for="Ingress" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="DetaljText" class="control-label"></label>
|
||||
<textarea class="form-control" asp-for="DetaljText" tabindex="2">@Model.DetaljText</textarea>
|
||||
<span asp-validation-for="DetaljText" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="Traningstider" class="control-label"></label>
|
||||
<input type="text" class="form-control" asp-for="Traningstider" tabindex="3">
|
||||
<span asp-validation-for="Traningstider" class="text-danger"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label asp-for="@Model.Bakgrundsbild" class="control-label"></label>
|
||||
<input type="file" class="form-control" asp-for="Bakgrundsbild" tabindex="4">
|
||||
<span asp-validation-for="Bakgrundsbild" class="text-danger"></span>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Spara ändringar</button>
|
||||
</form>
|
||||
|
||||
|
||||
@section Scripts {
|
||||
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
|
||||
}
|
||||
58
Views/Sport/Index.cshtml
Normal file
58
Views/Sport/Index.cshtml
Normal file
@@ -0,0 +1,58 @@
|
||||
@model List<Sport>
|
||||
@{
|
||||
ViewData["Title"] = "Detta finns på SportPalatset";
|
||||
}
|
||||
<h2 class="text-center mt-3 mb-4">@ViewData["Title"]</h2>
|
||||
|
||||
<a href="/Sport/Create" class="btn btn-success mb-5">Skapa ny Sport</a>
|
||||
|
||||
@if (TempData.ContainsKey("MeddelandeSuccess")) {
|
||||
<div class="alert alert-success alert-dismissible">
|
||||
<button type="button" class="close" data-dismiss="alert">×</button>
|
||||
<strong>Allt klart!</strong> @TempData["MeddelandeSuccess"]
|
||||
</div>
|
||||
}
|
||||
else if (TempData.ContainsKey("MeddelandeFail")) {
|
||||
<div class="alert alert-danger alert-dismissible">
|
||||
<button type="button" class="close" data-dismiss="alert">×</button>
|
||||
<strong>Något gick fel.</strong> @TempData["MeddelandeFail"]
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="container">
|
||||
@if (Model.Count() >= 1) {
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Id</th>
|
||||
<th>SportNamn</th>
|
||||
<th>Traningstider</th>
|
||||
<th>Bild</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var sport in Model) {
|
||||
<tr>
|
||||
<td>@sport.SportId</td>
|
||||
<td>@sport.SportNamn</td>
|
||||
<td>@sport.Traningstider</td>
|
||||
<td><img src="~/images/sport/@sport.Bakgrundsbild" alt="@sport.SportNamn" class="visningsbild" /></td>
|
||||
<td>
|
||||
<a asp-action="Delete" asp-controller="Sport" asp-route-Id="@sport.SportId">Ta bort</a> |
|
||||
<a asp-action="Edit" asp-controller="Sport" asp-route-Id="@sport.SportId">Editera</a> |
|
||||
<a asp-action="Details" asp-controller="Sport" asp-route-Id="@sport.SportId">Detaljer</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
}
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
@section Scripts {
|
||||
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
|
||||
}
|
||||
28
Views/Sport/Utbud.cshtml
Normal file
28
Views/Sport/Utbud.cshtml
Normal file
@@ -0,0 +1,28 @@
|
||||
@model List<Sport>
|
||||
@{
|
||||
ViewData["Title"] = "Detta finns på SportPalatset";
|
||||
}
|
||||
|
||||
<h2 class="text-center mt-3 mb-4">@ViewData["Title"]</h2>
|
||||
<p class="lead text-center font-weight-bold mt-1 mb-4">Hos oss hittar du allt för din träning. Det spelar ingen roll om du är elitsatsande eller motionär.</p>
|
||||
<div class="container">
|
||||
@foreach (var sport in Model) {
|
||||
<a href="/Sport/Details/@sport.SportId">
|
||||
<div class="col-sm mt-3">
|
||||
<div class="card bg-dark text-white">
|
||||
<img class="card-img" src="~/images/sport/@sport.Bakgrundsbild" alt="@sport.SportNamn">
|
||||
<div class="card-img-overlay myCard">
|
||||
<h3 class="card-title">@sport.SportNamn</h3>
|
||||
<p class="card-text mt-5">@sport.Ingress</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
}
|
||||
</div>
|
||||
|
||||
<p class="lead mt-5 mb-5 text-center font-weight-bold">Kom du ända hit utan att hitta något? Scrolla tillbaka så hittar du något kul för dig!</p>
|
||||
|
||||
@section Scripts {
|
||||
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
|
||||
}
|
||||
Reference in New Issue
Block a user