Beispiel #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());
 }
Beispiel #2
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());
 }
Beispiel #3
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());
 }