Ejemplo n.º 1
0
        public async Task Update(MicrotingDbContext dbContext)
        {
            question_translations questionTranslation =
                await dbContext.QuestionTranslations.SingleOrDefaultAsync(x => x.Id == Id).ConfigureAwait(false);

            if (questionTranslation == null)
            {
                throw new NullReferenceException($"Could not find question_translation with id {Id}");
            }

            questionTranslation.LanguageId    = LanguageId;
            questionTranslation.QuestionId    = QuestionId;
            questionTranslation.Name          = Name;
            questionTranslation.WorkflowState = WorkflowState;
            questionTranslation.MicrotingUid  = MicrotingUid;

            if (dbContext.ChangeTracker.HasChanges())
            {
                questionTranslation.UpdatedAt = DateTime.UtcNow;
                questionTranslation.Version  += 1;

                dbContext.QuestionTranslationVersions.Add(MapVersions(questionTranslation));
                await dbContext.SaveChangesAsync().ConfigureAwait(false);
            }
        }
Ejemplo n.º 2
0
 private question_translation_versions MapVersions(question_translations questionTranslations)
 {
     return(new question_translation_versions()
     {
         CreatedAt = questionTranslations.CreatedAt,
         UpdatedAt = questionTranslations.UpdatedAt,
         Version = questionTranslations.Version,
         WorkflowState = questionTranslations.WorkflowState,
         MicrotingUid = questionTranslations.MicrotingUid,
         LanguageId = questionTranslations.LanguageId,
         QuestionId = questionTranslations.QuestionId,
         Name = questionTranslations.Name,
         QuestionTranslationId = questionTranslations.Id
     });
 }