using AngleSharp.Dom;
using Manganese.Array;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using NLog;
using System.Collections.Generic;
namespace asg_form.Controllers
{
[ApiController]
public class 查询是否重名 : ControllerBase
{
private readonly Logger _logger = LogManager.GetCurrentClassLogger();
///
/// 获取所有video
///
///
[Route("api/v1/video/")]
[HttpGet]
public async Task>> get_video()
{
DirectoryInfo di = new DirectoryInfo($@"{AppDomain.CurrentDomain.BaseDirectory}video");
FileInfo[] files = di.GetFiles();
List result = new List();
foreach (FileInfo file in files)
{
result.Add(file.Name);
}
return result;
}
[Route("api/v1/Duplicate_name/")]
[HttpGet]
public async Task> Post(string name,string event_name)
{
TestDbContext ctx = new TestDbContext();
bool b = ctx.Forms.Include(a=>a.events).Any(a=>a.team_name==name&&a.events.name==event_name);
if (b)
{
return BadRequest("Have a CHONG NAME");
}
else
{
return "No have a chong name";
}
}
[Route("api/v2/repeatName/")]
[HttpGet]
public async Task> rpName(string teamName, int eventId)
{
TestDbContext ctx = new TestDbContext();
bool isRepeat = ctx.Forms.Include(a => a.events).Any(a => a.team_name == teamName && a.events.Id == eventId);
if (isRepeat)
{
return Ok(new { code = 200, message = "不重复" ,data = true});
}
else
{
return Ok(new { code = 200, message = "重复" ,data = false});
}
}
}
}