You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
126 lines
4.6 KiB
126 lines
4.6 KiB
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 AspNetUserRolleController : ControllerBase
|
|
{
|
|
// GET: api/<AspNetUserRolleController>
|
|
[HttpGet]
|
|
|
|
public List<AspNetUserRolle> Get()
|
|
{
|
|
dbhelper dbh = new dbhelper();
|
|
//dbh.Get_Tabledata("Select * from [AspNetUserRolle]", false, true);
|
|
|
|
List<BWPMModels.AspNetUserRolle> Details = new List<BWPMModels.AspNetUserRolle>();
|
|
return dbh.ConvertDataTable<BWPMModels.AspNetUserRolle>(dbh.Get_Tabledata("Select * from [AspNetUserRolle]", false, true));
|
|
}
|
|
[HttpGet]
|
|
[Route("usersql/{sql}")]
|
|
public List<AspNetUserRolle> GetLast(string sql)
|
|
{
|
|
dbhelper dbh = new dbhelper();
|
|
List<BWPMModels.AspNetUserRolle> Details = new List<BWPMModels.AspNetUserRolle>();
|
|
return dbh.ConvertDataTable<BWPMModels.AspNetUserRolle>(dbh.Get_Tabledata(sql, false, true));
|
|
}
|
|
|
|
// GET api/<AspNetUserRolleController>/5
|
|
[HttpGet("{id}")]
|
|
public List<AspNetUserRolle> Get(int id)
|
|
{
|
|
dbhelper dbh = new dbhelper();
|
|
List<AspNetUserRolle> Details = new List<AspNetUserRolle>();
|
|
return dbh.ConvertDataTable<AspNetUserRolle>(dbh.Get_Tabledata("Select * from [AspNetUserRolle] where id=" + id.ToString(), false, true));
|
|
}
|
|
|
|
// POST api/<AspNetUserRolleController>
|
|
[HttpPost]
|
|
public void Post([FromBody] AspNetUserRolle AspNetUserRolle)
|
|
{
|
|
dbhelper dbh = new dbhelper();
|
|
dbh.Get_Tabeldata_for_Update("Select top 1 * from [AspNetUserRolle] where id=-1", false, true);
|
|
DataRow dr = dbh.dsdaten.Tables[0].NewRow();
|
|
AspNetUserRolle.GetType().GetProperties().ToList().ForEach(f =>
|
|
{
|
|
try
|
|
{
|
|
if (f.PropertyType == typeof(DateTime))
|
|
{
|
|
dr[f.Name] = (DateTime)f.GetValue(AspNetUserRolle, null);
|
|
|
|
}
|
|
else
|
|
{
|
|
dr[f.Name] = f.GetValue(AspNetUserRolle, null);
|
|
}
|
|
}
|
|
catch (Exception ex) { string s = ex.Message; }
|
|
});
|
|
dbh.dsdaten.Tables[0].Rows.Add(dr);
|
|
dbh.Update_Tabeldata();
|
|
}
|
|
|
|
// PUT api/<AspNetUserRolleController>/5
|
|
[HttpPut("{id}")]
|
|
public void Put(int id, [FromBody] AspNetUserRolle AspNetUserRolle)
|
|
{
|
|
dbhelper dbh = new dbhelper();
|
|
dbh.Get_Tabeldata_for_Update("Select top 1 * from [AspNetUserRolle] where id=" + id.ToString(), false, true);
|
|
DataRow dr = dbh.dsdaten.Tables[0].Rows[0];
|
|
AspNetUserRolle.GetType().GetProperties().ToList().ForEach(f =>
|
|
{
|
|
try
|
|
{
|
|
if (f.PropertyType == typeof(DateTime))
|
|
{
|
|
dr[f.Name] = (DateTime)f.GetValue(AspNetUserRolle, null);
|
|
}
|
|
else
|
|
{
|
|
dr[f.Name] = f.GetValue(AspNetUserRolle, null);
|
|
}
|
|
}
|
|
catch (Exception ex) { string s = ex.Message; }
|
|
});
|
|
dbh.Update_Tabeldata();
|
|
|
|
}
|
|
// PUT api/<AspNetUserRolleController>/5
|
|
[HttpPut]
|
|
[Route("changepassword/{userid}")]
|
|
public void Put(string userid, [FromBody] AspNetUsers Aspnetuser)
|
|
{
|
|
dbhelper dbh = new dbhelper();
|
|
dbh.Get_Tabeldata_for_Update("Select top 1 * from [AspNetUsers] where id='" + userid+"'", false, true);
|
|
DataRow dr = dbh.dsdaten.Tables[0].Rows[0];
|
|
dr["PasswordHash"] = Aspnetuser.PasswordHash;
|
|
dbh.Update_Tabeldata();
|
|
|
|
}
|
|
// DELETE api/<AspNetUserRolleController>/5
|
|
[HttpDelete("{id}")]
|
|
public void Delete(int id)
|
|
{
|
|
dbhelper dbh = new dbhelper();
|
|
dbh.Get_Tabeldata_for_Update("Select top 1 * from [AspNetUserRolle] where id=" + id, false, true);
|
|
DataRow dr = dbh.dsdaten.Tables[0].Rows[0];
|
|
dr["Aktiv"] = false;
|
|
dr["mutiert_am"] = DateTime.Now;
|
|
dbh.Update_Tabeldata();
|
|
}
|
|
}
|
|
}
|