Exemple #1
0
        public ShoppingList AddToShoppingList(List <Order> orders, int shopperId)
        {
            ShoppingList shoppingList = new ShoppingList();

            shoppingList.CreatedByID = shopperId;
            shoppingList.Shopper     = (Shopper)_contextForShopper.EmployeeSet.FirstOrDefault(x => x is Shopper && x.Id == shopperId);
            shoppingList.DateCreated = DateTime.Now;

            shoppingList.Orders = orders;

            foreach (Order order in orders)
            {
                order.ShoppingList = shoppingList;
                _contextForShopper.Entry(order).State = System.Data.Entity.EntityState.Modified;
            }

            _contextForShopper.SaveChanges();

            _contextForShopper.ShoppingListSet.Add(shoppingList);
            _contextForShopper.Dispose();
            return(shoppingList);
        }
 public void Update(ShoppingList shoppingList)
 {
     throw new NotImplementedException();
 }