feat: 完成提交作业的后端
This commit is contained in:
@@ -30,7 +30,7 @@ public class ExamManager
|
||||
try
|
||||
{
|
||||
// 检查实验ID是否已存在
|
||||
var existingExam = _db.ExamTable.Where(e => e.ID == id).FirstOrDefault();
|
||||
var existingExam = _db.ExamTable.Where(e => e.ID.ToString() == id).FirstOrDefault();
|
||||
if (existingExam != null)
|
||||
{
|
||||
logger.Error($"实验ID已存在: {id}");
|
||||
@@ -82,28 +82,28 @@ public class ExamManager
|
||||
|
||||
if (name != null)
|
||||
{
|
||||
result += _db.ExamTable.Where(e => e.ID == id).Set(e => e.Name, name).Update();
|
||||
result += _db.ExamTable.Where(e => e.ID.ToString() == id).Set(e => e.Name, name).Update();
|
||||
}
|
||||
if (description != null)
|
||||
{
|
||||
result += _db.ExamTable.Where(e => e.ID == id).Set(e => e.Description, description).Update();
|
||||
result += _db.ExamTable.Where(e => e.ID.ToString() == id).Set(e => e.Description, description).Update();
|
||||
}
|
||||
if (tags != null)
|
||||
{
|
||||
var tagsString = string.Join(",", tags.Where(tag => !string.IsNullOrWhiteSpace(tag)).Select(tag => tag.Trim()));
|
||||
result += _db.ExamTable.Where(e => e.ID == id).Set(e => e.Tags, tagsString).Update();
|
||||
result += _db.ExamTable.Where(e => e.ID.ToString() == id).Set(e => e.Tags, tagsString).Update();
|
||||
}
|
||||
if (difficulty.HasValue)
|
||||
{
|
||||
result += _db.ExamTable.Where(e => e.ID == id).Set(e => e.Difficulty, Math.Max(1, Math.Min(5, difficulty.Value))).Update();
|
||||
result += _db.ExamTable.Where(e => e.ID.ToString() == id).Set(e => e.Difficulty, Math.Max(1, Math.Min(5, difficulty.Value))).Update();
|
||||
}
|
||||
if (isVisibleToUsers.HasValue)
|
||||
{
|
||||
result += _db.ExamTable.Where(e => e.ID == id).Set(e => e.IsVisibleToUsers, isVisibleToUsers.Value).Update();
|
||||
result += _db.ExamTable.Where(e => e.ID.ToString() == id).Set(e => e.IsVisibleToUsers, isVisibleToUsers.Value).Update();
|
||||
}
|
||||
|
||||
// 更新时间
|
||||
_db.ExamTable.Where(e => e.ID == id).Set(e => e.UpdatedTime, DateTime.Now).Update();
|
||||
_db.ExamTable.Where(e => e.ID.ToString() == id).Set(e => e.UpdatedTime, DateTime.Now).Update();
|
||||
|
||||
logger.Info($"实验已更新: {id},更新记录数: {result}");
|
||||
return new(result);
|
||||
@@ -133,7 +133,7 @@ public class ExamManager
|
||||
/// <returns>包含实验信息的结果,如果未找到则返回空</returns>
|
||||
public Result<Optional<Exam>> GetExamByID(string examId)
|
||||
{
|
||||
var exams = _db.ExamTable.Where(exam => exam.ID == examId).ToArray();
|
||||
var exams = _db.ExamTable.Where(exam => exam.ID.ToString() == examId).ToArray();
|
||||
|
||||
if (exams.Length > 1)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user