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