Beispiel #1
0
        public async Task <IActionResult> Get([FromQuery] DocumentPagination p)
        {
            var documents = await documentRepository.Get(p);

            var orders = new List <OrderResponse>();

            foreach (Document document in documents)
            {
                var docType     = document.Type;
                var serie       = document.Serie;
                var correlative = document.Correlative;
                var order       = new OrderResponse
                {
                    Document = document,
                    Tax      = await taxRepository.Find(docType, serie, correlative),
                    Detail   = await detailRepository.Find(docType, serie, correlative)
                };
                orders.Add(order);
            }
            ;

            return(Json(new StandardResponse
            {
                Status = 200,
                Data = orders
            }));
        }
Beispiel #2
0
        public async Task <IActionResult> GenerateGeneralReport(DocumentPagination p)
        {
            var documents = await documentRepository.Get(p);

            var orders = new List <OrderResponse>();

            foreach (Document document in documents)
            {
                var docType     = document.Type;
                var serie       = document.Serie;
                var correlative = document.Correlative;
                var order       = new OrderResponse
                {
                    Document = document,
                    Tax      = await taxRepository.Find(docType, serie, correlative),
                    Detail   = await detailRepository.Find(docType, serie, correlative)
                };
                orders.Add(order);
            }
            ;

            var binary = reportService.GenerateOrdersReport(orders);
            // HttpResponseMessage response = new HttpResponseMessage();
            // response.Content = new ByteArrayContent(binary);
            // response.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment");
            // response.Content.Headers.ContentDisposition.FileName = $"Reporte-Ventas-{DateTime.Now.ToString("dd/MM/yyy hh:m:ss")}";
            // response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/vnd.ms-excel");
            // return response;
            var hardcoded = Convert.ToBase64String(binary);

            return(Json(new StandardResponse
            {
                Status = 200,
                Data = hardcoded
            }));
        }