Bearbeitung von Lektion und Kurs
This commit is contained in:
@@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Mvc;
|
|||||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using MultipleChoiceTrainer.Data;
|
using MultipleChoiceTrainer.Data;
|
||||||
|
using MultipleChoiceTrainer.Models;
|
||||||
using MultipleChoiceTrainer.Models.DataModels;
|
using MultipleChoiceTrainer.Models.DataModels;
|
||||||
|
|
||||||
namespace MultipleChoiceTrainer.Controllers
|
namespace MultipleChoiceTrainer.Controllers
|
||||||
@@ -19,24 +20,6 @@ namespace MultipleChoiceTrainer.Controllers
|
|||||||
_context = context;
|
_context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET: Categories/Details/5
|
|
||||||
public async Task<IActionResult> Details(int? id)
|
|
||||||
{
|
|
||||||
if (id == null)
|
|
||||||
{
|
|
||||||
return NotFound();
|
|
||||||
}
|
|
||||||
|
|
||||||
var category = await _context.Categories
|
|
||||||
.FirstOrDefaultAsync(m => m.Id == id);
|
|
||||||
if (category == null)
|
|
||||||
{
|
|
||||||
return NotFound();
|
|
||||||
}
|
|
||||||
|
|
||||||
return View(category);
|
|
||||||
}
|
|
||||||
|
|
||||||
// GET: Categories/Create
|
// GET: Categories/Create
|
||||||
public IActionResult Create()
|
public IActionResult Create()
|
||||||
{
|
{
|
||||||
@@ -48,15 +31,15 @@ namespace MultipleChoiceTrainer.Controllers
|
|||||||
// more details, see http://go.microsoft.com/fwlink/?LinkId=317598.
|
// more details, see http://go.microsoft.com/fwlink/?LinkId=317598.
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[ValidateAntiForgeryToken]
|
[ValidateAntiForgeryToken]
|
||||||
public async Task<IActionResult> Create([Bind("Id,Name,Description")] Category category)
|
public async Task<IActionResult> Create(CategoryEditViewModel editViewModel)
|
||||||
{
|
{
|
||||||
if (ModelState.IsValid)
|
if (ModelState.IsValid)
|
||||||
{
|
{
|
||||||
_context.Add(category);
|
_context.Add(editViewModel.Entity);
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
return RedirectToAction(nameof(Index), "Home");
|
return RedirectToAction(nameof(Index), "Home", new { categoryId = editViewModel.Entity.Id });
|
||||||
}
|
}
|
||||||
return View(category);
|
return View(editViewModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET: Categories/Edit/5
|
// GET: Categories/Edit/5
|
||||||
@@ -72,7 +55,7 @@ namespace MultipleChoiceTrainer.Controllers
|
|||||||
{
|
{
|
||||||
return NotFound();
|
return NotFound();
|
||||||
}
|
}
|
||||||
return View(category);
|
return View(new CategoryEditViewModel() { Entity = category });
|
||||||
}
|
}
|
||||||
|
|
||||||
// POST: Categories/Edit/5
|
// POST: Categories/Edit/5
|
||||||
@@ -80,23 +63,18 @@ namespace MultipleChoiceTrainer.Controllers
|
|||||||
// more details, see http://go.microsoft.com/fwlink/?LinkId=317598.
|
// more details, see http://go.microsoft.com/fwlink/?LinkId=317598.
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[ValidateAntiForgeryToken]
|
[ValidateAntiForgeryToken]
|
||||||
public async Task<IActionResult> Edit(int id, [Bind("Id,Name,Description")] Category category)
|
public async Task<IActionResult> Edit(CategoryEditViewModel editViewModel)
|
||||||
{
|
{
|
||||||
if (id != category.Id)
|
|
||||||
{
|
|
||||||
return NotFound();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ModelState.IsValid)
|
if (ModelState.IsValid)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_context.Update(category);
|
_context.Update(editViewModel.Entity);
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
catch (DbUpdateConcurrencyException)
|
catch (DbUpdateConcurrencyException)
|
||||||
{
|
{
|
||||||
if (!CategoryExists(category.Id))
|
if (!CategoryExists(editViewModel.Entity.Id))
|
||||||
{
|
{
|
||||||
return NotFound();
|
return NotFound();
|
||||||
}
|
}
|
||||||
@@ -105,9 +83,9 @@ namespace MultipleChoiceTrainer.Controllers
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return RedirectToAction(nameof(Index), "Home");
|
return RedirectToAction(nameof(Index), "Home", new { categoryId = editViewModel.Entity.Id });
|
||||||
}
|
}
|
||||||
return View(category);
|
return View(editViewModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool CategoryExists(int id)
|
private bool CategoryExists(int id)
|
||||||
|
|||||||
@@ -25,12 +25,13 @@ namespace MultipleChoiceTrainer.Controllers
|
|||||||
this.context = context;
|
this.context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IActionResult Index()
|
public IActionResult Index(int? categoryId)
|
||||||
{
|
{
|
||||||
if (signInManager.IsSignedIn(User))
|
if (signInManager.IsSignedIn(User))
|
||||||
{
|
{
|
||||||
var categories = context.Categories.Include(e => e.Sections).ThenInclude(e => e.Questions).ToList();
|
var categories = context.Categories.Include(e => e.Sections).ThenInclude(e => e.Questions).ToList();
|
||||||
return View(categories);
|
var selectedCategory = categoryId.HasValue ? categoryId.Value : categories.First().Id;
|
||||||
|
return View(new HomeViewModel() { Categories = categories, SelectedCategoryId = selectedCategory });
|
||||||
}
|
}
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|||||||
111
MultipleChoiceTrainer/Controllers/SectionsController.cs
Normal file
111
MultipleChoiceTrainer/Controllers/SectionsController.cs
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using MultipleChoiceTrainer.Data;
|
||||||
|
using MultipleChoiceTrainer.Models;
|
||||||
|
using MultipleChoiceTrainer.Models.DataModels;
|
||||||
|
|
||||||
|
namespace MultipleChoiceTrainer.Controllers
|
||||||
|
{
|
||||||
|
public class SectionsController : Controller
|
||||||
|
{
|
||||||
|
private readonly ApplicationDbContext _context;
|
||||||
|
|
||||||
|
public SectionsController(ApplicationDbContext context)
|
||||||
|
{
|
||||||
|
_context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
// GET: Sections/Create
|
||||||
|
public IActionResult Create(int? categoryId)
|
||||||
|
{
|
||||||
|
if(!categoryId.HasValue)
|
||||||
|
{
|
||||||
|
categoryId = _context.Categories.First().Id;
|
||||||
|
}
|
||||||
|
|
||||||
|
ViewData["CategoryId"] = new SelectList(_context.Categories, "Id", "Name", categoryId);
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
// POST: Sections/Create
|
||||||
|
// To protect from overposting attacks, enable the specific properties you want to bind to, for
|
||||||
|
// more details, see http://go.microsoft.com/fwlink/?LinkId=317598.
|
||||||
|
[HttpPost]
|
||||||
|
[ValidateAntiForgeryToken]
|
||||||
|
public async Task<IActionResult> Create([Bind("Id,Name,Description,CategoryId")] Section section)
|
||||||
|
{
|
||||||
|
if (ModelState.IsValid)
|
||||||
|
{
|
||||||
|
_context.Add(section);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
return RedirectToAction(nameof(Index), "Home", new { categoryId = section.CategoryId });
|
||||||
|
}
|
||||||
|
ViewData["CategoryId"] = new SelectList(_context.Categories, "Id", "Name", section.CategoryId);
|
||||||
|
return View(section);
|
||||||
|
}
|
||||||
|
|
||||||
|
// GET: Sections/Edit/5
|
||||||
|
public async Task<IActionResult> Edit(int? id)
|
||||||
|
{
|
||||||
|
if (id == null)
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
var section = await _context.Sections.FindAsync(id);
|
||||||
|
if (section == null)
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
ViewData["CategoryId"] = new SelectList(_context.Categories, "Id", "Name", section.CategoryId);
|
||||||
|
return View(section);
|
||||||
|
}
|
||||||
|
|
||||||
|
// POST: Sections/Edit/5
|
||||||
|
// To protect from overposting attacks, enable the specific properties you want to bind to, for
|
||||||
|
// more details, see http://go.microsoft.com/fwlink/?LinkId=317598.
|
||||||
|
[HttpPost]
|
||||||
|
[ValidateAntiForgeryToken]
|
||||||
|
public async Task<IActionResult> Edit(int id, [Bind("Id,Name,Description,CategoryId")] Section section)
|
||||||
|
{
|
||||||
|
if (id != section.Id)
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ModelState.IsValid)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_context.Update(section);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
catch (DbUpdateConcurrencyException)
|
||||||
|
{
|
||||||
|
if (!SectionExists(section.Id))
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return RedirectToAction(nameof(Index), "Home", new { categoryId = section.CategoryId });
|
||||||
|
}
|
||||||
|
ViewData["CategoryId"] = new SelectList(_context.Categories, "Id", "Name", section.CategoryId);
|
||||||
|
return View(section);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private bool SectionExists(int id)
|
||||||
|
{
|
||||||
|
return _context.Sections.Any(e => e.Id == id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
13
MultipleChoiceTrainer/Models/AbstractEditViewModel.cs
Normal file
13
MultipleChoiceTrainer/Models/AbstractEditViewModel.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||||
|
|
||||||
|
namespace MultipleChoiceTrainer.Models
|
||||||
|
{
|
||||||
|
public class AbstractEditViewModel<T>
|
||||||
|
where T: new()
|
||||||
|
{
|
||||||
|
public T Entity { get; set; }
|
||||||
|
public int? PreviousCategoryId { get; set; }
|
||||||
|
|
||||||
|
public SelectList Assignables { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
12
MultipleChoiceTrainer/Models/CategoryEditViewModel.cs
Normal file
12
MultipleChoiceTrainer/Models/CategoryEditViewModel.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
using MultipleChoiceTrainer.Models.DataModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MultipleChoiceTrainer.Models
|
||||||
|
{
|
||||||
|
public class CategoryEditViewModel: AbstractEditViewModel<Category>
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,8 +15,9 @@ namespace MultipleChoiceTrainer.Models.DataModels
|
|||||||
[Display(Name = "Beschreibung")]
|
[Display(Name = "Beschreibung")]
|
||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
|
|
||||||
|
[Display(Name = "Kurs")]
|
||||||
public Category Category { get; set; }
|
public Category Category { get; set; }
|
||||||
|
[Display(Name = "Kurs")]
|
||||||
public int CategoryId { get; set; }
|
public int CategoryId { get; set; }
|
||||||
|
|
||||||
public ICollection<Question> Questions { get; set; } = new HashSet<Question>();
|
public ICollection<Question> Questions { get; set; } = new HashSet<Question>();
|
||||||
|
|||||||
14
MultipleChoiceTrainer/Models/HomeViewModel.cs
Normal file
14
MultipleChoiceTrainer/Models/HomeViewModel.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
using MultipleChoiceTrainer.Models.DataModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MultipleChoiceTrainer.Models
|
||||||
|
{
|
||||||
|
public class HomeViewModel
|
||||||
|
{
|
||||||
|
public IList<Category> Categories { get; set; }
|
||||||
|
public int SelectedCategoryId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
12
MultipleChoiceTrainer/Models/SectionEditViewModel.cs
Normal file
12
MultipleChoiceTrainer/Models/SectionEditViewModel.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
using MultipleChoiceTrainer.Models.DataModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MultipleChoiceTrainer.Models
|
||||||
|
{
|
||||||
|
public class SectionEditViewModel: AbstractEditViewModel<Section>
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
@model MultipleChoiceTrainer.Models.DataModels.Category
|
@model MultipleChoiceTrainer.Models.CategoryEditViewModel
|
||||||
|
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "Neuer Kurs";
|
ViewData["Title"] = "Neuer Kurs";
|
||||||
@@ -10,14 +10,14 @@
|
|||||||
<form asp-action="Create">
|
<form asp-action="Create">
|
||||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label asp-for="Name" class="control-label"></label>
|
<label asp-for="Entity.Name" class="control-label"></label>
|
||||||
<input asp-for="Name" class="form-control" />
|
<input asp-for="Entity.Name" class="form-control" />
|
||||||
<span asp-validation-for="Name" class="text-danger"></span>
|
<span asp-validation-for="Entity.Name" class="text-danger"></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label asp-for="Description" class="control-label"></label>
|
<label asp-for="Entity.Description" class="control-label"></label>
|
||||||
<input asp-for="Description" class="form-control" />
|
<input asp-for="Entity.Description" class="form-control" />
|
||||||
<span asp-validation-for="Description" class="text-danger"></span>
|
<span asp-validation-for="Entity.Description" class="text-danger"></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<button type="submit" class="btn btn-outline-primary"><i class="fas fa-save"></i> Speichern</button>
|
<button type="submit" class="btn btn-outline-primary"><i class="fas fa-save"></i> Speichern</button>
|
||||||
|
|||||||
@@ -1,25 +1,25 @@
|
|||||||
@model MultipleChoiceTrainer.Models.DataModels.Category
|
@model MultipleChoiceTrainer.Models.CategoryEditViewModel
|
||||||
|
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "Kurs bearbeiten";
|
ViewData["Title"] = "Kurs bearbeiten";
|
||||||
}
|
}
|
||||||
|
|
||||||
<h4>Kurs bearbeiten</h4>
|
<h4>Kurs bearbeiten</h4>
|
||||||
<hr />
|
<hr />
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<form asp-action="Edit">
|
<form asp-action="Edit">
|
||||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||||
<input type="hidden" asp-for="Id" />
|
<input type="hidden" asp-for="Entity.Id" />
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label asp-for="Name" class="control-label"></label>
|
<label asp-for="Entity.Name" class="control-label"></label>
|
||||||
<input asp-for="Name" class="form-control" />
|
<input asp-for="Entity.Name" class="form-control" />
|
||||||
<span asp-validation-for="Name" class="text-danger"></span>
|
<span asp-validation-for="Entity.Name" class="text-danger"></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label asp-for="Description" class="control-label"></label>
|
<label asp-for="Entity.Description" class="control-label"></label>
|
||||||
<input asp-for="Description" class="form-control" />
|
<input asp-for="Entity.Description" class="form-control" />
|
||||||
<span asp-validation-for="Description" class="text-danger"></span>
|
<span asp-validation-for="Entity.Description" class="text-danger"></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<button type="submit" class="btn btn-outline-primary"><i class="fas fa-save"></i> Speichern</button>
|
<button type="submit" class="btn btn-outline-primary"><i class="fas fa-save"></i> Speichern</button>
|
||||||
|
|||||||
@@ -1,20 +1,47 @@
|
|||||||
@model IList<MultipleChoiceTrainer.Models.DataModels.Category>
|
@model MultipleChoiceTrainer.Models.HomeViewModel
|
||||||
<p class="text-right"><a href="@Url.Action("Create", "Categories")" class="btn btn-link"><i class="fal fa-plus"></i> Kurs hinzufügen</a></p>
|
<h2>Kursübersicht</h2>
|
||||||
<table class="table">
|
<div class="row">
|
||||||
@foreach (var category in Model)
|
<div class="col-12 col-md-3">
|
||||||
|
<div class="nav flex-column nav-pills" id="v-pills-tab" role="tablist" aria-orientation="vertical">
|
||||||
|
@foreach (var category in Model.Categories)
|
||||||
{
|
{
|
||||||
<tr class="table-primary">
|
<a class="nav-link @if(category.Id == Model.SelectedCategoryId) { <text>active</text>}" id="v-pills-@category.Id-tab" data-toggle="pill" href="#v-pills-@category.Id" role="tab" aria-controls="v-pills-@category.Id" @if (category.Id == Model.SelectedCategoryId) { <text> aria-selected="true" </text> }>@category.Name</a>
|
||||||
<td>
|
}
|
||||||
<span class="badge badge-light"><a asp-action="edit" asp-controller="Categories" asp-route-id="@category.Id"><i class="far fa-file-edit"></i></a></span>
|
<a href="@Url.Action("Create", "Categories")" class="nav-link"><i class="fal fa-plus"></i> Kurs hinzufügen</a>
|
||||||
@category.Name<small class="text-muted"> @category.Description</small>
|
</div>
|
||||||
</td>
|
</div>
|
||||||
</tr>
|
<div class="col-9">
|
||||||
|
<div class="tab-content" id="v-pills-tabContent">
|
||||||
|
@foreach (var category in Model.Categories)
|
||||||
|
{
|
||||||
|
<div class="tab-pane fade @if(category.Id == Model.SelectedCategoryId) { <text>show active</text>}" id="v-pills-@category.Id" role="tabpanel" aria-labelledby="v-pills-@category.Id-tab">
|
||||||
|
<h3>@category.Name <small class="text-muted">@category.Description</small></h3>
|
||||||
|
|
||||||
|
<p class="text-black-50">
|
||||||
|
<a asp-action="edit" asp-controller="Categories" asp-route-id="@category.Id" class="text-black-50"><i class="far fa-edit"></i> Kurs bearbeiten</a>
|
||||||
|
<a asp-action="create" asp-controller="Sections" asp-route-categoryId="@category.Id" class="text-black-50"><i class="far fa-plus"></i> Lektion hinzufügen</a>
|
||||||
|
<a asp-action="create" asp-controller="Sections" asp-route-categoryId="@category.Id" class="text-black-50"><i class="far fa-map-marker-question"></i> Quiz starten</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="list-group">
|
||||||
@foreach (var sub in category.Sections)
|
@foreach (var sub in category.Sections)
|
||||||
{
|
{
|
||||||
<tr><td title="@sub.Description">@sub.Name</td></tr>
|
<ul class="list-group-item list-group-item-action">
|
||||||
|
<div class="d-flex w-100 justify-content-between">
|
||||||
|
<h5 class="mb-1">@sub.Name <small class="text-muted">@sub.Description</small></h5>
|
||||||
|
<small>@sub.Questions.Count() Fragen</small>
|
||||||
|
</div>
|
||||||
|
<p class="text-black-50">
|
||||||
|
<a asp-action="edit" asp-controller="Sections" asp-route-id="@sub.Id" class="text-black-50"><i class="far fa-edit"></i> Lektion bearbeiten</a>
|
||||||
|
<a asp-action="create" asp-controller="Sections" asp-route-categoryId="@category.Id" class="text-black-50"><i class="far fa-plus"></i> Frage hinzufügen</a>
|
||||||
|
<a asp-action="create" asp-controller="Sections" asp-route-categoryId="@category.Id" class="text-black-50"><i class="far fa-map-marker-question"></i> Quiz starten</a>
|
||||||
|
</p>
|
||||||
|
</ul>
|
||||||
}
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
<tr class="table-primary"><td>Hundetrainer</td></tr>
|
</div>
|
||||||
<tr><td>Lektion 1 - Der Hund</td></tr>
|
</div>
|
||||||
<tr><td>Lektion 2 - Der Schwanz</td></tr>
|
</div>
|
||||||
</table>
|
|
||||||
37
MultipleChoiceTrainer/Views/Sections/Create.cshtml
Normal file
37
MultipleChoiceTrainer/Views/Sections/Create.cshtml
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
@model MultipleChoiceTrainer.Models.DataModels.Section
|
||||||
|
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "Lektion anlegen";
|
||||||
|
}
|
||||||
|
|
||||||
|
<h4>Lektion anlegen</h4>
|
||||||
|
<hr />
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<form asp-action="Create">
|
||||||
|
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label asp-for="Name" class="control-label"></label>
|
||||||
|
<input asp-for="Name" class="form-control" />
|
||||||
|
<span asp-validation-for="Name" class="text-danger"></span>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label asp-for="Description" class="control-label"></label>
|
||||||
|
<input asp-for="Description" class="form-control" />
|
||||||
|
<span asp-validation-for="Description" class="text-danger"></span>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label asp-for="Category" class="control-label"></label>
|
||||||
|
<select asp-for="CategoryId" class="form-control" asp-items="ViewBag.CategoryId"></select>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<button type="submit" class="btn btn-outline-primary"><i class="fas fa-save"></i> Speichern</button>
|
||||||
|
<a asp-action="Index" asp-controller="Home" class="btn btn-outline-danger"><i class="fas fa-times"></i> Abbrechen</a>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@section Scripts {
|
||||||
|
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
|
||||||
|
}
|
||||||
39
MultipleChoiceTrainer/Views/Sections/Edit.cshtml
Normal file
39
MultipleChoiceTrainer/Views/Sections/Edit.cshtml
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
@model MultipleChoiceTrainer.Models.DataModels.Section
|
||||||
|
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "Lektion bearbeiten";
|
||||||
|
}
|
||||||
|
|
||||||
|
<h4>Lektion bearbeiten</h4>
|
||||||
|
<hr />
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<form asp-action="Edit">
|
||||||
|
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||||
|
<input type="hidden" asp-for="Id" />
|
||||||
|
<div class="form-group">
|
||||||
|
<label asp-for="Name" class="control-label"></label>
|
||||||
|
<input asp-for="Name" class="form-control" />
|
||||||
|
<span asp-validation-for="Name" class="text-danger"></span>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label asp-for="Description" class="control-label"></label>
|
||||||
|
<input asp-for="Description" class="form-control" />
|
||||||
|
<span asp-validation-for="Description" class="text-danger"></span>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label asp-for="Category" class="control-label"></label>
|
||||||
|
<select asp-for="CategoryId" class="form-control" asp-items="ViewBag.CategoryId"></select>
|
||||||
|
<span asp-validation-for="CategoryId" class="text-danger"></span>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<button type="submit" class="btn btn-outline-primary"><i class="fas fa-save"></i> Speichern</button>
|
||||||
|
<a asp-action="Index" asp-controller="Home" class="btn btn-outline-danger"><i class="fas fa-times"></i> Abbrechen</a>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@section Scripts {
|
||||||
|
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user