コード例 #1
0
        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));
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
 public ActionResult Get()
 {
     return(Ok(
                facturaService.GetAll()
                ));
 }