Exemple #1
0
        public async Task <IActionResult> DescargarListaRadicado([FromQuery(Name = "mes")] int mes,
                                                                 [FromQuery(Name = "listaEstadoId")] string listaEstadoId,
                                                                 [FromQuery(Name = "terceroId")] int terceroId
                                                                 )
        {
            List <int> listIds        = new List <int>();
            int?       terceroIdTemp  = null;
            string     mesDescripcion = string.Empty;
            string     nombreArchivo  = "Radicados.xlsx";

            try
            {
                valorPciId = User.FindFirst(ClaimTypes.Role).Value;
                if (!string.IsNullOrEmpty(valorPciId))
                {
                    pciId = int.Parse(valorPciId);
                }
                if (mes > 0 && mes < 13)
                {
                    mesDescripcion = _generalInterface.UppercaseFirst(DateTimeFormatInfo.CurrentInfo.GetMonthName(mes));
                    nombreArchivo  = "Radicados_" + mesDescripcion + ".xlsx";
                }
                if (terceroId > 0)
                {
                    terceroIdTemp = terceroId;
                }

                if (listaEstadoId.Length > 0)
                {
                    listIds = listaEstadoId.Split(',').Select(int.Parse).ToList();
                }

                var lista = await _repo.ObtenerListaRadicado(pciId, mes, terceroIdTemp, listIds);

                if (lista != null)
                {
                    DataTable dtResultado = _procesoCreacionExcelInterface.ObtenerTablaDeListaRadicado(lista.ToList());
                    return(_procesoCreacionExcelInterface.ExportExcel(Response, dtResultado, nombreArchivo));
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(BadRequest());
        }