public async Task <bool> AddUserInfo(UserInfo userInfo) { userInfo.Id = daoUtils.GUID(); await dbContext.UserInfos.AddAsync(userInfo); return(await dbContext.SaveChangesAsync() == 1); }
public async Task <bool> UploadQuiz(QuizQuestion question) { question.Id = daoUtils.GUID(); foreach (var quizOption in question.OptionDTOList) { quizOption.QuizId = question.Id; } await using var tx = await dbContext.Database.BeginTransactionAsync(); await dbContext.QuizQuestions.AddAsync(question); await dbContext.SaveChangesAsync(); await tx.CommitAsync(); return(true); }
public async Task <string> UploadOj(OjQuestion question, OjTestCaseTable ojTestCaseTable) { question.Id = daoUtils.GUID(); ojTestCaseTable.OjId = question.Id; await using var tx = await dbContext.Database.BeginTransactionAsync(); var count = await dbContext.OjQuestions.CountAsync(); question.OrderId = count + 1; await dbContext.OjQuestions.AddAsync(question); await dbContext.SaveChangesAsync(); ojTestCaseTable.OjId = question.Id; await dbContext.OjTestCaseTables.AddAsync(ojTestCaseTable); await dbContext.SaveChangesAsync(); await tx.CommitAsync(); return(question.Id); }