public static ProductPriceHistoryService GetInstance() { if (instance == null) { instance = new ProductPriceHistoryService(); } return(instance); }
public override Product Update(Product item) { base.Update(item); ProductPriceHistoryService.Add( new ProductPriceHistory() { ProductID = item.ID, Price = item.Cost, StartDate = DateTime.Now } ); return(item); }
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); }