using Competition.Common.Util; using CompetitionAPI.api.unity; using CompetitionAPI.Util; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; namespace CompetitionAPI.Controllers.unity { [Route("unity/[controller]")] [ApiController] public class SelectPlatformAreaController : Controller { Competition.Mysql.BLL.pow_user_exam user_exam_bll = new Competition.Mysql.BLL.pow_user_exam(); public SelectPlatformAreaController() { } /// /// 选择台区上传接口 /// /// /// [Authorize] [HttpPost] [APIFilter] public JsonResult Index([FromForm] SelectPlatformAreaRequest req) { try { var user_exam_model = user_exam_bll.GetModelList(" ExamId='" + req.ExamId + "' and UserId='" + req.UserId + "' ").FirstOrDefault(); if (user_exam_model != null) { if (user_exam_model.Status == "已结束") { return Json(Tool.GetJsonWithCode(APICode.Fail, "考生考试已结束")); } user_exam_model.SelectPlatformArea = req.SelectPlatformArea; if (req.SelectPlatformArea != user_exam_model.PlatformAreaName) { user_exam_model.IsScore = "1"; } if (user_exam_bll.Update(user_exam_model)) { return Json(Tool.GetJsonWithCode(APICode.Success, "成功")); } else { return Json(Tool.GetJsonWithCode(APICode.Fail, "失败")); } } else { return Json(Tool.GetJsonWithCode(APICode.Fail, "考生考试信息不存在")); } } catch (Exception ex) { LogHelper.WriteLog(ex.Message + ",行号:" + ex.StackTrace); return Json(Tool.GetJsonWithCode(APICode.Fail, "发生错误,请联系管理员。")); } } } }