feat(api): Отключена ручаня валидация в контроллере
This commit is contained in:
@@ -24,7 +24,7 @@ namespace PARR.API.Controllers.V1
|
||||
/// </summary>
|
||||
public class AgentHistoryController : BaseApiController
|
||||
{
|
||||
private readonly IValidator<AgentHistoryRequest> validator;
|
||||
//private readonly IValidator<AgentHistoryRequest> validator;
|
||||
private readonly IAgentHistoryRepository agentHistoryService;
|
||||
private readonly IUriService uriService;
|
||||
private readonly IMapper mapper;
|
||||
@@ -34,7 +34,7 @@ namespace PARR.API.Controllers.V1
|
||||
private readonly ILogger<AgentHistoryController> logger;
|
||||
|
||||
public AgentHistoryController(
|
||||
IValidator<AgentHistoryRequest> validator,
|
||||
//IValidator<AgentHistoryRequest> validator,
|
||||
IAgentHistoryRepository agentHistoryService,
|
||||
IUriService uriService,
|
||||
IMapper mapper,
|
||||
@@ -44,7 +44,7 @@ namespace PARR.API.Controllers.V1
|
||||
ILogger<AgentHistoryController> logger
|
||||
)
|
||||
{
|
||||
this.validator = validator;
|
||||
//this.validator = validator;
|
||||
this.agentHistoryService = agentHistoryService;
|
||||
this.uriService = uriService;
|
||||
this.mapper = mapper;
|
||||
@@ -119,9 +119,9 @@ namespace PARR.API.Controllers.V1
|
||||
[HttpPost(ApiRoutes.AgentHistory.Create)]
|
||||
public async Task<IActionResult> Create([FromBody] AgentHistoryRequest request)
|
||||
{
|
||||
var resultValidate = await validator.ValidateAsync(request);
|
||||
if (!resultValidate.IsValid)
|
||||
return BadRequest(new Response(resultValidate.Errors));
|
||||
//var resultValidate = await validator.ValidateAsync(request);
|
||||
//if (!resultValidate.IsValid)
|
||||
// return BadRequest(new Response(resultValidate.Errors));
|
||||
|
||||
|
||||
var clientIp = clientService.GetClientIp()?.ToString();
|
||||
|
||||
@@ -23,19 +23,19 @@ namespace PARR.API.Controllers.V1
|
||||
{
|
||||
private readonly IRabbitService mqService;
|
||||
private readonly MqSettings mqSettings;
|
||||
private readonly IValidator<DistributeRequest> validator;
|
||||
//private readonly IValidator<DistributeRequest> validator;
|
||||
private readonly IClientService clientService;
|
||||
|
||||
public DistributorController(
|
||||
IRabbitService mqService,
|
||||
MqSettings mqSettings,
|
||||
IValidator<DistributeRequest> validator,
|
||||
//IValidator<DistributeRequest> validator,
|
||||
IClientService clientService
|
||||
)
|
||||
{
|
||||
this.mqService = mqService;
|
||||
this.mqSettings = mqSettings;
|
||||
this.validator = validator;
|
||||
//this.validator = validator;
|
||||
this.clientService = clientService;
|
||||
}
|
||||
|
||||
@@ -47,9 +47,9 @@ namespace PARR.API.Controllers.V1
|
||||
[HttpPost(ApiRoutes.Distributor.Distribute)]
|
||||
public async Task<IActionResult> Distribute([FromBody] DistributeRequest request)
|
||||
{
|
||||
var resultValidate = await validator.ValidateAsync(request);
|
||||
if (!resultValidate.IsValid)
|
||||
return BadRequest(new Response(resultValidate.Errors));
|
||||
//var resultValidate = await validator.ValidateAsync(request);
|
||||
//if (!resultValidate.IsValid)
|
||||
// return BadRequest(new Response(resultValidate.Errors));
|
||||
|
||||
var requestToMq = new TemplateDistributorMq
|
||||
{
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace PARR.API.Controllers.V1
|
||||
private readonly IUriService uriService;
|
||||
private readonly IJobRepository jobService;
|
||||
private readonly ITemplateRepository templateService;
|
||||
private readonly IValidator<JobRequest> jobValidator;
|
||||
//private readonly IValidator<JobRequest> jobValidator;
|
||||
private readonly IRabbitService mqService;
|
||||
private readonly MqSettings mqSettings;
|
||||
private readonly IClientService clientService;
|
||||
@@ -54,7 +54,7 @@ namespace PARR.API.Controllers.V1
|
||||
IJobRepository jobService,
|
||||
ITemplateRepository templateService,
|
||||
IJobGroupRepository jobGroupService,
|
||||
IValidator<JobRequest> jobValidator,
|
||||
//IValidator<JobRequest> jobValidator,
|
||||
IUnitFilterService unitFilterService,
|
||||
IUnitRepository unitService,
|
||||
IRabbitService mqService,
|
||||
@@ -69,7 +69,7 @@ namespace PARR.API.Controllers.V1
|
||||
this.uriService = uriService;
|
||||
this.jobService = jobService;
|
||||
this.templateService = templateService;
|
||||
this.jobValidator = jobValidator;
|
||||
//this.jobValidator = jobValidator;
|
||||
this.mqService = mqService;
|
||||
this.mqSettings = mqSettings;
|
||||
this.clientService = clientService;
|
||||
@@ -188,12 +188,12 @@ namespace PARR.API.Controllers.V1
|
||||
[HttpPost(ApiRoutes.Job.Create)]
|
||||
public async Task<IActionResult> Create([FromBody] JobRequest request)
|
||||
{
|
||||
#region Валидация
|
||||
var jobValidateResult = await jobValidator.ValidateAsync(request);//Валидация параметров самого задания
|
||||
//#region Валидация
|
||||
//var jobValidateResult = await jobValidator.ValidateAsync(request);//Валидация параметров самого задания
|
||||
|
||||
if (!jobValidateResult.IsValid)
|
||||
return BadRequest(new Response(jobValidateResult.Errors));
|
||||
#endregion
|
||||
//if (!jobValidateResult.IsValid)
|
||||
// return BadRequest(new Response(jobValidateResult.Errors));
|
||||
//#endregion
|
||||
|
||||
//TODO: !!!!!!! проверить, если тип ЗОНТИК или ГРУППИРОВКА, то обязательно должны быть заполнены поля min max
|
||||
|
||||
@@ -262,9 +262,9 @@ namespace PARR.API.Controllers.V1
|
||||
[HttpPut(ApiRoutes.Job.Update)]
|
||||
public async Task<IActionResult> Update([FromRoute] Guid id, [FromBody] JobRequest request)
|
||||
{
|
||||
var resultValidate = await jobValidator.ValidateAsync(request);
|
||||
if (!resultValidate.IsValid)
|
||||
return BadRequest(new Response(resultValidate.Errors));
|
||||
//var resultValidate = await jobValidator.ValidateAsync(request);
|
||||
//if (!resultValidate.IsValid)
|
||||
// return BadRequest(new Response(resultValidate.Errors));
|
||||
|
||||
var orig = await jobService.Get()
|
||||
.Include(t => t.Tnk)
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace PARR.API.Controllers.V1
|
||||
private readonly IJobGroupRepository groupService;
|
||||
private readonly IJobRepository jobService;
|
||||
private readonly IEsppSchTypeConfigRepository esppConfigService;
|
||||
private readonly IValidator<JobGroupRequest> validator;
|
||||
//private readonly IValidator<JobGroupRequest> validator;
|
||||
private readonly IJobGroupTypeRepository jobGroupTypeService;
|
||||
private readonly IMatchingStatusService matchingStatusService;
|
||||
private readonly IScheduleResponseAreaTimeOffsetRepository scheduleResponseAreaTimeOffsetService;
|
||||
@@ -53,7 +53,7 @@ namespace PARR.API.Controllers.V1
|
||||
IJobGroupRepository groupService,
|
||||
IJobRepository jobService,
|
||||
IEsppSchTypeConfigRepository esppConfigService,
|
||||
IValidator<JobGroupRequest> validator,
|
||||
//IValidator<JobGroupRequest> validator,
|
||||
IJobGroupTypeRepository jobGroupTypeService,
|
||||
IMatchingStatusService matchingStatusService,
|
||||
IScheduleResponseAreaTimeOffsetRepository scheduleResponseAreaTimeOffsetService,
|
||||
@@ -67,7 +67,7 @@ namespace PARR.API.Controllers.V1
|
||||
this.groupService = groupService;
|
||||
this.jobService = jobService;
|
||||
this.esppConfigService = esppConfigService;
|
||||
this.validator = validator;
|
||||
//this.validator = validator;
|
||||
this.jobGroupTypeService = jobGroupTypeService;
|
||||
this.matchingStatusService = matchingStatusService;
|
||||
this.scheduleResponseAreaTimeOffsetService = scheduleResponseAreaTimeOffsetService;
|
||||
@@ -156,10 +156,10 @@ namespace PARR.API.Controllers.V1
|
||||
[HttpPost(ApiRoutes.JobGroup.Create)]
|
||||
public async Task<IActionResult> Create([FromBody] JobGroupRequest request)
|
||||
{
|
||||
var resultValidate = await validator.ValidateAsync(request);
|
||||
//var resultValidate = await validator.ValidateAsync(request);
|
||||
|
||||
if (!resultValidate.IsValid)
|
||||
return BadRequest(new Response(resultValidate.Errors));
|
||||
//if (!resultValidate.IsValid)
|
||||
// return BadRequest(new Response(resultValidate.Errors));
|
||||
|
||||
var jobGroup = new JobGroup
|
||||
{
|
||||
@@ -242,10 +242,10 @@ namespace PARR.API.Controllers.V1
|
||||
[HttpPut(ApiRoutes.JobGroup.Update)]
|
||||
public async Task<IActionResult> Update([FromRoute] Guid id, [FromBody] JobGroupRequest request)
|
||||
{
|
||||
var resultValidate = await validator.ValidateAsync(request);
|
||||
//var resultValidate = await validator.ValidateAsync(request);
|
||||
|
||||
if (!resultValidate.IsValid)
|
||||
return BadRequest(new Response(resultValidate.Errors));
|
||||
//if (!resultValidate.IsValid)
|
||||
// return BadRequest(new Response(resultValidate.Errors));
|
||||
|
||||
var orig = await groupService.Get()
|
||||
.Include(t => t.Jobs)
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace PARR.API.Controllers.V1
|
||||
{
|
||||
private readonly ILogger<JobUnitPreviewController> logger;
|
||||
private readonly IUnitFilterService unitFilterService;
|
||||
private readonly IValidator<JobRequest> jobValidator;
|
||||
//private readonly IValidator<JobRequest> jobValidator;
|
||||
private readonly IUnitRepository unitService;
|
||||
private readonly IJobGroupRepository jobGroupService;
|
||||
private readonly IMapper mapper;
|
||||
@@ -32,7 +32,7 @@ namespace PARR.API.Controllers.V1
|
||||
public JobUnitPreviewController(
|
||||
ILogger<JobUnitPreviewController> logger,
|
||||
IUnitFilterService unitFilterService,
|
||||
IValidator<JobRequest> jobValidator,
|
||||
//IValidator<JobRequest> jobValidator,
|
||||
IUnitRepository unitService,
|
||||
IJobGroupRepository jobGroupService,
|
||||
IMapper mapper
|
||||
@@ -40,7 +40,7 @@ namespace PARR.API.Controllers.V1
|
||||
{
|
||||
this.logger = logger;
|
||||
this.unitFilterService = unitFilterService;
|
||||
this.jobValidator = jobValidator;
|
||||
//this.jobValidator = jobValidator;
|
||||
this.unitService = unitService;
|
||||
this.jobGroupService = jobGroupService;
|
||||
this.mapper = mapper;
|
||||
@@ -54,12 +54,12 @@ namespace PARR.API.Controllers.V1
|
||||
[HttpPost(ApiRoutes.JobUnitPreview.Preview)]
|
||||
public async Task<IActionResult> Preview([FromBody] JobRequest request)
|
||||
{
|
||||
#region Валидация
|
||||
var jobValidateResult = await jobValidator.ValidateAsync(request);//Валидация параметров самого задания
|
||||
//#region Валидация
|
||||
//var jobValidateResult = await jobValidator.ValidateAsync(request);//Валидация параметров самого задания
|
||||
|
||||
if (!jobValidateResult.IsValid)
|
||||
return BadRequest(new Response(jobValidateResult.Errors));
|
||||
#endregion
|
||||
//if (!jobValidateResult.IsValid)
|
||||
// return BadRequest(new Response(jobValidateResult.Errors));
|
||||
//#endregion
|
||||
|
||||
var job = mapper.Map<Job>(request);
|
||||
|
||||
|
||||
@@ -27,21 +27,21 @@ namespace PARR.API.Controllers.V1
|
||||
private readonly ILogger<ProcessController> logger;
|
||||
private readonly IMapper mapper;
|
||||
private readonly IProcessRepository processService;
|
||||
private readonly IValidator<ProcessRequest> validator;
|
||||
//private readonly IValidator<ProcessRequest> validator;
|
||||
private readonly IUriService uriService;
|
||||
|
||||
public ProcessController(
|
||||
ILogger<ProcessController> logger,
|
||||
IMapper mapper,
|
||||
IProcessRepository processService,
|
||||
IValidator<ProcessRequest> validator,
|
||||
//IValidator<ProcessRequest> validator,
|
||||
IUriService uriService
|
||||
)
|
||||
{
|
||||
this.logger = logger;
|
||||
this.mapper = mapper;
|
||||
this.processService = processService;
|
||||
this.validator = validator;
|
||||
//this.validator = validator;
|
||||
this.uriService = uriService;
|
||||
}
|
||||
|
||||
@@ -120,9 +120,9 @@ namespace PARR.API.Controllers.V1
|
||||
[HttpPost(ApiRoutes.Process.Create)]
|
||||
public async Task<IActionResult> Create([FromBody] ProcessRequest request)
|
||||
{
|
||||
var resultValidate = await validator.ValidateAsync(request);
|
||||
if (!resultValidate.IsValid)
|
||||
return BadRequest(new Response(resultValidate.Errors));
|
||||
//var resultValidate = await validator.ValidateAsync(request);
|
||||
//if (!resultValidate.IsValid)
|
||||
// return BadRequest(new Response(resultValidate.Errors));
|
||||
|
||||
var existName = await processService.Get().FirstOrDefaultAsync(t => t.Name.ToLower() == request.Name.ToLower().Trim());
|
||||
if (existName != null)
|
||||
@@ -159,9 +159,9 @@ namespace PARR.API.Controllers.V1
|
||||
[HttpPut(ApiRoutes.Process.Update)]
|
||||
public async Task<IActionResult> Update([FromRoute] Guid id, [FromBody] ProcessRequest request)
|
||||
{
|
||||
var resultValidate = await validator.ValidateAsync(request);
|
||||
if (!resultValidate.IsValid)
|
||||
return BadRequest(new Response(resultValidate.Errors));
|
||||
//var resultValidate = await validator.ValidateAsync(request);
|
||||
//if (!resultValidate.IsValid)
|
||||
// return BadRequest(new Response(resultValidate.Errors));
|
||||
|
||||
//проверка на уникальность esppId
|
||||
var existEsppId = await processService.Get().FirstOrDefaultAsync(t => t.Id != id && t.EsppId == request.EsppId);
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace PARR.API.Controllers.V1.Statistics
|
||||
public class StatRobotStateController : BaseApiController
|
||||
{
|
||||
private readonly IInfluxDbService influxDbService;
|
||||
private readonly IValidator<RobotStateRequest> validator;
|
||||
//private readonly IValidator<RobotStateRequest> validator;
|
||||
private readonly InfluxDbSettings influxDbSettings;
|
||||
private readonly MonitoringSettings monitoringSettings;
|
||||
private readonly IClientService clientService;
|
||||
@@ -38,7 +38,7 @@ namespace PARR.API.Controllers.V1.Statistics
|
||||
|
||||
public StatRobotStateController(
|
||||
IInfluxDbService influxDbService,
|
||||
IValidator<RobotStateRequest> validator,
|
||||
//IValidator<RobotStateRequest> validator,
|
||||
InfluxDbSettings influxDbSettings,
|
||||
MonitoringSettings monitoringSettings,
|
||||
IClientService clientService,
|
||||
@@ -47,7 +47,7 @@ namespace PARR.API.Controllers.V1.Statistics
|
||||
)
|
||||
{
|
||||
this.influxDbService = influxDbService;
|
||||
this.validator = validator;
|
||||
//this.validator = validator;
|
||||
this.influxDbSettings = influxDbSettings;
|
||||
this.monitoringSettings = monitoringSettings;
|
||||
this.clientService = clientService;
|
||||
@@ -136,9 +136,9 @@ namespace PARR.API.Controllers.V1.Statistics
|
||||
[HttpPost(ApiRoutes.StatRobotState.Send)]
|
||||
public async Task<IActionResult> Send([FromBody] RobotStateRequest request)
|
||||
{
|
||||
var resultValidate = await validator.ValidateAsync(request);
|
||||
if (!resultValidate.IsValid)
|
||||
return BadRequest(new Response(resultValidate.Errors));
|
||||
//var resultValidate = await validator.ValidateAsync(request);
|
||||
//if (!resultValidate.IsValid)
|
||||
// return BadRequest(new Response(resultValidate.Errors));
|
||||
|
||||
var result = influxDbService.Write(write =>
|
||||
{
|
||||
|
||||
@@ -27,21 +27,21 @@ namespace PARR.API.Controllers.V1
|
||||
private readonly ILogger<SubprocessController> logger;
|
||||
private readonly IMapper mapper;
|
||||
private readonly ISubprocessRepository subprocessService;
|
||||
private readonly IValidator<SubprocessRequest> validator;
|
||||
//private readonly IValidator<SubprocessRequest> validator;
|
||||
private readonly IUriService uriService;
|
||||
|
||||
public SubprocessController(
|
||||
ILogger<SubprocessController> logger,
|
||||
IMapper mapper,
|
||||
ISubprocessRepository subprocessService,
|
||||
IValidator<SubprocessRequest> validator,
|
||||
//IValidator<SubprocessRequest> validator,
|
||||
IUriService uriService
|
||||
)
|
||||
{
|
||||
this.logger = logger;
|
||||
this.mapper = mapper;
|
||||
this.subprocessService = subprocessService;
|
||||
this.validator = validator;
|
||||
//this.validator = validator;
|
||||
this.uriService = uriService;
|
||||
}
|
||||
|
||||
@@ -124,9 +124,9 @@ namespace PARR.API.Controllers.V1
|
||||
[HttpPost(ApiRoutes.Subprocess.Create)]
|
||||
public async Task<IActionResult> Create([FromBody] SubprocessRequest request)
|
||||
{
|
||||
var resultValidate = await validator.ValidateAsync(request);
|
||||
if (!resultValidate.IsValid)
|
||||
return BadRequest(new Response(resultValidate.Errors));
|
||||
//var resultValidate = await validator.ValidateAsync(request);
|
||||
//if (!resultValidate.IsValid)
|
||||
// return BadRequest(new Response(resultValidate.Errors));
|
||||
|
||||
var existName = await subprocessService.Get().FirstOrDefaultAsync(t => t.Name.ToLower() == request.Name.Trim().ToLower());
|
||||
if (existName != null)
|
||||
@@ -164,9 +164,9 @@ namespace PARR.API.Controllers.V1
|
||||
[HttpPut(ApiRoutes.Subprocess.Update)]
|
||||
public async Task<IActionResult> Update([FromRoute] Guid id, [FromBody] SubprocessRequest request)
|
||||
{
|
||||
var resultValidate = await validator.ValidateAsync(request);
|
||||
if (!resultValidate.IsValid)
|
||||
return BadRequest(new Response(resultValidate.Errors));
|
||||
//var resultValidate = await validator.ValidateAsync(request);
|
||||
//if (!resultValidate.IsValid)
|
||||
// return BadRequest(new Response(resultValidate.Errors));
|
||||
|
||||
//проверка на уникальность esppId
|
||||
var existEsppId = await subprocessService.Get().FirstOrDefaultAsync(t => t.Id != id && t.EsppId == request.EsppId);
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace PARR.API.Controllers.V1
|
||||
[Authorize(Roles = ParrRoles.Administrator.Role)]
|
||||
public class TemplateActivatorController : BaseApiController
|
||||
{
|
||||
private readonly IValidator<TemplateActivatorRequest> validator;
|
||||
//private readonly IValidator<TemplateActivatorRequest> validator;
|
||||
private readonly IRabbitService mqService;
|
||||
private readonly IUriService uriService;
|
||||
private readonly MqSettings mqSettings;
|
||||
@@ -30,7 +30,7 @@ namespace PARR.API.Controllers.V1
|
||||
private readonly IClientService clientService;
|
||||
|
||||
public TemplateActivatorController(
|
||||
IValidator<TemplateActivatorRequest> validator,
|
||||
//IValidator<TemplateActivatorRequest> validator,
|
||||
IRabbitService mqService,
|
||||
IUriService uriService,
|
||||
MqSettings mqSettings,
|
||||
@@ -38,7 +38,7 @@ namespace PARR.API.Controllers.V1
|
||||
IClientService clientService
|
||||
)
|
||||
{
|
||||
this.validator = validator;
|
||||
//this.validator = validator;
|
||||
this.mqService = mqService;
|
||||
this.uriService = uriService;
|
||||
this.mqSettings = mqSettings;
|
||||
@@ -54,9 +54,9 @@ namespace PARR.API.Controllers.V1
|
||||
[HttpPost(ApiRoutes.TemplateActivator.SendRequest)]
|
||||
public async Task<IActionResult> SendRequest([FromBody] TemplateActivatorRequest request)
|
||||
{
|
||||
var resultValidate = await validator.ValidateAsync(request);
|
||||
if (!resultValidate.IsValid)
|
||||
return BadRequest(new Response(resultValidate.Errors));
|
||||
//var resultValidate = await validator.ValidateAsync(request);
|
||||
//if (!resultValidate.IsValid)
|
||||
// return BadRequest(new Response(resultValidate.Errors));
|
||||
|
||||
var mqRequest = new TemplateActivatorMq
|
||||
{
|
||||
|
||||
@@ -21,19 +21,19 @@ namespace PARR.API.Controllers.V1
|
||||
{
|
||||
private readonly ITemplateRepository templateService;
|
||||
private readonly IMapper mapper;
|
||||
private readonly IValidator<TemplateScheduleEsppIdRequest> validator;
|
||||
//private readonly IValidator<TemplateScheduleEsppIdRequest> validator;
|
||||
private readonly IUriService uriService;
|
||||
|
||||
public TemplateScheduleEspp(
|
||||
ITemplateRepository templateService,
|
||||
IMapper mapper,
|
||||
IValidator<TemplateScheduleEsppIdRequest> validator,
|
||||
//IValidator<TemplateScheduleEsppIdRequest> validator,
|
||||
IUriService uriService
|
||||
)
|
||||
{
|
||||
this.templateService = templateService;
|
||||
this.mapper = mapper;
|
||||
this.validator = validator;
|
||||
//this.validator = validator;
|
||||
this.uriService = uriService;
|
||||
}
|
||||
|
||||
@@ -62,9 +62,9 @@ namespace PARR.API.Controllers.V1
|
||||
[HttpPost(ApiRoutes.TemplateScheduleEspp.Create)]
|
||||
public async Task<IActionResult> SetEsppId([FromRoute] Guid templateId, [FromBody] TemplateScheduleEsppIdRequest request)
|
||||
{
|
||||
var resultValidate = await validator.ValidateAsync(request);
|
||||
if (!resultValidate.IsValid)
|
||||
return BadRequest(new Response(resultValidate.Errors));
|
||||
//var resultValidate = await validator.ValidateAsync(request);
|
||||
//if (!resultValidate.IsValid)
|
||||
// return BadRequest(new Response(resultValidate.Errors));
|
||||
|
||||
var template = await templateService.GetAsync(templateId);
|
||||
|
||||
|
||||
@@ -27,21 +27,21 @@ namespace PARR.API.Controllers.V1
|
||||
private readonly ILogger<TnkController> logger;
|
||||
private readonly IMapper mapper;
|
||||
private readonly ITnkRepository tnkService;
|
||||
private readonly IValidator<TnkRequest> validator;
|
||||
//private readonly IValidator<TnkRequest> validator;
|
||||
private readonly IUriService uriService;
|
||||
|
||||
public TnkController(
|
||||
ILogger<TnkController> logger,
|
||||
IMapper mapper,
|
||||
ITnkRepository tnkService,
|
||||
IValidator<TnkRequest> validator,
|
||||
//IValidator<TnkRequest> validator,
|
||||
IUriService uriService
|
||||
)
|
||||
{
|
||||
this.logger = logger;
|
||||
this.mapper = mapper;
|
||||
this.tnkService = tnkService;
|
||||
this.validator = validator;
|
||||
//this.validator = validator;
|
||||
this.uriService = uriService;
|
||||
}
|
||||
|
||||
@@ -127,9 +127,9 @@ namespace PARR.API.Controllers.V1
|
||||
[HttpPost(ApiRoutes.Tnk.Create)]
|
||||
public async Task<IActionResult> Create([FromBody] TnkRequest request)
|
||||
{
|
||||
var resultValidate = await validator.ValidateAsync(request);
|
||||
if (!resultValidate.IsValid)
|
||||
return BadRequest(new Response(resultValidate.Errors));
|
||||
//var resultValidate = await validator.ValidateAsync(request);
|
||||
//if (!resultValidate.IsValid)
|
||||
// return BadRequest(new Response(resultValidate.Errors));
|
||||
|
||||
var existName = await tnkService.Get().FirstOrDefaultAsync(t => t.Name.ToLower() == request.Name.Trim().ToLower());
|
||||
if (existName != null)
|
||||
@@ -168,9 +168,9 @@ namespace PARR.API.Controllers.V1
|
||||
[HttpPut(ApiRoutes.Tnk.Update)]
|
||||
public async Task<IActionResult> Update([FromRoute] Guid id, [FromBody] TnkRequest request)
|
||||
{
|
||||
var resultValidate = await validator.ValidateAsync(request);
|
||||
if (!resultValidate.IsValid)
|
||||
return BadRequest(new Response(resultValidate.Errors));
|
||||
//var resultValidate = await validator.ValidateAsync(request);
|
||||
//if (!resultValidate.IsValid)
|
||||
// return BadRequest(new Response(resultValidate.Errors));
|
||||
|
||||
////проверка на уникальность esppId
|
||||
//var existEsppId = await tnkService.Get().FirstOrDefaultAsync(t => t.Id != id && t.EsppId == request.EsppId);
|
||||
|
||||
@@ -15,6 +15,7 @@ using PARR.Core.Repositories.Interfaces;
|
||||
using PARR.Domain.Common.Pagination;
|
||||
using PARR.Domain.Common.Roles;
|
||||
using PARR.Domain.Entities;
|
||||
using PARR.Domain.Exceptions;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
@@ -26,21 +27,21 @@ namespace PARR.API.Controllers.V1
|
||||
{
|
||||
private readonly IMapper mapper;
|
||||
private readonly IUserRepository userService;
|
||||
private readonly IValidator<UserRequest> validator;
|
||||
//private readonly IValidator<UserRequest> validator;
|
||||
private readonly IUriService uriService;
|
||||
private readonly ILogger<UserController> logger;
|
||||
|
||||
public UserController(
|
||||
IMapper mapper,
|
||||
IUserRepository userService,
|
||||
IValidator<UserRequest> validator,
|
||||
//IValidator<UserRequest> validator,
|
||||
IUriService uriService,
|
||||
ILogger<UserController> logger
|
||||
)
|
||||
{
|
||||
this.mapper = mapper;
|
||||
this.userService = userService;
|
||||
this.validator = validator;
|
||||
//this.validator = validator;
|
||||
this.uriService = uriService;
|
||||
this.logger = logger;
|
||||
}
|
||||
@@ -122,14 +123,16 @@ namespace PARR.API.Controllers.V1
|
||||
[HttpPost(ApiRoutes.User.Create)]
|
||||
public async Task<IActionResult> Create([FromBody] UserRequest request)
|
||||
{
|
||||
var resultValidate = await validator.ValidateAsync(request);
|
||||
if (!resultValidate.IsValid)
|
||||
return BadRequest(new Response(resultValidate.Errors));
|
||||
//var resultValidate = await validator.ValidateAsync(request);
|
||||
//if (!resultValidate.IsValid)
|
||||
// return BadRequest(new Response(resultValidate.Errors));
|
||||
|
||||
var existIp = await userService.Get().FirstOrDefaultAsync(t => t.Ip == request.Ip);
|
||||
if (existIp != null)
|
||||
//throw new AlreadyExistsException($"Ip {request.Ip} занят другим пользователем.");
|
||||
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { FieldName = nameof(request.Ip), Message = $"Ip {request.Ip} занят другим пользователем." } }));
|
||||
|
||||
|
||||
var user = new User
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
@@ -158,9 +161,9 @@ namespace PARR.API.Controllers.V1
|
||||
[HttpPut(ApiRoutes.User.Update)]
|
||||
public async Task<IActionResult> Update([FromRoute] Guid id, [FromBody] UserRequest request)
|
||||
{
|
||||
var resultValidate = await validator.ValidateAsync(request);
|
||||
if (!resultValidate.IsValid)
|
||||
return BadRequest(new Response(resultValidate.Errors));
|
||||
//var resultValidate = await validator.ValidateAsync(request);
|
||||
//if (!resultValidate.IsValid)
|
||||
// return BadRequest(new Response(resultValidate.Errors));
|
||||
|
||||
var orig = await userService.Get()
|
||||
.Include(t => t.Roles).ThenInclude(t => t.Role)
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace PARR.API.Controllers.V1
|
||||
private readonly IMapper mapper;
|
||||
private readonly IWeekendDayRepository weekendDayService;
|
||||
private readonly IUriService uriService;
|
||||
private readonly IValidator<WeekendRequest> validator;
|
||||
//private readonly IValidator<WeekendRequest> validator;
|
||||
|
||||
public WeekendController(
|
||||
IMapper mapper,
|
||||
@@ -39,7 +39,7 @@ namespace PARR.API.Controllers.V1
|
||||
this.mapper = mapper;
|
||||
this.weekendDayService = weekendDayService;
|
||||
this.uriService = uriService;
|
||||
this.validator = validator;
|
||||
//this.validator = validator;
|
||||
}
|
||||
|
||||
|
||||
@@ -94,9 +94,9 @@ namespace PARR.API.Controllers.V1
|
||||
[HttpPost(ApiRoutes.Weekend.Create)]
|
||||
public async Task<IActionResult> Create([FromBody] WeekendRequest request)
|
||||
{
|
||||
var resultValidate = await validator.ValidateAsync(request);
|
||||
if (!resultValidate.IsValid)
|
||||
return BadRequest(new Response(resultValidate.Errors));
|
||||
//var resultValidate = await validator.ValidateAsync(request);
|
||||
//if (!resultValidate.IsValid)
|
||||
// return BadRequest(new Response(resultValidate.Errors));
|
||||
|
||||
var weekend = new WeekendDay { Id = Guid.NewGuid(), Date = request.WeekendDate };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user