Initial import from local backup (Documents-Playground/pakerpale)
This commit is contained in:
17
Models/User.cs
Normal file
17
Models/User.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Auth.api.Models
|
||||
{
|
||||
public class User
|
||||
{
|
||||
public int userID { get; set; }
|
||||
|
||||
public string userName { get; set; }
|
||||
|
||||
public string name { get; set; }
|
||||
|
||||
public string email { get; set; }
|
||||
|
||||
public string password { get; set; }
|
||||
}
|
||||
}
|
||||
79
Models/UserContext.cs
Normal file
79
Models/UserContext.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
using MySql.Data.MySqlClient;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Auth.api.Models
|
||||
{
|
||||
public class UserContext
|
||||
{
|
||||
public string ConnectionString { get; set; }
|
||||
|
||||
public UserContext(string connectionString)
|
||||
{
|
||||
this.ConnectionString = connectionString;
|
||||
}
|
||||
|
||||
// private MySqlConnection GetConnection()
|
||||
// {
|
||||
// return new MySqlConnection(ConnectionString);
|
||||
// }
|
||||
|
||||
public List<User> GetAllUsers()
|
||||
{
|
||||
List<User> list = new List<User>();
|
||||
|
||||
// using (MySqlConnection conn = GetConnection())
|
||||
// {
|
||||
// conn.Open();
|
||||
// MySqlCommand cmd = new MySqlCommand("select * from cm_user where 1 limit 10", conn);
|
||||
|
||||
// using (var reader = cmd.ExecuteReader())
|
||||
// {
|
||||
// while (reader.Read())
|
||||
// {
|
||||
// list.Add(new User()
|
||||
// {
|
||||
// userID = Convert.ToInt32(reader["userID"]),
|
||||
// userName = reader["userName"].ToString(),
|
||||
// name = reader["name"].ToString(),
|
||||
// email = reader["email"].ToString(),
|
||||
// password = reader["password"].ToString()
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<User> GetUserByUserId()
|
||||
{
|
||||
List<User> list = new List<User>();
|
||||
|
||||
// using (MySqlConnection conn = GetConnection())
|
||||
// {
|
||||
// conn.Open();
|
||||
// MySqlCommand cmd = new MySqlCommand("select * from cm_user where t 10", conn);
|
||||
|
||||
// using (var reader = cmd.ExecuteReader())
|
||||
// {
|
||||
// while (reader.Read())
|
||||
// {
|
||||
// list.Add(new User()
|
||||
// {
|
||||
// userID = Convert.ToInt32(reader["userID"]),
|
||||
// userName = reader["userName"].ToString(),
|
||||
// name = reader["name"].ToString(),
|
||||
// email = reader["email"].ToString(),
|
||||
// password = reader["password"].ToString()
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user