public static BasketShipment Load(Int32 basketShipmentId, bool useCache) { if (basketShipmentId == 0) { return(null); } BasketShipment basketShipment = null; string key = "BasketShipment_" + basketShipmentId.ToString(); if (useCache) { basketShipment = ContextCache.GetObject(key) as BasketShipment; if (basketShipment != null) { return(basketShipment); } } basketShipment = new BasketShipment(); if (basketShipment.Load(basketShipmentId)) { if (useCache) { ContextCache.SetObject(key, basketShipment); } return(basketShipment); } return(null); }
public static bool Delete(Int32 basketShipmentId) { BasketShipment basketShipment = new BasketShipment(); if (basketShipment.Load(basketShipmentId)) { return(basketShipment.Delete()); } return(false); }
/// <summary> /// Combines any shipments in the collection that have equivalent data. /// </summary> /// <param name="save">Flag indicating whether or not to persist changes.</param> /// <remarks>When shipments are combined any items they contain are merged into a single shipment.</remarks> public void Combine(bool save) { WebTrace.Write("Combine Basket Shipments"); for (int i = this.Count - 1; i >= 0; i--) { BasketShipment shipment = this[i]; List <BasketItem> shipmentItems = shipment.Items.FindAll(delegate(BasketItem item) { return(item.BasketShipmentId == shipment.BasketShipmentId); }); if (shipmentItems.Count > 0) { WebTrace.Write("i: " + i.ToString() + ", BasketShipmentId: " + shipment.BasketShipmentId.ToString()); BasketShipment match = this.Find(new System.Predicate <BasketShipment>(shipment.CanCombine)); if ((match != null) && (match.BasketShipmentId != shipment.BasketShipmentId)) { WebTrace.Write("match.BasketShipmentId: " + match.BasketShipmentId.ToString()); //NEED TO MOVE ITEMS FROM THIS SHIPMENT TO THE MATCHED SHIPMENT foreach (BasketItem item in shipmentItems) { item.BasketShipmentId = match.BasketShipmentId; if (save) { item.Save(); } } if (save) { this.DeleteAt(i); } else { removedItems.Add(this[i]); this.RemoveAt(i); } } } else { if (save) { this.DeleteAt(i); } else { removedItems.Add(this[i]); this.RemoveAt(i); } } } this.Save(); }
public static BasketShipmentCollection LoadForWarehouse(Int32 warehouseId, int maximumRows, int startRowIndex, string sortExpression) { //CREATE THE DYNAMIC SQL TO LOAD OBJECT StringBuilder selectQuery = new StringBuilder(); selectQuery.Append("SELECT"); if (maximumRows > 0) { selectQuery.Append(" TOP " + (startRowIndex + maximumRows).ToString()); } selectQuery.Append(" " + BasketShipment.GetColumnNames(string.Empty)); selectQuery.Append(" FROM ac_BasketShipments"); selectQuery.Append(" WHERE WarehouseId = @warehouseId"); if (!string.IsNullOrEmpty(sortExpression)) { selectQuery.Append(" ORDER BY " + sortExpression); } Database database = Token.Instance.Database; DbCommand selectCommand = database.GetSqlStringCommand(selectQuery.ToString()); database.AddInParameter(selectCommand, "@warehouseId", System.Data.DbType.Int32, NullableData.DbNullify(warehouseId)); //EXECUTE THE COMMAND BasketShipmentCollection results = new BasketShipmentCollection(); int thisIndex = 0; int rowCount = 0; using (IDataReader dr = database.ExecuteReader(selectCommand)) { while (dr.Read() && ((maximumRows < 1) || (rowCount < maximumRows))) { if (thisIndex >= startRowIndex) { BasketShipment basketShipment = new BasketShipment(); BasketShipment.LoadDataReader(basketShipment, dr); results.Add(basketShipment); rowCount++; } thisIndex++; } dr.Close(); } return(results); }
/// <summary> /// Transcribes shipping address from the basket to the order /// </summary> /// <param name="bs">Basket shipment object</param> /// <param name="os">Order shipment object</param> private static void RecordShippingAddress(BasketShipment bs, OrderShipment os) { //REMOVAL OF DEMO ENFORCMENT IS A VIOLATION OF THE LICENSE AGREEMENT if (Token.Instance.License.UseDemoMode) { os.ShipToFirstName = "DEMO"; os.ShipToLastName = "DEMO"; os.ShipToCompany = string.Empty; os.ShipToAddress1 = "DEMO"; os.ShipToAddress2 = string.Empty; os.ShipToCity = "DEMO"; os.ShipToProvince = "DEMO"; os.ShipToPostalCode = "DEMO"; os.ShipToCountryCode = "US"; os.ShipToPhone = "000-000-0000"; os.ShipToFax = string.Empty; os.ShipToEmail = string.Empty; os.ShipToResidence = false; } else { Address address = bs.Address; os.ShipToFirstName = address.FirstName; os.ShipToLastName = address.LastName; os.ShipToCompany = address.Company; os.ShipToAddress1 = address.Address1; os.ShipToAddress2 = address.Address2; os.ShipToCity = address.City; os.ShipToProvince = address.Province; os.ShipToPostalCode = address.PostalCode; os.ShipToCountryCode = address.CountryCode; os.ShipToPhone = address.Phone; os.ShipToFax = address.Fax; os.ShipToEmail = address.Email; os.ShipToResidence = address.Residence; } }
/// <summary> /// Indicates whether two shipments have identical origin and destination. /// </summary> /// <param name="other">The item to compare.</param> /// <returns>True if the items have identical origin and destination.</returns> public bool CanCombine(BasketShipment other) { return (this.WarehouseId.Equals(other.WarehouseId) && this.AddressId.Equals(other.AddressId)); }
public static SaveResult Update(BasketShipment basketShipment) { return(basketShipment.Save()); }
public static SaveResult Insert(BasketShipment basketShipment) { return(basketShipment.Save()); }
public static bool Delete(BasketShipment basketShipment) { return(basketShipment.Delete()); }