|
|
|
@ -279,25 +279,49 @@ public class Ghre_SurveyQuestionPoolServices : BaseServices<Ghre_SurveyQuestionP |
|
|
|
|
|
|
|
|
|
public async Task<ServiceResult> UpdateFrom(long Id, FromGhre_SurveyQuestionPoolPageData editModel) |
|
|
|
|
{ |
|
|
|
|
var questionType = editModel.questionType.Where(x => x.isActive == 1).FirstOrDefault(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await Db.Ado.BeginTranAsync(); |
|
|
|
|
|
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
await Db.Deleteable<Ghre_SurveyQuestionPoolOption>().Where(x => x.SurveyQuestionPoolId == Id).ExecuteCommandAsync(); |
|
|
|
|
string questionTypeName = ConvertQuestionType(questionType.QuestionType); |
|
|
|
|
var data = await base.QueryById(Id); |
|
|
|
|
|
|
|
|
|
var insert = Mapper.Map(data).ToANew<EditGhre_SurveyQuestionPoolInput>(); |
|
|
|
|
await _ghre_SurveyQuestionPoolOptionServicesServices.Delete(x => x.SurveyQuestionPoolId == Id); |
|
|
|
|
|
|
|
|
|
var insert = Mapper.Map(editModel).ToANew<EditGhre_SurveyQuestionPoolInput>(); |
|
|
|
|
await base.Update(Id, insert, null, ["QuestionNo"]); |
|
|
|
|
insert.BuiltIn = editModel.baseData.BuiltIn; |
|
|
|
|
|
|
|
|
|
insert.QuestionType = questionType.QuestionType; |
|
|
|
|
insert.QuestionNo = await GenerateContinuousSequence(insert.QuestionType.Substring(0, 1)); |
|
|
|
|
insert.QuestionContent = questionType.QuestionContent; |
|
|
|
|
insert.QuestionAnalysis = questionType.QuestionAnalysis; |
|
|
|
|
|
|
|
|
|
//for (int j = 0; j < editModel.Options.Count; j++) |
|
|
|
|
//{ |
|
|
|
|
// var option = Mapper.Map(editModel.Options[j]).ToANew<Ghre_SurveyOption>(); |
|
|
|
|
await base.Update(Id, insert); |
|
|
|
|
|
|
|
|
|
// option.SurveyQuestionId = Id; |
|
|
|
|
// await Db.Insertable(option).ExecuteReturnSnowflakeIdAsync(); |
|
|
|
|
var insertAnswers = questionType.Options.Select(x => new InsertGhre_SurveyQuestionPoolOptionInput() |
|
|
|
|
{ |
|
|
|
|
OptionNo = x.OptionNo, |
|
|
|
|
OptionContent = x.OptionContent, |
|
|
|
|
ImageUrl = x.ImageUrl, |
|
|
|
|
ImageWidthPc = x.ImageWidthPc, |
|
|
|
|
ImageWidthApp = x.ImageWidthApp, |
|
|
|
|
}).ToList(); |
|
|
|
|
int i = 100; |
|
|
|
|
insertAnswers.ForEach(x => |
|
|
|
|
{ |
|
|
|
|
x.TaxisNo = i; |
|
|
|
|
x.SurveyQuestionPoolId = Id; |
|
|
|
|
i = i + 100; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await _ghre_SurveyQuestionPoolOptionServicesServices.Add(insertAnswers); |
|
|
|
|
//} |
|
|
|
|
await Db.Ado.CommitTranAsync(); |
|
|
|
|
|
|
|
|
|
return ServiceResult.OprateSuccess("更新成功!"); |
|
|
|
|
return ServiceResult.OprateSuccess("修改成功!"); |
|
|
|
|
} |
|
|
|
|
catch (Exception) |
|
|
|
|
{ |
|
|
|
|