Update 07082021
This commit is contained in:
118
BlazorApp/Controller/Klasse/KlasseController.cs
Normal file
118
BlazorApp/Controller/Klasse/KlasseController.cs
Normal file
@@ -0,0 +1,118 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using BWPMModels;
|
||||
using BlazorApp.Helper;
|
||||
using Newtonsoft.Json;
|
||||
using System.Data;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BlazorApp.Controller
|
||||
|
||||
{
|
||||
|
||||
public class KlasseController : ControllerBase
|
||||
{
|
||||
public static List<Klasse> GetAllData()
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabledata("Select * from Klasse", false, true);
|
||||
return dbh.ConvertDataTable<Klasse>(dbh.dsdaten.Tables[0]);
|
||||
}
|
||||
|
||||
public static List<Klasse> GetByID(int ID)
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabledata("Select * from Klasse where id=" + ID.ToString(), false, true);
|
||||
return dbh.ConvertDataTable<Klasse>(dbh.dsdaten.Tables[0]);
|
||||
}
|
||||
|
||||
public static List<Klasse> GetByLehrerID(int ID)
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabledata("Select * from Klasse where lehrerid=" + ID.ToString(), false, true);
|
||||
return dbh.ConvertDataTable<Klasse>(dbh.dsdaten.Tables[0]);
|
||||
}
|
||||
|
||||
|
||||
public static List<Klasse> GetLast()
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabledata("Select top 1 * from Klasse order by mutiert_am desc", false, true);
|
||||
return dbh.ConvertDataTable<Klasse>(dbh.dsdaten.Tables[0]);
|
||||
}
|
||||
public static List<Klasse> GetLastByMutierer(string Mutierer)
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabledata("Select top 1 * from Klasse where mutierer='" + Mutierer + "' order by mutiert_am desc", false, true);
|
||||
return dbh.ConvertDataTable<Klasse>(dbh.dsdaten.Tables[0]);
|
||||
}
|
||||
|
||||
public static List<Klasse> GetbyUserSQL(string SQL)
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabledata(SQL, false, true);
|
||||
return dbh.ConvertDataTable<Klasse>(dbh.dsdaten.Tables[0]);
|
||||
}
|
||||
|
||||
public static int POST(Klasse Klassedata)
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabeldata_for_Update("Select top 1 * from [Klasse] where id=-1", false, true);
|
||||
DataRow dr = dbh.dsdaten.Tables[0].NewRow();
|
||||
Klassedata.GetType().GetProperties().ToList().ForEach(f =>
|
||||
{
|
||||
try
|
||||
{
|
||||
if (f.PropertyType == typeof(DateTime))
|
||||
{
|
||||
dr[f.Name] = (DateTime)f.GetValue(Klassedata, null);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
dr[f.Name] = f.GetValue(Klassedata, null);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) { string s = ex.Message; }
|
||||
});
|
||||
dbh.dsdaten.Tables[0].Rows.Add(dr);
|
||||
dbh.Update_Tabeldata();
|
||||
List<Klasse> tmplst = GetLastByMutierer(Klassedata.mutierer);
|
||||
return tmplst.First<Klasse>().ID;
|
||||
}
|
||||
|
||||
public static void PUT(Klasse Klassedata)
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabeldata_for_Update("Select top 1 * from [Klasse] where id=" + Klassedata.ID.ToString(), false, true);
|
||||
DataRow dr = dbh.dsdaten.Tables[0].Rows[0];
|
||||
Klassedata.GetType().GetProperties().ToList().ForEach(f =>
|
||||
{
|
||||
try
|
||||
{
|
||||
if (f.PropertyType == typeof(DateTime))
|
||||
{
|
||||
dr[f.Name] = (DateTime)f.GetValue(Klassedata, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
dr[f.Name] = f.GetValue(Klassedata, null);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) { string s = ex.Message; }
|
||||
});
|
||||
dbh.Update_Tabeldata();
|
||||
|
||||
}
|
||||
|
||||
public static void DELETE(Klasse Klassedata)
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabeldata_for_Update("delete from [Klasse] where id=" + Klassedata.ID.ToString(), false, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user