some bugs
This commit is contained in:
		
							parent
							
								
									0b0f1f59fa
								
							
						
					
					
						commit
						093e0881ee
					
				@ -249,21 +249,22 @@ else{
 | 
				
			|||||||
        [Authorize]
 | 
					        [Authorize]
 | 
				
			||||||
        public async Task<ActionResult<post_user_v2>> getalladmin_v2(string? keyword, short pageindex = 1, short pagesize = 10)
 | 
					        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();
 | 
					                var a = new all_record();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (keyword == null)
 | 
					                if (keyword == null)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    a.cout = userManager.Users.Count();
 | 
					                    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
 | 
					                else
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    a.cout = userManager.Users.Where(a => a.chinaname == keyword || a.UserName == keyword || a.Email == keyword).Count();
 | 
					                    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);
 | 
					                return Ok(a);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
				
			|||||||
@ -140,7 +140,11 @@ namespace asg_form.Controllers
 | 
				
			|||||||
            {
 | 
					            {
 | 
				
			||||||
                using (TestDbContext ctx = new TestDbContext())
 | 
					                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.msg=req_News.msg;
 | 
				
			||||||
                    qwq.Title=req_News.Title;
 | 
					                    qwq.Title=req_News.Title;
 | 
				
			||||||
                    qwq.FormName = user.UserName;
 | 
					                    qwq.FormName = user.UserName;
 | 
				
			||||||
 | 
				
			|||||||
@ -22,6 +22,8 @@ namespace asg_form
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        public int point {  get; set; }
 | 
					        public int point {  get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public bool isadmin { get; set; }
 | 
				
			||||||
 | 
					        public List<string>? Roles { get; set; }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public class Role : IdentityRole<long>
 | 
					    public class Role : IdentityRole<long>
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user