private ShoppingCart CreateShoppingCart(CustomPrincipal user, ClientProfile profile) { var cart = new ShoppingCart( user.UserId, user.AcctgID, profile.ClientGroup, profile.PersonalMarkup ); cart.ContentChanged += OnCartContentChanged; return cart; }
public void Merge( ShoppingCart other ) { if( other == null ) throw new ArgumentNullException( "other" ); using (var context = new DCFactory<StoreDataContext>()) { if( other.GetTotals( context.DataContext ).ItemsCount == 0 ) return; var items = LoadItems( context.DataContext ); foreach( var otherItem in other._storage.LoadItems( context.DataContext ) ) { var key = new ShoppingCartKey( otherItem.Manufacturer, otherItem.PartNumber, otherItem.SupplierID, otherItem.ReferenceID ); if( items.ContainsKey( key ) ) { items[ key ].Qty += otherItem.Qty; //items[ key ].ReferenceID = otherItem.ReferenceID; } else { // deas 28.04.2011 task3929 добавление в корзине флага отправить в заказ items.Add( key, new ShoppingCartItem { AddToOrder = otherItem.AddToOrder, Manufacturer = otherItem.Manufacturer, PartNumber = otherItem.PartNumber, SupplierID = otherItem.SupplierID, DeliveryDaysMin = otherItem.DeliveryDaysMin, DeliveryDaysMax = otherItem.DeliveryDaysMax, PartName = otherItem.PartName, PartDescription = otherItem.PartDescription, Qty = otherItem.Qty, ReferenceID = otherItem.ReferenceID, UnitPrice = otherItem.UnitPrice } ); } } Save( context.DataContext, items.Values ); other.ClearItems( context.DataContext ); } }