public IActionResult GetAll() { Respuesta _respuesta = new Respuesta(); try { var fact = _facturaService.GetAll(); _respuesta.Datos = fact; _respuesta.Exito = 1; } catch (Exception ex) { _respuesta.Mensaje = ex.ToString(); } return(Ok(_respuesta)); }
public FacturasDto ObtenerFacturas(int pageSize, int page) { try { var t1 = Task.Run(() => _facturaService.GetAll(pageSize, page)); var t2 = Task.Run(() => _facturaService.Count()); Task.WhenAll(t1, t2); var list = t1.Result; var total = t2.Result; //here is where we can use AutoMapper return(new FacturasDto { Facturas = list.Select(m => new FacturaDto { Folio = m.Folio, LugarExpedicion = m.LugarExpedicion, FechaExpedicion = m.FechaExpedicion, RfcEmisor = m.EmisorRfc, RfcReceptor = m.ReceptorRfc, }), Paginacion = new PaginacionDto { CurrrentPage = page, PageSize = pageSize, TotalRecords = total, TotalPages = (int)(total / pageSize) } }); } catch (Exception e) { throw new FaultException(e.InnerException?.Message ?? e.Message); } }
public ActionResult Get() { return(Ok( facturaService.GetAll() )); }