51 lines
No EOL
1.3 KiB
C#
51 lines
No EOL
1.3 KiB
C#
using SurveyBackend.DTOs.Survey;
|
|
using SurveyLib.Core.Models;
|
|
|
|
namespace SurveyBackend.Mappers;
|
|
|
|
/// <summary>
|
|
/// Маппер всего про опросы
|
|
/// </summary>
|
|
public static class SurveyMapper
|
|
{
|
|
/// <summary>
|
|
/// Схема создания в модель
|
|
/// </summary>
|
|
/// <param name="dto"></param>
|
|
/// <param name="userId"></param>
|
|
/// <returns></returns>
|
|
public static Survey CreateDtoToModel(SurveyCreateDto dto, int userId)
|
|
{
|
|
return new Survey
|
|
{
|
|
Title = dto.Title,
|
|
Description = dto.Description,
|
|
CreatedBy = userId
|
|
};
|
|
}
|
|
|
|
public static Survey UpdateDtoToModel(SurveyUpdateDto dto, int userId, int surveyId) => new Survey
|
|
{
|
|
Id = surveyId,
|
|
Title = dto.Title,
|
|
Description = dto.Description,
|
|
CreatedBy = userId
|
|
};
|
|
|
|
/// <summary>
|
|
/// Модель в выходную схему
|
|
/// </summary>
|
|
/// <param name="survey"></param>
|
|
/// <returns></returns>
|
|
public static SurveyOutputDto ModelToOutputDto(Survey survey)
|
|
{
|
|
return new SurveyOutputDto
|
|
{
|
|
Id = survey.Id,
|
|
Title = survey.Title,
|
|
Description = survey.Description,
|
|
CreatedBy = survey.CreatedBy,
|
|
CreatedAt = survey.CreatedAt,
|
|
};
|
|
}
|
|
} |