public Task <int> Count(DocumentPagination p)
        {
            var query = from d in context.Documents select d;

            if (p.From != "")
            {
                var date = DateTime.Parse(p.From);
                query = query.Where(d => d.EmissionDate.Date >= date);
            }
            if (p.To != "")
            {
                var date = DateTime.Parse(p.To);
                query = query.Where(d => d.EmissionDate.Date <= date);
            }
            if (p.State != null)
            {
                query = query.Where(d => d.EmissionState == p.State);
            }

            if (p.Plate != null)
            {
                query = query.Where(d => d.Plate == p.Plate);
            }
            if (p.EmissionPoint != 0)
            {
                query = query.Where(d => d.EmissionPoint.Id == p.EmissionPoint);
            }

            return(query.CountAsync());
        }
Beispiel #2
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 #3
0
        public async Task <IActionResult> Count([FromQuery] DocumentPagination p)
        {
            var count = await documentRepository.Count(p);

            return(Json(new StandardResponse
            {
                Status = 200,
                Data = count
            }));
        }
        public Task <List <Document> > Get(DocumentPagination p)
        {
            // Console.WriteLine($"From: {p.From}");
            // Console.WriteLine($"To: {p.To}");
            // Console.WriteLine($"State: {p.State}");
            // Console.WriteLine($"Plate: {p.Plate}");
            // Console.WriteLine(p.Plate == null);
            // Console.WriteLine(p.State == null);

            var query = from d in context.Documents select d;

            if (p.From != null && p.From != "")
            {
                var date = DateTime.Parse(p.From).Date;
                query = query.Where(d => d.EmissionDate.Date >= date);
            }
            if (p.To != null && p.To != "")
            {
                var date = DateTime.Parse(p.To).Date;
                query = query.Where(d => d.EmissionDate.Date <= date);
            }
            if (p.State != null)
            {
                query = query.Where(d => d.EmissionState == p.State);
            }

            if (p.Plate != null)
            {
                query = query.Where(d => d.Plate == p.Plate);
            }
            if (p.EmissionPoint != 0)
            {
                query = query.Where(d => d.EmissionPoint.Id == p.EmissionPoint);
            }
            if (p.User != 0)
            {
                query = query.Where(d => d.User.Id == p.User);
            }
            if (p.Serie != null)
            {
                query = query.Where(d => d.Serie == p.Serie);
            }
            if (p.Correlative != 0)
            {
                query = query.Where(d => d.Correlative == p.Correlative);
            }

            query = query.Include(d => d.User).Include(d => d.EmissionPoint);

            return(query.ToListAsync());
        }
Beispiel #5
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
            }));
        }