Esempio n. 1
0
 public IEnumerable <CartItemListModel> GetCartItemListByUser(int userId)
 {
     return((from cartItemList in HuahuiDbContext.CartItemList
             join cartJoin in HuahuiDbContext.Cart.Where(w => w.UserId.Equals(userId) && w.IsActive.Equals(true)) on cartItemList.CardId equals cartJoin.Id into CartItemListJoinCart
             from cart in CartItemListJoinCart
             join productJoin in HuahuiDbContext.Product on cartItemList.ProductId equals productJoin.Id into CartItemListJoinProduct
             from product in CartItemListJoinProduct.DefaultIfEmpty()
             join productGroupJoin in HuahuiDbContext.ProductGroup on product.ProductGroupCode equals productGroupJoin.Code into ProductJoinProductGroup
             from productGroup in ProductJoinProductGroup.DefaultIfEmpty()
             select new CartItemListModel
     {
         Id = cartItemList.Id,
         CardId = cartItemList.CardId,
         ProductId = cartItemList.ProductId,
         Quantity = cartItemList.Quantity,
         TotalPrice = cartItemList.TotalPrice,
         CreatedDateTime = cartItemList.CreatedDateTime,
         ProductName = product.Name,
         ProductGroupCode = product.ProductGroupCode,
         UnitPrice = productGroup.UnitPrice,
         PromotionPrice = productGroup.PromotionPrice.Value,
         MinQuantity = productGroup.MinQuantity,
         MaxQuantity = productGroup.MaxQuantity,
         IsPromotion = product.IsPromotion,
         PictureFileName = product.PictureFileName
     }).GroupBy(g => g.Id).Select(s => s.First()).ToList());
 }
Esempio n. 2
0
 public IEnumerable <OrderItemListModel> GetOrderItemListDataByOrderId(string orderId)
 {
     return((from orderItemList in HuahuiDbContext.OrderItemList.Where(w => w.OrderId.Equals(orderId))
             join orderJoin in HuahuiDbContext.Order on orderItemList.OrderId equals orderJoin.Id into OrderItemListJoinOrder
             from order in OrderItemListJoinOrder.DefaultIfEmpty()
             join customerJoin in HuahuiDbContext.Customer on order.UserId equals customerJoin.Id into OrderJoinCustomer
             from customer in OrderJoinCustomer.DefaultIfEmpty()
             join saleJoin in HuahuiDbContext.Sale on customer.SaleId equals saleJoin.Id into CustomerJoinSale
             from sale in CustomerJoinSale.DefaultIfEmpty()
             join productJoin in HuahuiDbContext.Product on orderItemList.ProductId equals productJoin.Id into OrderItemListJoinProduct
             from product in OrderItemListJoinProduct.DefaultIfEmpty()
             join productGroupJoin in HuahuiDbContext.ProductGroup on product.ProductGroupCode equals productGroupJoin.Code into ProductJoinProductGroup
             from productGroup in ProductJoinProductGroup.DefaultIfEmpty()
             select new OrderItemListModel
     {
         Id = orderItemList.Id,
         OrderId = orderItemList.OrderId,
         ProductId = orderItemList.ProductId,
         Quantity = orderItemList.Quantity,
         TotalPrice = orderItemList.TotalPrice,
         CreatedDateTime = orderItemList.CreatedDateTime,
         ProductName = product.Name,
         IsPromotion = product.IsPromotion,
         ProductGroupCode = product.ProductGroupCode,
         UnitPrice = productGroup.UnitPrice,
         PictureFileName = product.PictureFileName,
         CustomerName = customer.Firstname + " " + customer.Lastname,
         CustomerAddress = customer.Address,
         CustomerPhoneNumber = customer.PhoneNumber,
         SaleName = sale.Firstname + " " + sale.Lastname
     }).GroupBy(g => g.Id).Select(s => s.First()).ToList());
 }
Esempio n. 3
0
 public IEnumerable <CartItemListModel> GetCartItemList()
 {
     return((from cartItemList in HuahuiDbContext.CartItemList
             join productJoin in HuahuiDbContext.Product on cartItemList.ProductId equals productJoin.Id into CartItemListJoinProduct
             from product in CartItemListJoinProduct.DefaultIfEmpty()
             join productGroupJoin in HuahuiDbContext.ProductGroup on product.ProductGroupCode equals productGroupJoin.Code into ProductJoinProductGroup
             from productGroup in ProductJoinProductGroup.DefaultIfEmpty()
             select new CartItemListModel
     {
         Id = cartItemList.Id,
         CardId = cartItemList.CardId,
         ProductId = cartItemList.ProductId,
         Quantity = cartItemList.Quantity,
         TotalPrice = cartItemList.TotalPrice,
         CreatedDateTime = cartItemList.CreatedDateTime,
         ProductName = product.Name,
         ProductGroupCode = product.ProductGroupCode,
         IsPromotion = product.IsPromotion,
         PictureFileName = product.PictureFileName,
         UnitPrice = productGroup.UnitPrice
     }).GroupBy(g => g.Id).Select(s => s.First()).ToList());
 }
Esempio n. 4
0
 public IEnumerable <CartItemListModel> GetCompleteOrderItemListData()
 {
     return((from cartItemList in HuahuiDbContext.CartItemList
             join cartJoin in HuahuiDbContext.Cart.Where(w => w.Status.Equals("Approve")) on cartItemList.CardId equals cartJoin.Id into CartItemListJoinCart
             from cart in CartItemListJoinCart.DefaultIfEmpty()
             join productJoin in HuahuiDbContext.Product on cartItemList.ProductId equals productJoin.Id into CartItemListJoinProduct
             from product in CartItemListJoinProduct.DefaultIfEmpty()
             join productGroupJoin in HuahuiDbContext.ProductGroup on product.ProductGroupCode equals productGroupJoin.Code into ProductJoinProductGroup
             from productGroup in ProductJoinProductGroup.DefaultIfEmpty()
             select new CartItemListModel
     {
         Id = cartItemList.Id,
         OrderId = cart.OrderId,
         ProductId = cartItemList.ProductId,
         Quantity = cartItemList.Quantity,
         TotalPrice = cartItemList.TotalPrice,
         CreatedDateTime = cartItemList.CreatedDateTime,
         ProductName = product.Name,
         UnitPrice = productGroup.UnitPrice,
         PictureFileName = product.PictureFileName
     }).GroupBy(g => g.Id).Select(s => s.First()).ToList());
 }