feat: corrigindo erro
This commit is contained in:
parent
d4ec1f72a6
commit
d37ea0c377
|
|
@ -49,7 +49,7 @@ namespace line_gestao_api.Controllers
|
||||||
var normalizedConta = NormalizeContaValue(conta);
|
var normalizedConta = NormalizeContaValue(conta);
|
||||||
if (string.IsNullOrWhiteSpace(normalizedConta)) return null;
|
if (string.IsNullOrWhiteSpace(normalizedConta)) return null;
|
||||||
|
|
||||||
return AccountCompanies
|
return OperadoraContaResolver.GetAccountCompanies()
|
||||||
.FirstOrDefault(group => group.Contas.Any(c => NormalizeContaValue(c) == normalizedConta))
|
.FirstOrDefault(group => group.Contas.Any(c => NormalizeContaValue(c) == normalizedConta))
|
||||||
?.Empresa;
|
?.Empresa;
|
||||||
}
|
}
|
||||||
|
|
@ -530,9 +530,9 @@ namespace line_gestao_api.Controllers
|
||||||
Cliente = clienteExibicao,
|
Cliente = clienteExibicao,
|
||||||
line.Usuario,
|
line.Usuario,
|
||||||
line.CentroDeCustos,
|
line.CentroDeCustos,
|
||||||
SetorNome = line.Setor != null ? line.Setor.Nome : null,
|
SetorNome = line.Setor != null ? line.Setor!.Nome : null,
|
||||||
AparelhoNome = line.Aparelho != null ? line.Aparelho.Nome : null,
|
AparelhoNome = line.Aparelho != null ? line.Aparelho!.Nome : null,
|
||||||
AparelhoCor = line.Aparelho != null ? line.Aparelho.Cor : null,
|
AparelhoCor = line.Aparelho != null ? line.Aparelho!.Cor : null,
|
||||||
line.PlanoContrato,
|
line.PlanoContrato,
|
||||||
line.Status,
|
line.Status,
|
||||||
line.Skil,
|
line.Skil,
|
||||||
|
|
@ -1337,21 +1337,24 @@ namespace line_gestao_api.Controllers
|
||||||
// ==========================================================
|
// ==========================================================
|
||||||
[HttpPost("batch-status-update")]
|
[HttpPost("batch-status-update")]
|
||||||
[Authorize(Roles = "sysadmin,gestor")]
|
[Authorize(Roles = "sysadmin,gestor")]
|
||||||
public async Task<ActionResult<BatchLineStatusUpdateResultDto>> BatchStatusUpdate([FromBody] BatchLineStatusUpdateRequestDto req)
|
public async Task<ActionResult<BatchLineStatusUpdateResultDto>> BatchStatusUpdate([FromBody] BatchLineStatusUpdateRequestDto? req)
|
||||||
{
|
{
|
||||||
var action = (req?.Action ?? "").Trim().ToLowerInvariant();
|
if (req is null)
|
||||||
|
return BadRequest(new { message = "Payload inválido para processamento em lote." });
|
||||||
|
|
||||||
|
var action = (req.Action ?? "").Trim().ToLowerInvariant();
|
||||||
var isBlockAction = action is "block" or "bloquear";
|
var isBlockAction = action is "block" or "bloquear";
|
||||||
var isUnblockAction = action is "unblock" or "desbloquear";
|
var isUnblockAction = action is "unblock" or "desbloquear";
|
||||||
|
|
||||||
if (!isBlockAction && !isUnblockAction)
|
if (!isBlockAction && !isUnblockAction)
|
||||||
return BadRequest(new { message = "Ação inválida. Use 'block' ou 'unblock'." });
|
return BadRequest(new { message = "Ação inválida. Use 'block' ou 'unblock'." });
|
||||||
|
|
||||||
var blockStatus = NormalizeOptionalText(req?.BlockStatus);
|
var blockStatus = NormalizeOptionalText(req.BlockStatus);
|
||||||
if (isBlockAction && string.IsNullOrWhiteSpace(blockStatus))
|
if (isBlockAction && string.IsNullOrWhiteSpace(blockStatus))
|
||||||
return BadRequest(new { message = "Informe o tipo de bloqueio para bloqueio em lote." });
|
return BadRequest(new { message = "Informe o tipo de bloqueio para bloqueio em lote." });
|
||||||
|
|
||||||
var applyToAllFiltered = req?.ApplyToAllFiltered ?? false;
|
var applyToAllFiltered = req.ApplyToAllFiltered;
|
||||||
var ids = (req?.LineIds ?? new List<Guid>())
|
var ids = (req.LineIds ?? new List<Guid>())
|
||||||
.Where(x => x != Guid.Empty)
|
.Where(x => x != Guid.Empty)
|
||||||
.Distinct()
|
.Distinct()
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
@ -1378,7 +1381,7 @@ namespace line_gestao_api.Controllers
|
||||||
baseQuery = _db.MobileLines.Where(x => ids.Contains(x.Id));
|
baseQuery = _db.MobileLines.Where(x => ids.Contains(x.Id));
|
||||||
}
|
}
|
||||||
|
|
||||||
var userFilter = (req?.Usuario ?? "").Trim();
|
var userFilter = (req.Usuario ?? "").Trim();
|
||||||
if (!applyToAllFiltered && !string.IsNullOrWhiteSpace(userFilter))
|
if (!applyToAllFiltered && !string.IsNullOrWhiteSpace(userFilter))
|
||||||
{
|
{
|
||||||
baseQuery = baseQuery.Where(x => EF.Functions.ILike(x.Usuario ?? "", $"%{userFilter}%"));
|
baseQuery = baseQuery.Where(x => EF.Functions.ILike(x.Usuario ?? "", $"%{userFilter}%"));
|
||||||
|
|
@ -5353,7 +5356,7 @@ namespace line_gestao_api.Controllers
|
||||||
|
|
||||||
private static void ApplyBlockedLineToReservaContext(MobileLine line)
|
private static void ApplyBlockedLineToReservaContext(MobileLine line)
|
||||||
{
|
{
|
||||||
if (!ShouldAutoMoveBlockedLineToReserva(line?.Status)) return;
|
if (!ShouldAutoMoveBlockedLineToReserva(line.Status)) return;
|
||||||
line.Usuario = "RESERVA";
|
line.Usuario = "RESERVA";
|
||||||
line.Skil = "RESERVA";
|
line.Skil = "RESERVA";
|
||||||
if (string.IsNullOrWhiteSpace(line.Cliente))
|
if (string.IsNullOrWhiteSpace(line.Cliente))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue