public IActionResult Consultar([FromBody] ConsultaNotaIngresoPlantaRequestDTO request)
        {
            Guid guid = Guid.NewGuid();

            _log.RegistrarEvento($"{guid.ToString()}{Environment.NewLine}{Newtonsoft.Json.JsonConvert.SerializeObject(request)}");

            ConsultaNotaIngresoPlantaResponseDTO response = new ConsultaNotaIngresoPlantaResponseDTO();

            try
            {
                response.Result.Data    = _NotaIngresoPlantaService.ConsultarNotaIngresoPlanta(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.ToString()}{Environment.NewLine}{Newtonsoft.Json.JsonConvert.SerializeObject(response)}");

            return(Ok(response));
        }
        public List <ConsultaNotaIngresoPlantaBE> ConsultarNotaIngresoPlanta(ConsultaNotaIngresoPlantaRequestDTO request)
        {
            if (request.FechaInicio == null || request.FechaInicio == DateTime.MinValue || request.FechaFin == null || request.FechaFin == DateTime.MinValue || string.IsNullOrEmpty(request.EstadoId))
            {
                throw new ResultException(new Result {
                    ErrCode = "01", Message = "Acopio.NotaIngresoPlanta.ValidacionSeleccioneMinimoUnFiltro.Label"
                });
            }

            var timeSpan = request.FechaFin - request.FechaInicio;

            if (timeSpan.Days > 730)
            {
                throw new ResultException(new Result {
                    ErrCode = "02", Message = "Acopio.NotaIngresoPlanta.ValidacionRangoFechaMayor2anios.Label"
                });
            }

            var list = _INotaIngresoPlantaRepository.ConsultarNotaIngresoPlanta(request);

            return(list.ToList());
        }
Beispiel #3
0
        public IEnumerable <ConsultaNotaIngresoPlantaBE> ConsultarNotaIngresoPlanta(ConsultaNotaIngresoPlantaRequestDTO request)
        {
            var parameters = new DynamicParameters();

            parameters.Add("Numero", request.Numero);
            parameters.Add("NumeroGuiaRemision", request.NumeroGuiaRemision);
            parameters.Add("RazonSocialOrganizacion", request.RazonSocialOrganizacion);
            parameters.Add("RucOrganizacion", request.RucOrganizacion);
            parameters.Add("ProductoId", request.ProductoId);
            parameters.Add("MotivoIngresoId", request.MotivoIngresoId);
            parameters.Add("SubProductoId", request.SubProductoId);
            parameters.Add("EstadoId", request.EstadoId);
            parameters.Add("EmpresaId", request.EmpresaId);
            parameters.Add("FechaInicio", request.FechaInicio);
            parameters.Add("FechaFin", request.FechaFin);
            parameters.Add("FechaGuiaRemisionInicio", request.FechaInicio);
            parameters.Add("FechaGuiaRemisionFin", request.FechaFin);


            using (IDbConnection db = new SqlConnection(_connectionString.Value.CoffeeConnectDB))
            {
                return(db.Query <ConsultaNotaIngresoPlantaBE>("uspNotaIngresoPlantaConsulta", parameters, commandType: CommandType.StoredProcedure));
            }
        }