4
This commit is contained in:
parent
0d369e426f
commit
cc7ad7c7a5
@ -67,7 +67,7 @@ namespace asg_form.Controllers
|
||||
string Invitorid = this.User.FindFirst(ClaimTypes.NameIdentifier)!.Value;
|
||||
var user = await userManager.FindByIdAsync(Invitorid);
|
||||
long userId = user.Id;
|
||||
if (user.officium != "Commentator" || !this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "nbadmin")) return Ok(new error_mb { code = 401, message = "您不是解说无法完成邀请" });
|
||||
if (user.officium != "Commentator" ) return Ok(new error_mb { code = 401, message = "您不是解说无法完成邀请" });
|
||||
using (TestDbContext sb = new TestDbContext())
|
||||
{
|
||||
try
|
||||
|
@ -42,13 +42,15 @@ namespace asg_form.Controllers
|
||||
game.team1_name = req.team1_name;
|
||||
game.team2_name = req.team2_name;
|
||||
game.opentime = req.opentime;
|
||||
game.commentary = req.commentary;
|
||||
game.bilibiliuri = req.bilibiliuri;
|
||||
game.referee = req.referee;
|
||||
game.belong = req.belong;
|
||||
game.tag=req.tag;
|
||||
game.judge = req.judge;
|
||||
game.commentary = req.commentary;
|
||||
if(req.comLimit != null)
|
||||
game.com_limit = req.comLimit;
|
||||
else game.com_limit = 2;
|
||||
game.person_type = req.personType;
|
||||
await testDb.SaveChangesAsync();
|
||||
return Ok(new { code = 200, message = "加入成功" });
|
||||
@ -85,10 +87,12 @@ namespace asg_form.Controllers
|
||||
bool a = await userManager.IsInRoleAsync(user, "admin");
|
||||
if (a)
|
||||
{
|
||||
int wp = -1;
|
||||
try
|
||||
{
|
||||
|
||||
using (TestDbContext testDb = new TestDbContext())
|
||||
{
|
||||
{ wp = 0;
|
||||
testDb.team_Games.Add(new team_game
|
||||
{
|
||||
team1_name = req.team1_name,
|
||||
@ -104,13 +108,14 @@ namespace asg_form.Controllers
|
||||
com_limit = req.comLimit,
|
||||
person_type = req.personType,
|
||||
});
|
||||
wp = 1;
|
||||
await testDb.SaveChangesAsync();
|
||||
return Ok(new { code = 200, message = "加入成功" });
|
||||
}
|
||||
|
||||
}catch (Exception ex)
|
||||
{
|
||||
return Ok(new { code = 500, message = "服务器错误", details = ex.Message });
|
||||
return Ok(new { code = 500, message = "服务器错误", details = ex.Message,wp });
|
||||
}
|
||||
|
||||
}
|
||||
@ -181,12 +186,17 @@ namespace asg_form.Controllers
|
||||
TestDbContext testDb = new TestDbContext();
|
||||
team_game game = testDb.team_Games.Include(a => a.logs).First(a => a.id == gameid);
|
||||
testDb.team_Games.Remove(game);
|
||||
var query = testDb.T_Invitation.Where(n => n.match_id == gameid).ToList();
|
||||
if (query.Any())
|
||||
{
|
||||
testDb.T_Invitation.RemoveRange(query);
|
||||
}
|
||||
await testDb.SaveChangesAsync();
|
||||
return "ok";
|
||||
return Ok(new error_mb { code = 200, message = "成功删除" });
|
||||
}
|
||||
else
|
||||
{
|
||||
return BadRequest(new error_mb { code = 400, message = "无权访问" });
|
||||
return Ok(new error_mb { code = 401, message = "无权访问" });
|
||||
|
||||
}
|
||||
|
||||
@ -357,7 +367,7 @@ namespace asg_form.Controllers
|
||||
public Uri? bilibiliuri { get; set;}
|
||||
public string tag { get; set; }
|
||||
public string? judge { get; set; }
|
||||
public int comLimit { get; set; }
|
||||
public int comLimit { get; set; } = 2;
|
||||
public string? personType { get; set; }
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user