add AnswerVariant
This commit is contained in:
parent
8a80013c94
commit
ae43e8c74c
10 changed files with 139 additions and 5 deletions
|
|
@ -0,0 +1,28 @@
|
|||
using SurveyBackend.DTOs.AnswerVariant;
|
||||
using SurveyLib.Core.Models;
|
||||
|
||||
namespace SurveyBackend.Mappers;
|
||||
|
||||
public static class AnswerVariantMapper
|
||||
{
|
||||
public static AnswerVariant CreateDtoToModel(AnswerVariantCreateDto dto, int questionId) => new AnswerVariant
|
||||
{
|
||||
QuestionId = questionId,
|
||||
Text = dto.Text
|
||||
};
|
||||
|
||||
public static AnswerVariant UpdateDtoToModel(AnswerVariantUpdateDto dto, int answerVariantId, int questionId) =>
|
||||
new AnswerVariant
|
||||
{
|
||||
QuestionId = questionId,
|
||||
Id = answerVariantId,
|
||||
Text = dto.Text
|
||||
};
|
||||
|
||||
public static AnswerVariantOutputDto ModelToOutputDto(AnswerVariant model) => new AnswerVariantOutputDto
|
||||
{
|
||||
Id = model.Id,
|
||||
QuestionId = model.QuestionId,
|
||||
Text = model.Text
|
||||
};
|
||||
}
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
using SurveyBackend.DTOs.AnswerVariant;
|
||||
using SurveyBackend.DTOs.Question;
|
||||
using SurveyBackend.Services.Exceptions;
|
||||
using SurveyLib.Core.Models;
|
||||
|
|
@ -88,9 +89,9 @@ public static class QuestionMapper
|
|||
};
|
||||
}
|
||||
|
||||
private static List<OutputAnswerVariantDto> AnswerVariantsToDto(IEnumerable<AnswerVariant> answerVariants)
|
||||
private static List<AnswerVariantOutputDto> AnswerVariantsToDto(IEnumerable<AnswerVariant> answerVariants)
|
||||
{
|
||||
return answerVariants.Select(av => new OutputAnswerVariantDto
|
||||
return answerVariants.Select(av => new AnswerVariantOutputDto
|
||||
{
|
||||
Id = av.Id,
|
||||
QuestionId = av.QuestionId,
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ public static class SurveyMapper
|
|||
Title = survey.Title,
|
||||
Description = survey.Description,
|
||||
CreatedBy = survey.CreatedBy,
|
||||
CreatedAt = survey.CreatedAt,
|
||||
};
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue