修复很多bug
This commit is contained in:
		
							parent
							
								
									162c38dadf
								
							
						
					
					
						commit
						00f8d9e796
					
				@ -115,6 +115,9 @@ namespace asg_form.Controllers.Store
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// 
 | 
					        /// 
 | 
				
			||||||
        /// </summary>
 | 
					        /// </summary>
 | 
				
			||||||
@ -138,23 +141,24 @@ namespace asg_form.Controllers.Store
 | 
				
			|||||||
                IQueryable<StoreinfoDB> b;
 | 
					                IQueryable<StoreinfoDB> b;
 | 
				
			||||||
                if (showVerification)
 | 
					                if (showVerification)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                     b = sb.T_Storeinfo;
 | 
					                     b = sb.T_Storeinfo.Include(a=>a.Store);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                else
 | 
					                else
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    b = sb.T_Storeinfo.Where(a=>a.isVerification==false);
 | 
					                    b = sb.T_Storeinfo.Include(a => a.Store).Where(a => a.isVerification == false);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
               if (search_id == null)
 | 
					               if (search_id == null)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    a.cout = b.Count();
 | 
					                    a.cout = b.Count();
 | 
				
			||||||
                    a.msg = await b.Paginate(pageindex, pagesize).ToListAsync();
 | 
					                    a.msg = await b.Paginate(pageindex, pagesize).Select(a => new { a.id, a.buyerid, a.Store.Price, a.Store.description, a.isVerification, a.Store.information, a.Store.Name }).ToListAsync();
 | 
				
			||||||
                 
 | 
					                 
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                else
 | 
					                else
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    a.cout = b.Where(a => a.buyerid == search_id).Count();
 | 
					                    a.cout = b.Where(a => a.buyerid == search_id).Count();
 | 
				
			||||||
                    a.msg = await b.Where(a => a.buyerid == search_id).Paginate(pageindex, pagesize).ToListAsync();
 | 
					                    a.msg = await b.Where(a => a.buyerid == search_id).Paginate(pageindex, pagesize).Select(a => new { a.id, a.buyerid, a.Store.Price, a.Store.description, a.isVerification, a.Store.information, a.Store.Name }).ToListAsync();
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					               
 | 
				
			||||||
                return Ok(a);
 | 
					                return Ok(a);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@ -185,7 +189,7 @@ namespace asg_form.Controllers.Store
 | 
				
			|||||||
                List<buyreq_record> bureq = new List<buyreq_record>();
 | 
					                List<buyreq_record> bureq = new List<buyreq_record>();
 | 
				
			||||||
                foreach (var item in storeid)
 | 
					                foreach (var item in storeid)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    var stort = await sb.T_Store.FindAsync(storeid);
 | 
					                    var stort = await sb.T_Store.FindAsync(item);
 | 
				
			||||||
                    try
 | 
					                    try
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        user.Integral = cut_value((long)user.Integral, stort.Price);
 | 
					                        user.Integral = cut_value((long)user.Integral, stort.Price);
 | 
				
			||||||
 | 
				
			|||||||
