add all docs
This commit is contained in:
parent
d692a2e519
commit
edff901b52
4 changed files with 49 additions and 0 deletions
|
|
@ -3,8 +3,16 @@ using SurveyBackend.DTOs;
|
||||||
|
|
||||||
namespace SurveyBackend.Mappers;
|
namespace SurveyBackend.Mappers;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Маппер всего связанного с авторизацией
|
||||||
|
/// </summary>
|
||||||
public static class AuthMapper
|
public static class AuthMapper
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Перегнать схему регистрации в нового юзера
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dto"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static User UserRegistrationToModel(UserRegistrationDto dto) => new User
|
public static User UserRegistrationToModel(UserRegistrationDto dto) => new User
|
||||||
{
|
{
|
||||||
Email = dto.Email,
|
Email = dto.Email,
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,18 @@ using SurveyLib.Core.Models.QuestionVariants;
|
||||||
|
|
||||||
namespace SurveyBackend.Mappers;
|
namespace SurveyBackend.Mappers;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Маппер всего про вопросы
|
||||||
|
/// </summary>
|
||||||
public static class QuestionMapper
|
public static class QuestionMapper
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Создание вопроса в модель
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dto"></param>
|
||||||
|
/// <param name="surveyId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <exception cref="BadRequestException"></exception>
|
||||||
public static QuestionBase QuestionCreationToModel(CreateQuestionDto dto, int surveyId)
|
public static QuestionBase QuestionCreationToModel(CreateQuestionDto dto, int surveyId)
|
||||||
{
|
{
|
||||||
return dto.QuestionType.ToLower() switch
|
return dto.QuestionType.ToLower() switch
|
||||||
|
|
@ -32,6 +42,11 @@ public static class QuestionMapper
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Модель в выходную схему
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="question"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static OutputQuestionDto ModelToQuestionDto(QuestionBase question)
|
public static OutputQuestionDto ModelToQuestionDto(QuestionBase question)
|
||||||
{
|
{
|
||||||
var withAnswerVariants = question.GetType() != typeof(TextQuestion);
|
var withAnswerVariants = question.GetType() != typeof(TextQuestion);
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,17 @@ using SurveyLib.Core.Models;
|
||||||
|
|
||||||
namespace SurveyBackend.Mappers;
|
namespace SurveyBackend.Mappers;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Маппер всего про опросы
|
||||||
|
/// </summary>
|
||||||
public static class SurveyMapper
|
public static class SurveyMapper
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Схема создания в модель
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dto"></param>
|
||||||
|
/// <param name="userId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static Survey CreateDtoToModel(CreateSurveyDto dto, int userId)
|
public static Survey CreateDtoToModel(CreateSurveyDto dto, int userId)
|
||||||
{
|
{
|
||||||
return new Survey
|
return new Survey
|
||||||
|
|
@ -15,6 +24,11 @@ public static class SurveyMapper
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Модель в выходную схему
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="survey"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static OutputSurveyDto ModelToOutputDto(Survey survey)
|
public static OutputSurveyDto ModelToOutputDto(Survey survey)
|
||||||
{
|
{
|
||||||
return new OutputSurveyDto
|
return new OutputSurveyDto
|
||||||
|
|
|
||||||
|
|
@ -2,17 +2,29 @@ using SurveyBackend.Services.Exceptions;
|
||||||
|
|
||||||
namespace SurveyBackend.Middlewares;
|
namespace SurveyBackend.Middlewares;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Имбовая миддлваря, ловит все эксепшны, кастомные прокидывает как HTTP-exception, остальные кидает 502 и кайфуем
|
||||||
|
/// </summary>
|
||||||
public class ExceptionsMiddleware
|
public class ExceptionsMiddleware
|
||||||
{
|
{
|
||||||
private readonly RequestDelegate _next;
|
private readonly RequestDelegate _next;
|
||||||
private readonly ILogger<ExceptionsMiddleware> _logger;
|
private readonly ILogger<ExceptionsMiddleware> _logger;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Ну типа конструктор хз
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="next"></param>
|
||||||
|
/// <param name="logger"></param>
|
||||||
public ExceptionsMiddleware(RequestDelegate next, ILogger<ExceptionsMiddleware> logger)
|
public ExceptionsMiddleware(RequestDelegate next, ILogger<ExceptionsMiddleware> logger)
|
||||||
{
|
{
|
||||||
_next = next;
|
_next = next;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="context"></param>
|
||||||
public async Task InvokeAsync(HttpContext context)
|
public async Task InvokeAsync(HttpContext context)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue