public IActionResult ConsultarPorId([FromBody] ConsultaLiquidacionProcesoPlantaPorIdRequestDTO request) { Guid guid = Guid.NewGuid(); _log.RegistrarEvento($"{guid}{Environment.NewLine}{JsonConvert.SerializeObject(request)}"); ConsultaLiquidacionProcesoPlantaPorIdResponseDTO response = new ConsultaLiquidacionProcesoPlantaPorIdResponseDTO(); try { response.Result.Data = LiquidacionProcesoPlantaService.ConsultarLiquidacionProcesoPlantaPorId(request); response.Result.Success = true; } catch (ResultException ex) { response.Result = new Result() { Success = true, ErrCode = ex.Result.ErrCode, Message = ex.Result.Message }; } catch (Exception ex) { response.Result = new Result() { Success = false, Message = "Ocurrio un problema en el servicio, intentelo nuevamente." }; _log.RegistrarEvento(ex, guid.ToString()); } _log.RegistrarEvento($"{guid}{Environment.NewLine}{JsonConvert.SerializeObject(response)}"); return(Ok(response)); }
public ConsultaLiquidacionProcesoPlantaPorIdBE ConsultarLiquidacionProcesoPlantaPorId(ConsultaLiquidacionProcesoPlantaPorIdRequestDTO request) { ConsultaLiquidacionProcesoPlantaPorIdBE consultaLiquidacionProcesoPlantaPorIdBE = _ILiquidacionProcesoPlantaRepository.ConsultarLiquidacionProcesoPlantaPorId(request.LiquidacionProcesoPlantaId); consultaLiquidacionProcesoPlantaPorIdBE.Preparacion = consultaLiquidacionProcesoPlantaPorIdBE.ProductoTerminado + " - " + consultaLiquidacionProcesoPlantaPorIdBE.SubProductoTerminado + " - " + consultaLiquidacionProcesoPlantaPorIdBE.Calidad; if (consultaLiquidacionProcesoPlantaPorIdBE != null) { consultaLiquidacionProcesoPlantaPorIdBE.Detalle = _ILiquidacionProcesoPlantaRepository.ConsultarLiquidacionProcesoPlantaDetallePorId(request.LiquidacionProcesoPlantaId).ToList(); consultaLiquidacionProcesoPlantaPorIdBE.Resultado = _ILiquidacionProcesoPlantaRepository.ConsultarLiquidacionProcesoPlantaResultadoPorId(request.LiquidacionProcesoPlantaId, request.EmpresaId).ToList(); decimal totalKilosNetos = 0; foreach (ConsultaLiquidacionProcesoPlantaResultadoBE item in consultaLiquidacionProcesoPlantaPorIdBE.Resultado) { totalKilosNetos = totalKilosNetos + item.KilosNetos; } foreach (ConsultaLiquidacionProcesoPlantaResultadoBE item in consultaLiquidacionProcesoPlantaPorIdBE.Resultado) { item.Porcentaje = decimal.Round(((item.KilosNetos / totalKilosNetos) * 100), 2); } List <ConsultaDetalleTablaBE> lista = _IMaestroRepository.ConsultarDetalleTablaDeTablas(consultaLiquidacionProcesoPlantaPorIdBE.EmpresaId, String.Empty).ToList(); string[] certificacionesIds = consultaLiquidacionProcesoPlantaPorIdBE.TipoCertificacionId.Split('|'); string certificacionLabel = string.Empty; if (certificacionesIds.Length > 0) { List <ConsultaDetalleTablaBE> certificaciones = lista.Where(a => a.CodigoTabla.Trim().Equals("TipoCertificacion")).ToList(); foreach (string certificacionId in certificacionesIds) { ConsultaDetalleTablaBE certificacion = certificaciones.Where(a => a.Codigo == certificacionId).FirstOrDefault(); if (certificacion != null) { certificacionLabel = certificacionLabel + certificacion.Label + " "; } } } consultaLiquidacionProcesoPlantaPorIdBE.TipoCertificacion = certificacionLabel; } return(consultaLiquidacionProcesoPlantaPorIdBE); }