Update nach User-Passwort-Change
This commit is contained in:
106
CoreWebAPI1/Controllers/AspNetRoles.cs
Normal file
106
CoreWebAPI1/Controllers/AspNetRoles.cs
Normal file
@@ -0,0 +1,106 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using CoreWebAPI1.Models;
|
||||
using BWPMModels;
|
||||
using System.Data;
|
||||
using SecuringWebApiUsingApiKey.Attributes;
|
||||
|
||||
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||
|
||||
namespace CoreWebAPI1.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
|
||||
public class AspNetRolesController : ControllerBase
|
||||
{
|
||||
// GET: api/<AspNetRolesController>
|
||||
[HttpGet]
|
||||
public List<AspNetRoles> Get()
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
//dbh.Get_Tabledata("Select * from [AspNetRoles]", false, true);
|
||||
|
||||
List<BWPMModels.AspNetRoles> Details = new List<BWPMModels.AspNetRoles>();
|
||||
return dbh.ConvertDataTable<BWPMModels.AspNetRoles>(dbh.Get_Tabledata("Select * from [AspNetRoles]", false, true));
|
||||
}
|
||||
|
||||
|
||||
// GET api/<AspNetRolesController>/5
|
||||
[HttpGet("{id}")]
|
||||
public List<AspNetRoles> Get(int id)
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
List<AspNetRoles> Details = new List<AspNetRoles>();
|
||||
return dbh.ConvertDataTable<AspNetRoles>(dbh.Get_Tabledata("Select * from [AspNetRoles] where id=" + id.ToString(), false, true));
|
||||
}
|
||||
|
||||
// POST api/<AspNetRolesController>
|
||||
[HttpPost]
|
||||
public void Post([FromBody] AspNetRoles AspNetRoles)
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabeldata_for_Update("Select top 1 * from [AspNetRoles] where id=-1", false, true);
|
||||
DataRow dr = dbh.dsdaten.Tables[0].NewRow();
|
||||
AspNetRoles.GetType().GetProperties().ToList().ForEach(f =>
|
||||
{
|
||||
try
|
||||
{
|
||||
if (f.PropertyType == typeof(DateTime))
|
||||
{
|
||||
dr[f.Name] = (DateTime)f.GetValue(AspNetRoles, null);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
dr[f.Name] = f.GetValue(AspNetRoles, null);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) { string s = ex.Message; }
|
||||
});
|
||||
dbh.dsdaten.Tables[0].Rows.Add(dr);
|
||||
dbh.Update_Tabeldata();
|
||||
}
|
||||
|
||||
// PUT api/<AspNetRolesController>/5
|
||||
[HttpPut("{id}")]
|
||||
public void Put(int id, [FromBody] AspNetRoles AspNetRoles)
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabeldata_for_Update("Select top 1 * from [AspNetRoles] where id=" + id.ToString(), false, true);
|
||||
DataRow dr = dbh.dsdaten.Tables[0].Rows[0];
|
||||
AspNetRoles.GetType().GetProperties().ToList().ForEach(f =>
|
||||
{
|
||||
try
|
||||
{
|
||||
if (f.PropertyType == typeof(DateTime))
|
||||
{
|
||||
dr[f.Name] = (DateTime)f.GetValue(AspNetRoles, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
dr[f.Name] = f.GetValue(AspNetRoles, null);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) { string s = ex.Message; }
|
||||
});
|
||||
dbh.Update_Tabeldata();
|
||||
|
||||
}
|
||||
|
||||
// DELETE api/<AspNetRolesController>/5
|
||||
[HttpDelete("{id}")]
|
||||
public void Delete(int id)
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabeldata_for_Update("Select top 1 * from [AspNetRoles] where id=" + id, false, true);
|
||||
DataRow dr = dbh.dsdaten.Tables[0].Rows[0];
|
||||
dr["Aktiv"] = false;
|
||||
dr["mutiert_am"] = DateTime.Now;
|
||||
dbh.Update_Tabeldata();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user