private static List <OrderOffer> LoadListFromReader(IDataReader reader) { List <OrderOffer> orderOfferList = new List <OrderOffer>(); try { while (reader.Read()) { OrderOffer orderOffer = new OrderOffer(); orderOffer.itemGuid = new Guid(reader["ItemGuid"].ToString()); orderOffer.orderGuid = new Guid(reader["OrderGuid"].ToString()); orderOffer.offerGuid = new Guid(reader["OfferGuid"].ToString()); orderOffer.taxClassGuid = new Guid(reader["TaxClassGuid"].ToString()); orderOffer.offerPrice = Convert.ToDecimal(reader["OfferPrice"], CultureInfo.InvariantCulture); orderOffer.quantity = Convert.ToInt32(reader["Quantity"]); orderOffer.name = reader["Name"].ToString(); orderOfferList.Add(orderOffer); } } finally { reader.Close(); } return(orderOfferList); }
public static Order CreateOrder( Store store, Cart cart, string gatewayRawResponse, string gatewayTransactionId, string gatewayApprovalCode, string currencyCode, string paymentMethod, Guid orderStatusGuid) { Order order = new Order(cart.CartGuid); order.billingAddress1 = cart.OrderInfo.BillingAddress1; order.billingAddress2 = cart.OrderInfo.BillingAddress2; order.billingCity = cart.OrderInfo.BillingCity; order.billingCompany = cart.OrderInfo.BillingCompany; order.billingCountry = cart.OrderInfo.BillingCountry; order.billingFirstName = cart.OrderInfo.BillingFirstName; order.billingLastName = cart.OrderInfo.BillingLastName; order.billingPostalCode = cart.OrderInfo.BillingPostalCode; order.billingState = cart.OrderInfo.BillingState; order.billingSuburb = cart.OrderInfo.BillingSuburb; order.completed = cart.OrderInfo.Completed; order.completedFromIP = cart.OrderInfo.CompletedFromIP; order.created = DateTime.UtcNow; order.createdFromIP = cart.OrderInfo.CompletedFromIP; order.customerAddressLine1 = cart.OrderInfo.CustomerAddressLine1; order.customerAddressLine2 = cart.OrderInfo.CustomerAddressLine2; order.customerCity = cart.OrderInfo.CustomerCity; order.customerCompany = cart.OrderInfo.CustomerCompany; order.customerCountry = cart.OrderInfo.CustomerCountry; order.customerEmail = cart.OrderInfo.CustomerEmail; order.customerEmailVerified = cart.OrderInfo.CustomerEmailVerified; order.customerFirstName = cart.OrderInfo.CustomerFirstName; order.customerLastName = cart.OrderInfo.CustomerLastName; order.customerPostalCode = cart.OrderInfo.CustomerPostalCode; order.customerState = cart.OrderInfo.CustomerState; order.customerSuburb = cart.OrderInfo.CustomerSuburb; order.customerTelephoneDay = cart.OrderInfo.CustomerTelephoneDay; order.customerTelephoneNight = cart.OrderInfo.CustomerTelephoneNight; order.deliveryAddress1 = cart.OrderInfo.DeliveryAddress1; order.deliveryAddress2 = cart.OrderInfo.DeliveryAddress2; order.deliveryCity = cart.OrderInfo.DeliveryCity; order.deliveryCompany = cart.OrderInfo.DeliveryCompany; order.deliveryCountry = cart.OrderInfo.DeliveryCountry; order.deliveryFirstName = cart.OrderInfo.DeliveryFirstName; order.deliveryLastName = cart.OrderInfo.DeliveryLastName; order.deliveryPostalCode = cart.OrderInfo.DeliveryPostalCode; order.deliveryState = cart.OrderInfo.DeliveryState; order.deliverySuburb = cart.OrderInfo.DeliverySuburb; order.gatewayAuthCode = gatewayApprovalCode; order.gatewayRawResponse = gatewayRawResponse; order.gatewayTransID = gatewayTransactionId; order.lastModified = DateTime.UtcNow; order.lastUserActivity = cart.LastUserActivity; order.orderGuid = cart.CartGuid; order.OrderTotal = cart.OrderTotal; order.statusGuid = orderStatusGuid; order.storeGuid = cart.StoreGuid; order.clerkGuid = cart.ClerkGuid; order.subTotal = cart.SubTotal; order.taxTotal = cart.TaxTotal; order.discount = cart.Discount; order.shippingTotal = cart.ShippingTotal; order.taxZoneGuid = cart.OrderInfo.TaxZoneGuid; order.userGuid = cart.UserGuid; order.discountCodesCsv = cart.DiscountCodesCsv; order.customData = cart.CustomData; order.Save(); // TODO: need to add this in insert so we don't have to save 2x order.paymentMethod = paymentMethod; order.Save(); foreach (CartOffer cartOffer in cart.CartOffers) { OrderOffer orderOffer = new OrderOffer(); orderOffer.AddedToCart = cartOffer.AddedToCart; //orderOffer.CurrencyGuid = cartOffer.CurrencyGuid; orderOffer.OfferGuid = cartOffer.OfferGuid; orderOffer.OfferPrice = cartOffer.OfferPrice; orderOffer.OrderGuid = order.OrderGuid; //orderOffer.PriceGuid = cartOffer.PriceGuid; orderOffer.Quantity = cartOffer.Quantity; orderOffer.TaxClassGuid = cartOffer.TaxClassGuid; orderOffer.Save(); Collection<OfferProduct> offerProducts = OfferProduct.GetbyOffer(orderOffer.OfferGuid); foreach (OfferProduct offerProduct in offerProducts) { OrderOfferProduct orderProduct = new OrderOfferProduct(); orderProduct.Created = DateTime.UtcNow; orderProduct.FullfillTermsGuid = offerProduct.FullFillTermsGuid; orderProduct.FullfillType = offerProduct.FullfillType; orderProduct.OfferGuid = offerProduct.OfferGuid; orderProduct.OrderGuid = order.OrderGuid; orderProduct.ProductGuid = offerProduct.ProductGuid; orderProduct.Save(); if ( (offerProduct.FullfillType == (byte)FulfillmentType.Download) && (offerProduct.FullFillTermsGuid != Guid.Empty) ) { // create download fullfillment ticket FullfillDownloadTerms downloadTerms = new FullfillDownloadTerms(offerProduct.FullFillTermsGuid); FullfillDownloadTicket downloadTicket = new FullfillDownloadTicket(); downloadTicket.CountAfterDownload = downloadTerms.CountAfterDownload; downloadTicket.DownloadsAllowed = downloadTerms.DownloadsAllowed; downloadTicket.ExpireAfterDays = downloadTerms.ExpireAfterDays; downloadTicket.FullfillTermsGuid = offerProduct.FullFillTermsGuid; downloadTicket.OrderGuid = order.OrderGuid; downloadTicket.ProductGuid = offerProduct.ProductGuid; downloadTicket.PurchaseTime = order.Completed; downloadTicket.StoreGuid = order.StoreGuid; downloadTicket.UserGuid = order.UserGuid; downloadTicket.Save(); } } } if (order.DiscountCodesCsv.Length > 0) { List<WebStore.Business.Discount> discountList = WebStore.Business.Discount.GetValidDiscounts(store.ModuleGuid, cart, cart.DiscountCodesCsv); foreach (WebStore.Business.Discount d in discountList) { d.UseCount += 1; d.Save(); // TODO: Discount log } } Cart.Delete(cart.CartGuid); return order; }
private static List<OrderOffer> LoadListFromReader(IDataReader reader) { List<OrderOffer> orderOfferList = new List<OrderOffer>(); try { while (reader.Read()) { OrderOffer orderOffer = new OrderOffer(); orderOffer.itemGuid = new Guid(reader["ItemGuid"].ToString()); orderOffer.orderGuid = new Guid(reader["OrderGuid"].ToString()); orderOffer.offerGuid = new Guid(reader["OfferGuid"].ToString()); orderOffer.taxClassGuid = new Guid(reader["TaxClassGuid"].ToString()); orderOffer.offerPrice = Convert.ToDecimal(reader["OfferPrice"], CultureInfo.InvariantCulture); orderOffer.quantity = Convert.ToInt32(reader["Quantity"]); orderOffer.name = reader["Name"].ToString(); orderOfferList.Add(orderOffer); } } finally { reader.Close(); } return orderOfferList; }