Exemplo n.º 1
0
 private answer_value_versions MapVersions(answer_values answerValue)
 {
     return(new answer_value_versions
     {
         QuestionId = answerValue.QuestionId,
         Value = answerValue.Value,
         OptionId = answerValue.OptionId,
         AnswerId = answerValue.AnswerId,
         AnswerValueId = answerValue.Id,
         CreatedAt = answerValue.CreatedAt,
         Version = answerValue.Version,
         UpdatedAt = answerValue.UpdatedAt,
         WorkflowState = answerValue.WorkflowState,
         MicrotingUid = answerValue.MicrotingUid
     });
 }
Exemplo n.º 2
0
        public async Task Delete(MicrotingDbContext dbContext)
        {
            answer_values answerValue = await dbContext.answer_values.FirstOrDefaultAsync(x => x.Id == Id);

            if (answerValue == null)
            {
                throw new NullReferenceException($"Could not find answer value with Id: {Id}");
            }

            answerValue.WorkflowState = Constants.Constants.WorkflowStates.Removed;

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

                dbContext.answer_value_versions.Add(MapVersions(answerValue));
                await dbContext.SaveChangesAsync().ConfigureAwait(false);
            }
        }