Update 07082021

This commit is contained in:
2021-08-07 09:44:37 +02:00
parent 1ff218a129
commit 4d443fdfd4
5663 changed files with 6581858 additions and 1321 deletions

View File

@@ -1,47 +1,117 @@
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 BerufController
public class BerufController : ControllerBase
{
public static List<Beruf> GetAllData()
{
Helper.HttpClientHelper httpcli = new Helper.HttpClientHelper();
httpcli.CallService("Beruf", "", "GET", null);
return JsonConvert.DeserializeObject<List<Beruf>>(httpcli.Results.daten);
dbhelper dbh = new dbhelper();
dbh.Get_Tabledata("Select * from Beruf", false, true);
return dbh.ConvertDataTable<Beruf>(dbh.dsdaten.Tables[0]);
}
public static void savedata(Beruf Berufdata)
public static List<Beruf> GetAllAktiveData()
{
Helper.HttpClientHelper httpcli = new Helper.HttpClientHelper();
httpcli.CallService("Beruf", Berufdata.ID.ToString(), "PUT", Berufdata);
dbhelper dbh = new dbhelper();
dbh.Get_Tabledata("Select * from Beruf where aktiv=1 order by bezeichnung", false, true);
return dbh.ConvertDataTable<Beruf>(dbh.dsdaten.Tables[0]);
}
public static int InsertData(Beruf Berufdata)
public static List<Beruf> GetByID(int ID)
{
Helper.HttpClientHelper httpcli = new Helper.HttpClientHelper();
httpcli.CallService("Beruf", "", "POST", Berufdata);
List<BWPMModels.Beruf> LastBeruf = new List<Beruf>();
LastBeruf = GetLast(Berufdata);
return LastBeruf.First<Beruf>().ID;
dbhelper dbh = new dbhelper();
dbh.Get_Tabledata("Select * from Beruf where id=" + ID.ToString(), false, true);
return dbh.ConvertDataTable<Beruf>(dbh.dsdaten.Tables[0]);
}
public static List<Beruf> GetLast(Beruf Berufdata)
public static List<Beruf> GetLast()
{
Helper.HttpClientHelper httpcli = new Helper.HttpClientHelper();
string sql = "Select top 1 * from Beruf where mutierer='" + Berufdata.mutierer + "' order by erstellt_am desc";
httpcli.CallService("Beruf", "usersql/" + sql, "GET", Berufdata);
return JsonConvert.DeserializeObject<List<Beruf>>(httpcli.Results.daten);
dbhelper dbh = new dbhelper();
dbh.Get_Tabledata("Select top 1 * from Beruf order by mutiert_am desc", false, true);
return dbh.ConvertDataTable<Beruf>(dbh.dsdaten.Tables[0]);
}
public static List<Beruf> GetLastByMutierer(string Mutierer)
{
dbhelper dbh = new dbhelper();
dbh.Get_Tabledata("Select top 1 * from Beruf where mutierer='" + Mutierer + "' order by mutiert_am desc", false, true);
return dbh.ConvertDataTable<Beruf>(dbh.dsdaten.Tables[0]);
}
public static List<Beruf> GetbyUserSQL(string SQL)
{
dbhelper dbh = new dbhelper();
dbh.Get_Tabledata(SQL, false, true);
return dbh.ConvertDataTable<Beruf>(dbh.dsdaten.Tables[0]);
}
public static int POST(Beruf Berufdata)
{
dbhelper dbh = new dbhelper();
dbh.Get_Tabeldata_for_Update("Select top 1 * from [Beruf] where id=-1", false, true);
DataRow dr = dbh.dsdaten.Tables[0].NewRow();
Berufdata.GetType().GetProperties().ToList().ForEach(f =>
{
try
{
if (f.PropertyType == typeof(DateTime))
{
dr[f.Name] = (DateTime)f.GetValue(Berufdata, null);
}
else
{
dr[f.Name] = f.GetValue(Berufdata, null);
}
}
catch (Exception ex) { string s = ex.Message; }
});
dbh.dsdaten.Tables[0].Rows.Add(dr);
dbh.Update_Tabeldata();
List<Beruf> tmplst = GetLastByMutierer(Berufdata.mutierer);
return tmplst.First<Beruf>().ID;
}
public static void PUT(Beruf Berufdata)
{
dbhelper dbh = new dbhelper();
dbh.Get_Tabeldata_for_Update("Select top 1 * from [Beruf] where id=" + Berufdata.ID.ToString(), false, true);
DataRow dr = dbh.dsdaten.Tables[0].Rows[0];
Berufdata.GetType().GetProperties().ToList().ForEach(f =>
{
try
{
if (f.PropertyType == typeof(DateTime))
{
dr[f.Name] = (DateTime)f.GetValue(Berufdata, null);
}
else
{
dr[f.Name] = f.GetValue(Berufdata, null);
}
}
catch (Exception ex) { string s = ex.Message; }
});
dbh.Update_Tabeldata();
}
public static void DELETE(Beruf Berufdata)
{
dbhelper dbh = new dbhelper();
dbh.Get_Tabeldata_for_Update("delete from [Beruf] where id=" + Berufdata.ID.ToString(), false, true);
}
}
}
}