コード例 #1
0
 public static ProductPriceHistoryService GetInstance()
 {
     if (instance == null)
     {
         instance = new ProductPriceHistoryService();
     }
     return(instance);
 }
コード例 #2
0
        public override Product Update(Product item)
        {
            base.Update(item);
            ProductPriceHistoryService.Add(
                new ProductPriceHistory()
            {
                ProductID = item.ID,

                Price     = item.Cost,
                StartDate = DateTime.Now
            }
                );
            return(item);
        }
コード例 #3
0
        public IEnumerable <Order> GetOrdersByUserID(string id)
        {
            var context   = new ApplicationDbContext();
            var resOrders = context.Orders.Where(a => a.UserID == id).Include(b => b.Products);

            foreach (var order in resOrders)
            {
                order.TotalCost2 = 0;
                foreach (var product in order.Products) // orderedProduct
                {
                    order.TotalCost2 += ProductPriceHistoryService.GetProductPriceByDate(product.RealProductID, order.OrderDate) * product.ProductQuantity;
                }
            }
            return(resOrders);
        }