public DBRole AddRole(long user_id, int job, string name) { var role = new DBRole(); role.user_id = user_id; role.job_type = job; role.name = name; role.level = 1; Con.Insert(role); return(role); }
public DBRole Put([FromBody] UpdateRole updateRole) { DotNetEnv.Env.Load(); postgreUnitOfWork db = new postgreUnitOfWork(System.Environment.GetEnvironmentVariable("CONN_STR")); DBRole newRole = new DBRole(updateRole.id, updateRole.name, DateTime.Now, DateTime.Now); DBRole updated = db.RoleRepo.UpdateRole(newRole); db.Commit(); return(updated); }
public List <DBRole> GetAllRoles() { string query = "SELECT roleId, roleName, created_at FROM \"role\""; List <DBRole> fetched = new List <DBRole>(); using (var cmd = new NpgsqlCommand(query, _connection, _transaction)) { using (NpgsqlDataReader reader = cmd.ExecuteReader()) { if (reader.Read()) { DBRole _role = new DBRole(reader.GetInt32(0), reader.GetString(1), reader.GetDateTime(2)); fetched.Add(_role); } } return(fetched); } }