コード例 #1
0
 protected override IQuery <Order> ApplyWhereClause(IQuery <Order> query, OrderFilterDto filter)
 {
     return(filter.CompanyId == 0
         ? query
         : query.Where(new SimplePredicate(nameof(Order.CompanyId), ValueComparingOperator.Equal,
                                           filter.CompanyId)));
 }
コード例 #2
0
ファイル: OrderRepository.cs プロジェクト: mg52/ReadingIsGood
        public async Task <List <Order> > GetAllAsync(OrderFilterDto dto)
        {
            var query = _ctx.Orders.Include(x => x.OrderItems).ThenInclude(x => x.Product).Where(x => true);

            if (dto.CustomerId != null && dto.CustomerId != Guid.Empty)
            {
                query = query.Where(x => x.CustomerId == dto.CustomerId);
            }

            var returnValue = await query.ToListAsync();

            return(returnValue);
        }
コード例 #3
0
        private List <OrderDto> orderlist([FromBody] OrderFilterDto filter)
        {
            _context.ChangeTracker.QueryTrackingBehavior
                = Microsoft.EntityFrameworkCore.QueryTrackingBehavior.NoTracking;
            OrderListDto orderListDto = new OrderListDto();
            var          orderList    = (from o in _context.Orders
                                         join i in _context.Invoices on o.InvoiceNumber equals i.InvoiceNumber into oi
                                         from i in oi.DefaultIfEmpty()

                                         join si in _context.ShippingInfo on o.Id equals si.orderId into sio
                                         from si in sio.DefaultIfEmpty()

                                         where o.CardId == filter.userId
                                         //&& (filter.paid != null ? i.Paid == filter.paid : true)
                                         //&& (filter.status != null ? i.Status == filter.status : true)
                                         //&& (filter.start != null ? o.RecordDate >= filter.start : true) && (filter.end != null ? o.RecordDate <= filter.end : true)
                                         //&& (filter.keyword != null ? i.InvoiceNumber.ToString().Contains(filter.keyword) || o.PoNumber.ToString().Contains(filter.keyword) : true)
                                         select new OrderDto
            {
                id = o.Id,
                card_id = o.CardId,
                branch = o.Branch,
                po_number = o.PoNumber,
                status = _isettings.getOrderStatus(Convert.ToInt32(o.Status)),                                                  //o.Status.ToString(),
                invoice_number = o.InvoiceNumber,
                TotalAmount_GstIncl = i.Total,
                TotalAmount_GSTExcl = i.Price,
                GstAmount = i.Tax,
                record_date = o.RecordDate,
                shipto = o.Shipto,
                special_shipto = o.SpecialShipto,
                date_shipped = o.DateShipped,
                freight = o.Freight,
                ticket = o.Ticket,
                shipping_method = o.ShippingMethod,
                payment_type = o.PaymentType,
                paid = _iorder.getOrderPaymentStatus(o.Id),                                                 //o.Paid,
                receiver_name = si.receiver,
                receiver_phone = si.receiver_phone,
                is_web_order = true,
                freightInfo = _iorder.getSupplierShippingInfo(o.Id),
                web_order_status = o.WebOrderStatus
            }).ToList();

            return(orderList);
        }
コード例 #4
0
        public async Task <List <OrderDto> > GetFilteredOrdersAsync(OrderFilterDto filter)
        {
            var orders = this._dbContext.Orders.Include("OrderItems.Product");

            if (filter.TableId.HasValue)
            {
                orders = orders.Where(x => x.TableId == filter.TableId.Value);
            }

            if (filter.OrderDate.HasValue)
            {
                orders = orders.Where(x => x.OrderDate.Date == filter.OrderDate.Value.Date);
            }

            if (filter.IsClosed.HasValue)
            {
                orders = orders.Where(x => x.IsClosed == filter.IsClosed.Value);
            }

            return(await orders.Select(x =>
                                       new OrderDto
            {
                Id = x.Id,
                OrderDate = x.OrderDate,
                TableId = x.TableId,
                IsClosed = x.IsClosed,

                OrderItems = x.OrderItems.Select(item =>
                                                 new OrderItemDto
                {
                    OrderId = x.Id,
                    ProductId = item.ProductId,
                    ProductName = item.Product.Name,
                    Quantity = item.Quantity,
                    Note = item.Note
                }
                                                 ).ToList()
            }
                                       )
                   .OrderByDescending(x => x.OrderDate)
                   .ThenBy(x => x.TableId)
                   .ToListAsync());
        }
