public IActionResult ConsultarSocioFincaEstimadoPorSocioFincaId([FromBody] ConsultaSocioFincaEstimadoPorSocioFincaIdRequest request)
        {
            Guid guid = Guid.NewGuid();

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

            ConsultaSocioFincaEstimadoPorSocioFincaIdResponseDTO response = new ConsultaSocioFincaEstimadoPorSocioFincaIdResponseDTO();

            try
            {
                response.Result.Data = _socioFincaService.ConsultarSocioFincaEstimadoPorSocioFincaId(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));
        }
Example #2
0
        public ConsultaSocioFincaEstimadoPorSocioFincaIdBE ConsultarSocioFincaEstimadoPorSocioFincaId(ConsultaSocioFincaEstimadoPorSocioFincaIdRequest request)
        {
            List <ConsultaSocioFincaEstimadoPorSocioFincaIdBE> fincaEstimados = _ISocioFincaRepository.ConsultarSocioFincaEstimadoPorSocioFincaId(request.SocioFincaId).ToList();

            ConsultaSocioFincaEstimadoPorSocioFincaIdBE fincaEstima = null;

            if (fincaEstimados.Count > 0)
            {
                int anioActual = DateTime.Now.Year;

                fincaEstima = fincaEstimados.Where(x => x.Anio == anioActual).FirstOrDefault();
                if (fincaEstima != null)
                {
                    fincaEstima.SaldoPendiente = fincaEstima.Estimado - fincaEstima.Consumido;
                }
            }
            return(fincaEstima);
        }