Update 07082021
This commit is contained in:
110
BlazorApp/Controller/Optionen/OptionenController.cs
Normal file
110
BlazorApp/Controller/Optionen/OptionenController.cs
Normal file
@@ -0,0 +1,110 @@
|
||||
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 OptionenController : ControllerBase
|
||||
{
|
||||
public static List<Optionen> GetAllData()
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabledata("Select * from Optionen", false, true);
|
||||
return dbh.ConvertDataTable<Optionen>(dbh.dsdaten.Tables[0]);
|
||||
}
|
||||
|
||||
public static List<Optionen> GetByID(int ID)
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabledata("Select * from Optionen where id=" + ID.ToString(), false, true);
|
||||
return dbh.ConvertDataTable<Optionen>(dbh.dsdaten.Tables[0]);
|
||||
}
|
||||
|
||||
public static List<Optionen> GetLast()
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabledata("Select top 1 * from Optionen order by mutiert_am desc", false, true);
|
||||
return dbh.ConvertDataTable<Optionen>(dbh.dsdaten.Tables[0]);
|
||||
}
|
||||
public static List<Optionen> GetLastByMutierer(string Mutierer)
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabledata("Select top 1 * from Optionen where mutierer='" + Mutierer + "' order by mutiert_am desc", false, true);
|
||||
return dbh.ConvertDataTable<Optionen>(dbh.dsdaten.Tables[0]);
|
||||
}
|
||||
|
||||
public static List<Optionen> GetbyUserSQL(string SQL)
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabledata(SQL, false, true);
|
||||
return dbh.ConvertDataTable<Optionen>(dbh.dsdaten.Tables[0]);
|
||||
}
|
||||
|
||||
public static int POST(Optionen Optionendata)
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabeldata_for_Update("Select top 1 * from [Optionen] where id=-1", false, true);
|
||||
DataRow dr = dbh.dsdaten.Tables[0].NewRow();
|
||||
Optionendata.GetType().GetProperties().ToList().ForEach(f =>
|
||||
{
|
||||
try
|
||||
{
|
||||
if (f.PropertyType == typeof(DateTime))
|
||||
{
|
||||
dr[f.Name] = (DateTime)f.GetValue(Optionendata, null);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
dr[f.Name] = f.GetValue(Optionendata, null);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) { string s = ex.Message; }
|
||||
});
|
||||
dbh.dsdaten.Tables[0].Rows.Add(dr);
|
||||
dbh.Update_Tabeldata();
|
||||
List<Optionen> tmplst = GetLastByMutierer(Optionendata.mutierer);
|
||||
return tmplst.First<Optionen>().ID;
|
||||
}
|
||||
|
||||
public static void PUT(Optionen Optionendata)
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabeldata_for_Update("Select top 1 * from [Optionen] where id=" + Optionendata.ID.ToString(), false, true);
|
||||
DataRow dr = dbh.dsdaten.Tables[0].Rows[0];
|
||||
Optionendata.GetType().GetProperties().ToList().ForEach(f =>
|
||||
{
|
||||
try
|
||||
{
|
||||
if (f.PropertyType == typeof(DateTime))
|
||||
{
|
||||
dr[f.Name] = (DateTime)f.GetValue(Optionendata, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
dr[f.Name] = f.GetValue(Optionendata, null);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) { string s = ex.Message; }
|
||||
});
|
||||
dbh.Update_Tabeldata();
|
||||
|
||||
}
|
||||
|
||||
public static void DELETE(Optionen Optionendata)
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabeldata_for_Update("delete from [Optionen] where id=" + Optionendata.ID.ToString(), false, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user