コード例 #5
0
        public IActionResult getOrders([FromQuery] int id, [FromQuery] bool?invoiced, [FromQuery] bool?paid, [FromQuery] int?status, [FromQuery] string customer,
                                       [FromQuery] DateTime start, [FromQuery] DateTime end, [FromQuery] string keyword)
        {
            var filter = new OrderFilterDto();

            filter.id       = id;
            filter.inoviced = invoiced;
            filter.paid     = paid;
            filter.status   = status;
            filter.customer = customer;
            if (start != DateTime.MinValue)
            {
                filter.start = start;
            }
            if (end != DateTime.MinValue)
            {
                filter.end = end;
            }
            filter.keyword = keyword;

            var orderList = orderlist(filter);

            return(Ok(orderList));
        }
コード例 #6
0
        private List <OrderDto> orderlist([FromBody] OrderFilterDto filter)
        {
            _context.ChangeTracker.QueryTrackingBehavior
                = Microsoft.EntityFrameworkCore.QueryTrackingBehavior.NoTracking;
            OrderListDto orderListDto = new OrderListDto();
            var          orderList    = (from o in _context.Orders
                                         join i in _context.Invoice on o.InvoiceNumber equals i.InvoiceNumber into oi
                                         from i in oi.DefaultIfEmpty()

                                         join si in _context.ShippingInfo on o.Id equals si.orderId into sio
                                         from si in sio.DefaultIfEmpty()

                                         where o.CardId == filter.id
                                         //&& (filter.paid != null ? i.Paid == filter.paid : true)
                                         //&& (filter.status != null ? i.Status == filter.status : true)
                                         //&& (filter.start != null ? o.RecordDate >= filter.start : true) && (filter.end != null ? o.RecordDate <= filter.end : true)
                                         //&& (filter.keyword != null ? i.InvoiceNumber.ToString().Contains(filter.keyword) || o.PoNumber.ToString().Contains(filter.keyword) : true)
                                         select new OrderDto
            {
                id = o.Id,
                card_id = o.CardId,
                branch = o.Branch,
                po_number = o.PoNumber,
                status = _isettings.getOrderStatus(Convert.ToInt32(o.Status)),                  //o.Status.ToString(),
                invoice_number = o.InvoiceNumber,
                TotalAmount_GstIncl = i.Total,
                TotalAmount_GSTExcl = i.Price,
                GstAmount = i.Tax,
                record_date = o.RecordDate,
                shipto = o.Shipto,
                special_shipto = o.SpecialShipto,
                date_shipped = o.DateShipped,
                freight = o.Freight,
                ticket = o.Ticket,
                shipping_method = o.ShippingMethod,
                payment_type = o.PaymentType,
                paid = _iorder.getOrderPaymentStatus(o.Id),                 //o.Paid,
                receiver_name = si.receiver,
                receiver_phone = si.receiver_phone,
                is_web_order = true,
                freightInfo = _iorder.getSupplierShippingInfo(o.Id),
                web_order_status = o.WebOrderStatus
            }).ToList()
            ;

            //var itemCount = orderList.Count();
            //var pageCount = (int)Math.Ceiling(itemCount / (double)pagination.PageSize);
            //var finalList =
            //        orderList
            //        .Skip((pagination.PageNumber - 1) * pagination.PageSize)
            //        .Take(pagination.PageSize);

            //foreach (var o in orderList)
            //{
            //    try
            //    {
            //        if (o.web_order_status == 0)
            //            o.web_order_status = 1;
            //        o.status = getOrderStatus(o.web_order_status);
            //    }
            //    catch (Exception ex)
            //    {
            //        _logger.LogCritical($"error occur when changing order status!",ex);

            //    }
            //}

            //orderListDto.Orders = finalList;
            //orderListDto.CurrentPage = pagination.PageNumber;
            //orderListDto.PageSize = pagination.PageSize;
            //orderListDto.PageCount = pageCount;
            //orderListDto.ItemCount = itemCount;
            return(orderList);
        }
コード例 #7
0
        public async Task <List <OrderDto> > GetOrders(OrderFilterDto dto)
        {
            var Orders = await _OrderRepository.GetAllAsync(dto);

            return(Orders.Adapt <List <OrderDto> >());
        }
コード例 #8
0
        public async Task <ActionResult <List <OrderDto> > > GetFilteredOrdersAsync(OrderFilterDto filter)
        {
            var orders = await this._dal.GetFilteredOrdersAsync(filter);

            return(Ok(orders));
        }