Beispiel #1
0
 public static void RetrieveProducts(this IWeekBasket weekBasket, ApplicationDbContext context)
 {
     foreach (BillEntry billEntry in weekBasket.BillEntries)
     {
         if (billEntry.ProductStock == null)
         {
             billEntry.ProductStock = context.ProductsStocks.Include(x => x.AdherentStolon).Include(x => x.Product).Include(x => x.AdherentStolon.Adherent).AsNoTracking().First(x => x.Id == billEntry.ProductStockId);
         }
     }
 }
        //Calcul du prix total d'un panier
        private Decimal GetBasketPrice(IWeekBasket basket)
        {
            if (basket == null)
            {
                return(0);
            }
            Decimal price = 0;

            foreach (BillEntry entry in basket.BillEntries)
            {
                price += entry.Price;
            }
            return(price);
        }
 //Calcul du prix total d'un panier
 private Decimal GetBasketPrice(IWeekBasket basket)
 {
     if (basket == null)
     {
         return 0;
     }
     Decimal price = 0;
     foreach (BillEntry entry in basket.Products)
     {
         Product product = _context.Products.First(x => x.Id == entry.ProductId);
         price += (product.UnitPrice * entry.Quantity);
     }
     return price;
 }