@ -222,6 +222,19 @@ else{
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        [Route("api/v1/admin/userfind/{userid}")]
 | 
				
			||||||
 | 
					        [HttpGet]
 | 
				
			||||||
 | 
					        [Authorize]
 | 
				
			||||||
 | 
					        public async Task<ActionResult<object>> getuser(long userid)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (!this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin"))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                return BadRequest(new error_mb { code = 400, message = "无权访问" });
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            return await userManager.Users.Select(a => new { a.Id, a.Email, a.chinaname, a.UserName, a.Integral, a.officium }).FirstAsync(a=>a.Id==userid);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
@ -242,14 +255,14 @@ else{
 | 
				
			|||||||
                if (keyword == null)
 | 
					                if (keyword == null)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    a.cout = userManager.Users.Count();
 | 
					                    a.cout = userManager.Users.Count();
 | 
				
			||||||
                    a.msg = await userManager.Users.Paginate(pageindex, pagesize).ToListAsync();
 | 
					                    a.msg = await userManager.Users.Paginate(pageindex, pagesize).Select(a => new {a.Id,a.Email,a.chinaname,a.UserName,a.Integral,a.officium}).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).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 }).ToListAsync();
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                return Ok(a);
 | 
					                return Ok(a);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -66,10 +66,8 @@ using(TestDbContext db=new TestDbContext()){
 | 
				
			|||||||
    public async Task<ActionResult<object>> config_get_title([FromBody] string title)
 | 
					    public async Task<ActionResult<object>> config_get_title([FromBody] string title)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin"))
 | 
					       
 | 
				
			||||||
        {
 | 
					
 | 
				
			||||||
            return BadRequest(new error_mb { code = 400, message = "无权访问" });
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        using (TestDbContext db = new TestDbContext())
 | 
					        using (TestDbContext db = new TestDbContext())
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            var config = db.T_config.FirstOrDefault(a => a.Title == title);
 | 
					            var config = db.T_config.FirstOrDefault(a => a.Title == title);
 | 
				
			||||||
 | 
				
			|||||||
@ -1,4 +1,6 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					using System.Security.Cryptography;
 | 
				
			||||||
 | 
					using System.Runtime.InteropServices.ComTypes;
 | 
				
			||||||
using asg_form.Controllers.Hubs;
 | 
					using asg_form.Controllers.Hubs;
 | 
				
			||||||
using Manganese.Text;
 | 
					using Manganese.Text;
 | 
				
			||||||
using Masuit.Tools;
 | 
					using Masuit.Tools;
 | 
				
			||||||
@ -20,6 +22,7 @@ using System.Text;
 | 
				
			|||||||
using System.Web;
 | 
					using System.Web;
 | 
				
			||||||
using static asg_form.Controllers.excel;
 | 
					using static asg_form.Controllers.excel;
 | 
				
			||||||
using static ËùÓжÓÎé;
 | 
					using static ËùÓжÓÎé;
 | 
				
			||||||
 | 
					using Manganese.Array;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace asg_form.Controllers
 | 
					namespace asg_form.Controllers
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -243,6 +246,81 @@ namespace asg_form.Controllers
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 提交表单
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        /// <param name="imageFile"></param>
 | 
				
			||||||
 | 
					        /// <param name="for1">表单信息</param>
 | 
				
			||||||
 | 
					        /// <param name="captoken">谷歌人机验证验证码</param>
 | 
				
			||||||
 | 
					        /// <returns></returns>
 | 
				
			||||||
 | 
					        [Route("api/v2/form/")]
 | 
				
			||||||
 | 
					        [HttpPost]
 | 
				
			||||||
 | 
					        public async Task<ActionResult<string>> PostAsync(IFormFile imageFile,[FromForm] form_get_new for1)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    TestDbContext ctx = new TestDbContext();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    if (ctx.Forms.Include(a=>a.events).Where(a=>a.events.name==for1.events_name).Any(e => e.team_name == for1.team_name))
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                    return BadRequest(new error_mb { code = 400, message = "有重名队伍" });
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                         if (imageFile == null || imageFile.Length == 0)
 | 
				
			||||||
 | 
					                return BadRequest("Invalid image file.");
 | 
				
			||||||
 | 
					            // 将文件保存到磁盘
 | 
				
			||||||
 | 
					            var filePath = Path.Combine(Directory.GetCurrentDirectory(), $"loge/{for1.events_name}/", $"{imageFile.FileName}");
 | 
				
			||||||
 | 
					            using (var stream = new FileStream(filePath, FileMode.Create))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                await imageFile.CopyToAsync(stream);
 | 
				
			||||||
 | 
					            }    // 返回成功响应
 | 
				
			||||||
 | 
					                      //  base64toimg(for1.logo_base64, $@"{AppDomain.CurrentDomain.BaseDirectory}loge\{for1.events_name}\{for1.team_name}.png");
 | 
				
			||||||
 | 
					                  var events= await ctx.events.FirstAsync(ctx => ctx.name == for1.events_name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        form form1 = new form();
 | 
				
			||||||
 | 
					                        form1.logo_uri = $"https://124.223.35.239/loge/{for1.events_name}/{for1.team_name}.png";
 | 
				
			||||||
 | 
					                        form1.team_name = for1.team_name;
 | 
				
			||||||
 | 
					                        form1.team_password = for1.team_password;
 | 
				
			||||||
 | 
					                        form1.team_tel = for1.team_tel;
 | 
				
			||||||
 | 
					                        form1.events = events;
 | 
				
			||||||
 | 
					                    
 | 
				
			||||||
 | 
					                        List<role> role = new List<role>();
 | 
				
			||||||
 | 
					                        foreach (role_get a in for1.role_get)
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            role.Add(new role { role_id = a.role_id, role_lin = a.role_lin, role_name = a.role_name,Common_Roles=a.Common_Roles,Historical_Ranks=a.Historical_Ranks,Id_Card=a.Id_Card,Game_Name=a.Game_Name,Phone_Number=a.Phone_Number,Id_Card_Name=a.Id_Card_Name });
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        form1.role = role;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        ctx.Forms.Add(form1);
 | 
				
			||||||
 | 
					                        await ctx.SaveChangesAsync();
 | 
				
			||||||
 | 
					                    int nownumber = ctx.Forms.Count();
 | 
				
			||||||
 | 
					                    //ChatRoomHub chat = new ChatRoomHub();
 | 
				
			||||||
 | 
					                    // await chat.formok(nownumber, for1.team_name);
 | 
				
			||||||
 | 
					                    try
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        await hubContext.Clients.All.SendAsync("formok", $"队伍{for1.team_name}已经成功报名,剩余队伍名额:{ctx.Forms.Count()}/32");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    catch
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    logger.Info($"有新队伍报名!队伍名称:{for1.team_name} ");
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    return "ok!";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
     public void base64toimg(string base64,string path)
 | 
					     public void base64toimg(string base64,string path)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -393,6 +471,7 @@ namespace asg_form.Controllers
 | 
				
			|||||||
        public async Task<ActionResult<List<string>>> search_name(string team_name,string events_name)
 | 
					        public async Task<ActionResult<List<string>>> search_name(string team_name,string events_name)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            var ctx = new TestDbContext();
 | 
					            var ctx = new TestDbContext();
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
            var data = ctx.Forms.Where(a => a.team_name.IndexOf(team_name) >= 0&&a.events.name==events_name).Select(a => a.team_name).ToList();
 | 
					            var data = ctx.Forms.Where(a => a.team_name.IndexOf(team_name) >= 0&&a.events.name==events_name).Select(a => a.team_name).ToList();
 | 
				
			||||||
            return data;
 | 
					            return data;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@ -440,6 +519,7 @@ namespace asg_form.Controllers
 | 
				
			|||||||
        public string team_tel { get; set; }
 | 
					        public string team_tel { get; set; }
 | 
				
			||||||
        public string logo_uri { get; set; }
 | 
					        public string logo_uri { get; set; }
 | 
				
			||||||
        public Events.T_events events { get; set; }
 | 
					        public Events.T_events events { get; set; }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
      //  public string? belong { get; set; }
 | 
					      //  public string? belong { get; set; }
 | 
				
			||||||
        public List<role> role { get; set; } = new List<role>();
 | 
					        public List<role> role { get; set; } = new List<role>();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -447,7 +527,7 @@ namespace asg_form.Controllers
 | 
				
			|||||||
    public class form_get
 | 
					    public class form_get
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public DateTime time { get; set; } = DateTime.Now;
 | 
					       // public DateTime time { get; set; } = DateTime.Now;
 | 
				
			||||||
        public string team_name { get; set; }
 | 
					        public string team_name { get; set; }
 | 
				
			||||||
        public string team_password { get; set; }
 | 
					        public string team_password { get; set; }
 | 
				
			||||||
        public string team_tel { get; set; }
 | 
					        public string team_tel { get; set; }
 | 
				
			||||||
@ -457,6 +537,19 @@ namespace asg_form.Controllers
 | 
				
			|||||||
        public List<role_get> role_get { get; set; }
 | 
					        public List<role_get> role_get { get; set; }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      public class form_get_new
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public DateTime time { get; set; } = DateTime.Now;
 | 
				
			||||||
 | 
					        public string team_name { get; set; }
 | 
				
			||||||
 | 
					        public string team_password { get; set; }
 | 
				
			||||||
 | 
					        public string team_tel { get; set; }
 | 
				
			||||||
 | 
					      // public string logo_base64 { get; set; }
 | 
				
			||||||
 | 
					        public string events_name { get; set; }
 | 
				
			||||||
 | 
					      //  public string? belong { get; set; }
 | 
				
			||||||
 | 
					        public List<role_get> role_get { get; set; }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -464,7 +557,7 @@ namespace asg_form.Controllers
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public long Id { get; set; }
 | 
					        public long Id { get; set; }
 | 
				
			||||||
        public string team_name { get; set; }
 | 
					        public string Team_name { get; set; }
 | 
				
			||||||
        public string team_password { get; set; }
 | 
					        public string team_password { get; set; }
 | 
				
			||||||
        public string team_tel { get; set; }
 | 
					        public string team_tel { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -259,13 +259,20 @@ namespace asg_form.Controllers
 | 
				
			|||||||
        [Authorize]
 | 
					        [Authorize]
 | 
				
			||||||
        [Route("api/v1/user/")]
 | 
					        [Route("api/v1/user/")]
 | 
				
			||||||
        [HttpGet]
 | 
					        [HttpGet]
 | 
				
			||||||
        public async Task<ActionResult<post_user>> getuser()
 | 
					        public async Task<ActionResult<post_user>> getuser(bool showbase64=true)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            string id = this.User.FindFirst(ClaimTypes.NameIdentifier)!.Value;
 | 
					            string id = this.User.FindFirst(ClaimTypes.NameIdentifier)!.Value;
 | 
				
			||||||
            var user = await userManager.FindByIdAsync(id);
 | 
					            var user = await userManager.FindByIdAsync(id);
 | 
				
			||||||
            var isadmin = await userManager.IsInRoleAsync(user, "admin");
 | 
					            var isadmin = await userManager.IsInRoleAsync(user, "admin");
 | 
				
			||||||
            List<string> roles = (List<string>)await userManager.GetRolesAsync(user);
 | 
					            List<string> roles = (List<string>)await userManager.GetRolesAsync(user);
 | 
				
			||||||
            return new post_user { id = id.ToInt64(), Base64 = user.UserBase64, name = user.UserName, chinaname = user.chinaname, email = user.Email, isadmin = isadmin, Roles = roles, officium = user.officium };
 | 
					            if (showbase64) {
 | 
				
			||||||
 | 
					                return new post_user { id = id.ToInt64(), money = user.Integral, Base64 = user.UserBase64, name = user.UserName, chinaname = user.chinaname, email = user.Email, isadmin = isadmin, Roles = roles, officium = user.officium };
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                return new post_user { id = id.ToInt64(), money = user.Integral,  name = user.UserName, chinaname = user.chinaname, email = user.Email, isadmin = isadmin, Roles = roles, officium = user.officium };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -279,6 +286,7 @@ namespace asg_form.Controllers
 | 
				
			|||||||
            public string? email { get; set; }
 | 
					            public string? email { get; set; }
 | 
				
			||||||
            public bool isadmin { get; set; }
 | 
					            public bool isadmin { get; set; }
 | 
				
			||||||
            public string? officium { get; set; }
 | 
					            public string? officium { get; set; }
 | 
				
			||||||
 | 
					            public long? money {  get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            public List<string>? Roles { get; set; }
 | 
					            public List<string>? Roles { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -120,8 +120,50 @@ namespace asg_form.Controllers
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// 修改新闻
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        /// <param name="req_News">新闻内容</param>
 | 
				
			||||||
 | 
					        /// <returns></returns>
 | 
				
			||||||
 | 
					        [Authorize]
 | 
				
			||||||
 | 
					        [Route("api/v1/admin/news/")]
 | 
				
			||||||
 | 
					        [HttpPut]
 | 
				
			||||||
 | 
					        public async Task<ActionResult<string>> Put([FromBody] req_news req_News,long newsid)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            string id = this.User.FindFirst(ClaimTypes.NameIdentifier)!.Value;
 | 
				
			||||||
 | 
					            var user = await userManager.FindByIdAsync(id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            bool a = await userManager.IsInRoleAsync(user, "admin");
 | 
				
			||||||
 | 
					            if (a)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                using (TestDbContext ctx = new TestDbContext())
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    var qwq= await ctx.news.FindAsync(newsid);
 | 
				
			||||||
 | 
					                    qwq.msg=req_News.msg;
 | 
				
			||||||
 | 
					                    qwq.Title=req_News.Title;
 | 
				
			||||||
 | 
					                    qwq.FormName = user.UserName;
 | 
				
			||||||
 | 
					                    await ctx.SaveChangesAsync();
 | 
				
			||||||
 | 
					                   
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                  
 | 
					                  
 | 
				
			||||||
 | 
					                return "ok!";
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                return "无权访问";
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class T_news
 | 
					public class T_news
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        public long Id { get; set; }
 | 
					        public long Id { get; set; }
 | 
				
			||||||
@ -144,4 +186,3 @@ namespace asg_form.Controllers
 | 
				
			|||||||
    
 | 
					    
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user