//desde aqui los metodos que voy a utilizar... public async Task <PagedList <CobAdjuntosCobranza> > GetCobAdjuntosCobranza(AdjuntosCobranzaFilter filters) { filters.PageNumber = filters.PageNumber == 0 ? _paginationOptions.DefaultPageNumber : filters.PageNumber; filters.PageSize = filters.PageSize == 0 ? _paginationOptions.DefaultPageSize : filters.PageSize; List <CobAdjuntosCobranza> result = new List <CobAdjuntosCobranza>(); List <CobAdjuntosCobranza> adjuntosCob = await _unitOfWork.CobAdjuntosCobranzaRepository.GetAdjuntoPorDocumento((long)filters.Documento); if (adjuntosCob != null) { result.AddRange(adjuntosCob); } PagedList <CobAdjuntosCobranza> pagedResult = PagedList <CobAdjuntosCobranza> .Create(result, filters.PageNumber, filters.PageSize); return(pagedResult); }
public async Task <IActionResult> GetCobAdjuntosCobranza([FromQuery] AdjuntosCobranzaFilter filters) { var usuario = "rr105841";//User.Identity.Name; await _generalCobranzaService.GeneraRecibo((long)filters.Documento, usuario); PagedList <CobAdjuntosCobranza> cobranzaAdjuntos = await _cobAdjuntosCobranzaService.GetCobAdjuntosCobranza(filters); IEnumerable <CobAdjuntosCobranzaDto> adjuntosCobranzaDto = _mapper.Map <IEnumerable <CobAdjuntosCobranzaDto> >(cobranzaAdjuntos); List <CobAdjuntosCobranzaDto> result = new List <CobAdjuntosCobranzaDto>(); foreach (var item in adjuntosCobranzaDto) { var tipoDocumento = await _ofdTipoDocumentoService.GetById(item.IdTipoDocumento); item.DescripcionTipoDocumento = tipoDocumento.NombreDocumento; result.Add(item); } Metadata metadata = new Metadata { TotalCount = cobranzaAdjuntos.TotalCount, PageSize = cobranzaAdjuntos.PageSize, CurrentPage = cobranzaAdjuntos.CurrentPage, TotalPage = cobranzaAdjuntos.TotalPage, HasNextPage = cobranzaAdjuntos.HasNextPage, HasPreviousPage = cobranzaAdjuntos.HasPreviousPage, NextPageUrl = "", // _uriService.GetGeneralCobranzaPaginationUri(filters, "api/GeneralCobranzas").ToString(), PreviousPageUrl = "" //_uriService.GetGeneralCobranzaPaginationUri(filters, "api/GeneralCobranzas").ToString(), }; //ApiResponse<IEnumerable<CobGeneralCobranzaDto>> response = new ApiResponse<IEnumerable<CobGeneralCobranzaDto>>(generalCobranzasDtos); var response = new ApiResponse <IEnumerable <CobAdjuntosCobranzaDto> >(result) { Meta = metadata }; return(Ok(response)); }
public async Task <IActionResult> GetAllAdjuntosCobranza(AdjuntosCobranzaFilter filters) { List <CobAdjuntosCobranzaDto> result = new List <CobAdjuntosCobranzaDto>(); Metadata metadata = new Metadata { IsValid = false, Message = "", TotalCount = 0 }; _logger.LogWarning("Iniciando Get all Adjubtos del Documento:" + filters.Documento.ToString()); try { var generalCobranza = await _generalCobranzaService.GetGeneralCobranzaPorDocumento((long)filters.Documento); if (generalCobranza.FlagAprobado == false) { var usuario = "RR105841";// User.Identity.Name; await _generalCobranzaService.GeneraRecibo((long)filters.Documento, usuario); } PagedList <CobAdjuntosCobranza> listaAdjuntos; listaAdjuntos = await _cobAdjuntosCobranzaService.GetCobAdjuntosCobranza(filters); IEnumerable <CobAdjuntosCobranzaDto> adjuntosCobranzaDto = _mapper.Map <IEnumerable <CobAdjuntosCobranzaDto> >(listaAdjuntos); foreach (var item in adjuntosCobranzaDto) { var tipoDocumento = await _ofdTipoDocumentoService.GetById(item.IdTipoDocumento); item.DescripcionTipoDocumento = tipoDocumento.NombreDocumento; item.Link = _paginationOptions.UrlGetFiles + item.NombreArchivo; var extencion = Path.GetExtension(item.NombreArchivo); if (extencion.ToLower() == ".pdf") { item.IsImage = false; } else { item.IsImage = true; } result.Add(item); } metadata.IsValid = true; metadata.Message = ""; metadata.TotalCount = listaAdjuntos.TotalCount; metadata.PageSize = listaAdjuntos.PageSize; metadata.CurrentPage = listaAdjuntos.CurrentPage; metadata.TotalPage = listaAdjuntos.TotalPage; metadata.HasNextPage = listaAdjuntos.HasNextPage; metadata.HasPreviousPage = listaAdjuntos.HasPreviousPage; metadata.NextPageUrl = ""; metadata.PreviousPageUrl = ""; _logger.LogWarning("Lista de Adjuntos recuperada corectamente del Documento:" + filters.Documento.ToString()); } catch (Exception e) { metadata.IsValid = false; metadata.Message = e.InnerException.Message; var responseError = new ApiResponse <IEnumerable <CobAdjuntosCobranzaDto> >(result) { Meta = metadata }; _logger.LogError("Return Get all Adjuntos del Documento:" + filters.Documento.ToString() + "Error:" + e.InnerException.Message); return(Ok(responseError)); } result = result.OrderByDescending(x => x.FechaCreacion).ToList(); var response = new ApiResponse <IEnumerable <CobAdjuntosCobranzaDto> >(result) { Meta = metadata }; _logger.LogWarning("Return Get all Adjuntos del Documento:" + filters.Documento.ToString()); return(Ok(response)); }