some bugs
This commit is contained in:
parent
0b0f1f59fa
commit
093e0881ee
@ -249,21 +249,22 @@ else{
|
||||
[Authorize]
|
||||
public async Task<ActionResult<post_user_v2>> getalladmin_v2(string? keyword, short pageindex = 1, short pagesize = 10)
|
||||
{
|
||||
if (this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin"))
|
||||
bool isAdmin = this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin");
|
||||
if (isAdmin)
|
||||
{
|
||||
var a = new all_record();
|
||||
|
||||
if (keyword == null)
|
||||
{
|
||||
a.cout = userManager.Users.Count();
|
||||
a.msg = await userManager.Users.Paginate(pageindex, pagesize).Select(a => new { a.Id, a.Email, a.chinaname, a.UserName, a.Integral, a.officium }).ToListAsync();
|
||||
|
||||
a.msg = await userManager.Users.Paginate(pageindex, pagesize).Select(a => new { a.Id, a.Email, a.chinaname, a.UserName, a.Integral, a.officium,a.isadmin ,a.Roles}).ToListAsync();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
a.cout = userManager.Users.Where(a => a.chinaname == keyword || a.UserName == keyword || a.Email == keyword).Count();
|
||||
a.msg = await userManager.Users.Where(a => a.chinaname == keyword || a.UserName == keyword || a.Email == keyword).Paginate(pageindex, pagesize).Select(a => new { a.Id, a.Email, a.chinaname, a.UserName, a.Integral, a.officium }).ToListAsync();
|
||||
a.msg = await userManager.Users.Where(a => a.chinaname == keyword || a.UserName == keyword || a.Email == keyword).Paginate(pageindex, pagesize).Select(a => new { a.Id, a.Email, a.chinaname, a.UserName, a.Integral, a.officium, a.isadmin, a.Roles }).ToListAsync();
|
||||
}
|
||||
return Ok(a);
|
||||
}
|
||||
|
@ -140,7 +140,11 @@ namespace asg_form.Controllers
|
||||
{
|
||||
using (TestDbContext ctx = new TestDbContext())
|
||||
{
|
||||
var qwq= await ctx.news.FindAsync(newsid);
|
||||
var qwq= await ctx.news.Where(n => n.Id == newsid && n.Type == req_News.Type).FindAsync(newsid);
|
||||
if (qwq == null)
|
||||
{
|
||||
return NotFound("News item not found or type mismatch.");
|
||||
}
|
||||
qwq.msg=req_News.msg;
|
||||
qwq.Title=req_News.Title;
|
||||
qwq.FormName = user.UserName;
|
||||
|
@ -21,7 +21,9 @@ namespace asg_form
|
||||
public string? officium { get; set; }
|
||||
|
||||
public int point { get; set; }
|
||||
|
||||
|
||||
public bool isadmin { get; set; }
|
||||
public List<string>? Roles { get; set; }
|
||||
}
|
||||
|
||||
public class Role : IdentityRole<long>
|
||||
|
Loading…
x
Reference in New Issue
Block a user