コード例 #1
0
        public IQueryable <OrderItem> GetAllByOrderId(int orderId)
        {
            var orderItems = (from oi in db.OrderItem.All()
                              join si in Seller.All() on oi.sellerId equals si.id
                              where oi.orderId == orderId
                              select new OrderItem()
            {
                id = oi.id,
                sellerId = oi.sellerId,
                orderId = oi.orderId,
                price = oi.price,
                description = oi.description,
                SellerName = si.name
            });

            return(orderItems.AsQueryable <OrderItem>());
        }
コード例 #2
0
        public List <StartCash> GetAllBySaleId(int id)
        {
            var startingCash = (from sc in db.StartCash.All()
                                join si in Seller.All() on sc.sellerId equals si.id
                                where sc.saleId == id
                                orderby si.name
                                select new StartCash()
            {
                id = sc.id,
                cashAmount = sc.cashAmount,
                saleId = sc.saleId,
                sellerId = sc.sellerId,
                SellerName = si.name
            }).ToList();

            return(startingCash);
        }
コード例 #3
0
ファイル: TotalRepository.cs プロジェクト: gvhung/SaleManager
        public IQueryable <Total> GetTotalsBySaleId(int saleId)
        {
            var saleTotal = (from s in Sale.All()
                             join o in Order.All() on s.id equals o.saleId
                             join oi in OrderItem.All() on o.id equals oi.orderId
                             join se in Seller.All() on oi.sellerId equals se.id
                             where s.endDate == null && o.complete == 1
                             group oi by se.id into g
                             select new
            {
                SaleTotal = g.Sum(e => e.price),
                SellerId = g.Key
            }).ToList();

            var contributeTotal = (from s in Sale.All()
                                   join sc in StartCash.All() on s.id equals sc.saleId
                                   join se in Seller.All() on sc.sellerId equals se.id
                                   where s.endDate == null
                                   group sc by se.id into g
                                   select new
            {
                ContributeTotal = g.Sum(e => e.cashAmount),
                SellerId = g.Key
            }).ToList();

            var sellers = (from se in Seller.All()
                           select se).ToList();

            var total = (from se in sellers
                         join st in saleTotal on se.id equals st.SellerId into h
                         from st in h.DefaultIfEmpty()
                         join sc in contributeTotal on se.id equals sc.SellerId into g
                         from sc in g.DefaultIfEmpty()
                         let a = GetSellerName((int)se.id)
                                 orderby se.name ascending
                                 select new Total()
            {
                name = a,
                startingContribution = sc == null ? 0 : sc.ContributeTotal,
                saleTotal = st == null ? 0 : st.SaleTotal,
                total = (sc == null ? 0 : sc.ContributeTotal) + (st == null ? 0 : st.SaleTotal)
            });

            return(total.AsQueryable());
        }
コード例 #4
0
 public IQueryable <Seller> GetAll()
 {
     return(Seller.All());
 }