feature: add blazor app
This commit is contained in:
9
FahrzeugeMVC/Models/ErrorViewModel.cs
Normal file
9
FahrzeugeMVC/Models/ErrorViewModel.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace FahrzeugeMVC.Models
|
||||
{
|
||||
public class ErrorViewModel
|
||||
{
|
||||
public string? RequestId { get; set; }
|
||||
|
||||
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
|
||||
}
|
||||
}
|
||||
19
FahrzeugeMVC/Models/FahrzeugEinfugenModel.cs
Normal file
19
FahrzeugeMVC/Models/FahrzeugEinfugenModel.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace FahrzeugeMVC.Models;
|
||||
|
||||
public class FahrzeugEinfugenModel
|
||||
{
|
||||
[Required]
|
||||
public string? Name { get; set; }
|
||||
[Required]
|
||||
public string? Type { get; set; }
|
||||
|
||||
public List<SelectListItem> FahrzeugTypen { get; private set; } = new()
|
||||
{
|
||||
new SelectListItem("Auto", "Auto", true),
|
||||
new SelectListItem("Motorrad", "Motorrad"),
|
||||
new SelectListItem("Fahrrad", "Fahrrad")
|
||||
};
|
||||
}
|
||||
42
FahrzeugeMVC/Models/FahrzeugListeModel.cs
Normal file
42
FahrzeugeMVC/Models/FahrzeugListeModel.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using FahrzeugDatenBank;
|
||||
|
||||
namespace FahrzeugeMVC.Models;
|
||||
|
||||
public class FahrzeugListeModel
|
||||
{
|
||||
public FahrzeugListeModel(IEnumerable<FahrzeugDTO> fahrzeugs)
|
||||
{
|
||||
foreach (var fahrzeug in fahrzeugs)
|
||||
{
|
||||
switch (fahrzeug.Typ)
|
||||
{
|
||||
case "Auto":
|
||||
var auto = new Auto()
|
||||
{
|
||||
Id = fahrzeug.Id,
|
||||
Name = fahrzeug.Name,
|
||||
};
|
||||
this.Fahrzeuge.Add(auto);
|
||||
break;
|
||||
case "Motorrad":
|
||||
var motorrad = new Motorrad()
|
||||
{
|
||||
Id = fahrzeug.Id,
|
||||
Name = fahrzeug.Name,
|
||||
};
|
||||
this.Fahrzeuge.Add(motorrad);
|
||||
break;
|
||||
case "Fahrrad":
|
||||
var fahrrad = new Fahrrad()
|
||||
{
|
||||
Id = fahrzeug.Id,
|
||||
Name = fahrzeug.Name,
|
||||
};
|
||||
Fahrzeuge.Add(fahrrad);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<Fahrzeug> Fahrzeuge { get; set; } = new();
|
||||
}
|
||||
Reference in New Issue
Block a user