本文整理汇总了C#中SmartStore.Core.Domain.Orders.Order类的典型用法代码示例。如果您正苦于以下问题:C# Order类的具体用法?C# Order怎么用?C# Order使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Order类属于SmartStore.Core.Domain.Orders命名空间,在下文中一共展示了Order类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PrepareReturnRequestModel
protected SubmitReturnRequestModel PrepareReturnRequestModel(SubmitReturnRequestModel model, Order order)
{
if (order == null)
throw new ArgumentNullException("order");
if (model == null)
throw new ArgumentNullException("model");
model.OrderId = order.Id;
string returnRequestReasons = _orderSettings.GetLocalized(x => x.ReturnRequestReasons, order.CustomerLanguageId, true, false);
string returnRequestActions = _orderSettings.GetLocalized(x => x.ReturnRequestActions, order.CustomerLanguageId, true, false);
//return reasons
foreach (var rrr in returnRequestReasons.SplitSafe(","))
{
model.AvailableReturnReasons.Add(new SelectListItem() { Text = rrr, Value = rrr });
}
//return actions
foreach (var rra in returnRequestActions.SplitSafe(","))
{
model.AvailableReturnActions.Add(new SelectListItem() { Text = rra, Value = rra });
}
//products
var orderItems = _orderService.GetAllOrderItems(order.Id, null, null, null, null, null, null);
foreach (var orderItem in orderItems)
{
var orderItemModel = new SubmitReturnRequestModel.OrderItemModel()
{
Id = orderItem.Id,
ProductId = orderItem.Product.Id,
ProductName = orderItem.Product.GetLocalized(x => x.Name),
ProductSeName = orderItem.Product.GetSeName(),
AttributeInfo = orderItem.AttributeDescription,
Quantity = orderItem.Quantity
};
model.Items.Add(orderItemModel);
//unit price
switch (order.CustomerTaxDisplayType)
{
case TaxDisplayType.ExcludingTax:
{
var unitPriceExclTaxInCustomerCurrency = _currencyService.ConvertCurrency(orderItem.UnitPriceExclTax, order.CurrencyRate);
orderItemModel.UnitPrice = _priceFormatter.FormatPrice(unitPriceExclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, _workContext.WorkingLanguage, false);
}
break;
case TaxDisplayType.IncludingTax:
{
var unitPriceInclTaxInCustomerCurrency = _currencyService.ConvertCurrency(orderItem.UnitPriceInclTax, order.CurrencyRate);
orderItemModel.UnitPrice = _priceFormatter.FormatPrice(unitPriceInclTaxInCustomerCurrency, true, order.CustomerCurrencyCode, _workContext.WorkingLanguage, true);
}
break;
}
}
return model;
}
示例2: DeleteOrder
/// <summary>
/// Deletes an order
/// </summary>
/// <param name="order">The order</param>
public virtual void DeleteOrder(Order order)
{
if (order == null)
throw new ArgumentNullException("order");
order.Deleted = true;
UpdateOrder(order);
}
示例3: AddOrderNote
public virtual void AddOrderNote(Order order, string note, bool displayToCustomer = false)
{
if (order != null && note.HasValue())
{
order.OrderNotes.Add(new OrderNote
{
Note = note,
DisplayToCustomer = displayToCustomer,
CreatedOnUtc = DateTime.UtcNow
});
UpdateOrder(order);
}
}
示例4: CanCompleteOrder
/// <summary>
/// Gets a value indicating whether the order can be marked as completed
/// </summary>
/// <param name="order">Order</param>
/// <returns>A value indicating whether the order can be marked as completed</returns>
public virtual bool CanCompleteOrder(Order order)
{
if (order == null)
throw new ArgumentNullException("order");
return (order.OrderStatus != OrderStatus.Complete && order.OrderStatus != OrderStatus.Cancelled);
}
示例5: Can_save_and_load_order_with_giftCardUsageHistory
public void Can_save_and_load_order_with_giftCardUsageHistory()
{
var testCustomer = GetTestCustomer();
var order = new Order
{
OrderGuid = Guid.NewGuid(),
Customer = testCustomer,
BillingAddress = GetTestBillingAddress(),
CreatedOnUtc = new DateTime(2010, 01, 01)
};
order.GiftCardUsageHistory.Add
(
new GiftCardUsageHistory()
{
UsedValue = 1.1M,
CreatedOnUtc = new DateTime(2010, 01, 01),
GiftCard = GetTestGiftCard()
}
);
var fromDb = SaveAndLoadEntity(order);
fromDb.ShouldNotBeNull();
fromDb.GiftCardUsageHistory.ShouldNotBeNull();
fromDb.GiftCardUsageHistory.Count.ShouldEqual(1);
fromDb.GiftCardUsageHistory.First().CreatedOnUtc.ShouldEqual(new DateTime(2010, 01, 01));
}
示例6: CanRePostProcessPayment
/// <summary>
/// Gets a value indicating whether customers can complete a payment after order is placed but not completed (for redirection payment methods)
/// </summary>
/// <param name="order">Order</param>
/// <returns>Result</returns>
public virtual bool CanRePostProcessPayment(Order order)
{
if (order == null)
throw new ArgumentNullException("order");
if (!_paymentSettings.AllowRePostingPayments)
return false;
var paymentMethod = LoadPaymentMethodBySystemName(order.PaymentMethodSystemName);
if (paymentMethod == null)
return false; //Payment method couldn't be loaded (for example, was uninstalled)
if (paymentMethod.Value.PaymentMethodType != PaymentMethodType.Redirection && paymentMethod.Value.PaymentMethodType != PaymentMethodType.StandardAndRedirection)
return false; //this option is available only for redirection payment methods
if (order.Deleted)
return false; //do not allow for deleted orders
if (order.OrderStatus == OrderStatus.Cancelled)
return false; //do not allow for cancelled orders
if (order.PaymentStatus != PaymentStatus.Pending)
return false; //payment status should be Pending
return paymentMethod.Value.CanRePostProcessPayment(order);
}
示例7: UpdateOrder
/// <summary>
/// Updates the order
/// </summary>
/// <param name="order">The order</param>
public virtual void UpdateOrder(Order order)
{
if (order == null)
throw new ArgumentNullException("order");
order.UpdatedOnUtc = DateTime.UtcNow;
_orderRepository.Update(order);
//event notifications
_eventPublisher.EntityUpdated(order);
_eventPublisher.PublishOrderUpdated(order);
}
示例8: Can_save_and_load_order_with_shipping_address
public void Can_save_and_load_order_with_shipping_address()
{
var order = new Order
{
OrderGuid = Guid.NewGuid(),
Customer = GetTestCustomer(),
BillingAddress = GetTestBillingAddress(),
ShippingAddress = GetTestShippingAddress(),
CreatedOnUtc = new DateTime(2010, 01, 04)
};
var fromDb = SaveAndLoadEntity(order);
fromDb.ShouldNotBeNull();
fromDb.ShippingAddress.ShouldNotBeNull();
fromDb.ShippingAddress.FirstName.ShouldEqual("FirstName 2");
}
示例9: AddOrderTokens
//codehint: sm-add end
public virtual void AddOrderTokens(IList<Token> tokens, Order order, int languageId)
{
tokens.Add(new Token("Order.OrderNumber", order.GetOrderNumber()));
tokens.Add(new Token("Order.CustomerFullName", string.Format("{0} {1}", order.BillingAddress.FirstName, order.BillingAddress.LastName)));
tokens.Add(new Token("Order.CustomerEmail", order.BillingAddress.Email));
tokens.Add(new Token("Order.BillingFirstName", order.BillingAddress.FirstName));
tokens.Add(new Token("Order.BillingLastName", order.BillingAddress.LastName));
tokens.Add(new Token("Order.BillingPhoneNumber", order.BillingAddress.PhoneNumber));
tokens.Add(new Token("Order.BillingEmail", order.BillingAddress.Email));
tokens.Add(new Token("Order.BillingFaxNumber", order.BillingAddress.FaxNumber));
tokens.Add(new Token("Order.BillingCompany", order.BillingAddress.Company));
tokens.Add(new Token("Order.BillingAddress1", order.BillingAddress.Address1));
tokens.Add(new Token("Order.BillingAddress2", order.BillingAddress.Address2));
tokens.Add(new Token("Order.BillingCity", order.BillingAddress.City));
tokens.Add(new Token("Order.BillingStateProvince", order.BillingAddress.StateProvince != null ? order.BillingAddress.StateProvince.GetLocalized(x => x.Name) : ""));
tokens.Add(new Token("Order.BillingZipPostalCode", order.BillingAddress.ZipPostalCode));
tokens.Add(new Token("Order.BillingCountry", order.BillingAddress.Country != null ? order.BillingAddress.Country.GetLocalized(x => x.Name) : ""));
tokens.Add(new Token("Order.ShippingMethod", order.ShippingMethod));
tokens.Add(new Token("Order.ShippingFirstName", order.ShippingAddress != null ? order.ShippingAddress.FirstName : ""));
tokens.Add(new Token("Order.ShippingLastName", order.ShippingAddress != null ? order.ShippingAddress.LastName : ""));
tokens.Add(new Token("Order.ShippingPhoneNumber", order.ShippingAddress != null ? order.ShippingAddress.PhoneNumber : ""));
tokens.Add(new Token("Order.ShippingEmail", order.ShippingAddress != null ? order.ShippingAddress.Email : ""));
tokens.Add(new Token("Order.ShippingFaxNumber", order.ShippingAddress != null ? order.ShippingAddress.FaxNumber : ""));
tokens.Add(new Token("Order.ShippingCompany", order.ShippingAddress != null ? order.ShippingAddress.Company : ""));
tokens.Add(new Token("Order.ShippingAddress1", order.ShippingAddress != null ? order.ShippingAddress.Address1 : ""));
tokens.Add(new Token("Order.ShippingAddress2", order.ShippingAddress != null ? order.ShippingAddress.Address2 : ""));
tokens.Add(new Token("Order.ShippingCity", order.ShippingAddress != null ? order.ShippingAddress.City : ""));
tokens.Add(new Token("Order.ShippingStateProvince", order.ShippingAddress != null && order.ShippingAddress.StateProvince != null ? order.ShippingAddress.StateProvince.GetLocalized(x => x.Name) : ""));
tokens.Add(new Token("Order.ShippingZipPostalCode", order.ShippingAddress != null ? order.ShippingAddress.ZipPostalCode : ""));
tokens.Add(new Token("Order.ShippingCountry", order.ShippingAddress != null && order.ShippingAddress.Country != null ? order.ShippingAddress.Country.GetLocalized(x => x.Name) : ""));
var paymentMethod = _paymentService.LoadPaymentMethodBySystemName(order.PaymentMethodSystemName);
var paymentMethodName = paymentMethod != null ? GetLocalizedValue(paymentMethod.Metadata, "FriendlyName", x => x.FriendlyName) : order.PaymentMethodSystemName;
tokens.Add(new Token("Order.PaymentMethod", paymentMethodName));
tokens.Add(new Token("Order.VatNumber", order.VatNumber));
tokens.Add(new Token("Order.Product(s)", ProductListToHtmlTable(order, languageId), true));
tokens.Add(new Token("Order.CustomerComment", order.CustomerOrderComment, true));
var language = _languageService.GetLanguageById(languageId);
if (language != null && !String.IsNullOrEmpty(language.LanguageCulture))
{
DateTime createdOn = _dateTimeHelper.ConvertToUserTime(order.CreatedOnUtc, TimeZoneInfo.Utc, _dateTimeHelper.GetCustomerTimeZone(order.Customer));
tokens.Add(new Token("Order.CreatedOn", createdOn.ToString("D", new CultureInfo(language.LanguageCulture))));
}
else
{
tokens.Add(new Token("Order.CreatedOn", order.CreatedOnUtc.ToString("D")));
}
//TODO add a method for getting URL (use routing because it handles all SEO friendly URLs)
tokens.Add(new Token("Order.OrderURLForCustomer", string.Format("{0}order/details/{1}", _webHelper.GetStoreLocation(false), order.Id), true));
tokens.Add(new Token("Order.Disclaimer", TopicToHtml("Disclaimer", languageId), true));
tokens.Add(new Token("Order.ConditionsOfUse", TopicToHtml("ConditionsOfUse", languageId), true));
//event notification
_eventPublisher.EntityTokensAdded(order, tokens);
}
示例10: Capture
/// <summary>
/// Capture an order (from admin panel)
/// </summary>
/// <param name="order">Order</param>
/// <returns>A list of errors; empty list if no errors</returns>
public virtual IList<string> Capture(Order order)
{
if (order == null)
throw new ArgumentNullException("order");
if (!CanCapture(order))
throw new SmartException("Cannot do capture for order.");
var request = new CapturePaymentRequest();
CapturePaymentResult result = null;
try
{
//old info from placing order
request.Order = order;
result = _paymentService.Capture(request);
if (result.Success)
{
var paidDate = order.PaidDateUtc;
if (result.NewPaymentStatus == PaymentStatus.Paid)
paidDate = DateTime.UtcNow;
order.CaptureTransactionId = result.CaptureTransactionId;
order.CaptureTransactionResult = result.CaptureTransactionResult;
order.PaymentStatus = result.NewPaymentStatus;
order.PaidDateUtc = paidDate;
_orderService.UpdateOrder(order);
//add a note
order.OrderNotes.Add(new OrderNote()
{
Note = T("OrderCaptured"),
DisplayToCustomer = false,
CreatedOnUtc = DateTime.UtcNow
});
_orderService.UpdateOrder(order);
CheckOrderStatus(order);
//raise event
if (order.PaymentStatus == PaymentStatus.Paid)
{
_eventPublisher.PublishOrderPaid(order);
}
}
}
catch (Exception exc)
{
if (result == null)
result = new CapturePaymentResult();
result.AddError(string.Format("Error: {0}. Full exception: {1}", exc.Message, exc.ToString()));
}
//process errors
string error = "";
for (int i = 0; i < result.Errors.Count; i++)
{
error += string.Format("Error {0}: {1}", i, result.Errors[i]);
if (i != result.Errors.Count - 1)
error += ". ";
}
if (!String.IsNullOrEmpty(error))
{
//add a note
order.OrderNotes.Add(new OrderNote()
{
Note = string.Format("Unable to capture order. {0}", error),
DisplayToCustomer = false,
CreatedOnUtc = DateTime.UtcNow
});
_orderService.UpdateOrder(order);
//log it
string logError = string.Format(T("OrderCaptureError"), order.GetOrderNumber(), error);
_logger.InsertLog(LogLevel.Error, logError, logError);
}
return result.Errors;
}
示例11: Can_save_and_load_order_with_shipments
public void Can_save_and_load_order_with_shipments()
{
var order = new Order
{
OrderGuid = Guid.NewGuid(),
Customer = GetTestCustomer(),
BillingAddress = GetTestBillingAddress(),
CreatedOnUtc = new DateTime(2010, 01, 01)
};
order.Shipments.Add
(
new Shipment()
{
TrackingNumber = "TrackingNumber 1",
ShippedDateUtc = new DateTime(2010, 01, 01),
DeliveryDateUtc = new DateTime(2010, 01, 02),
CreatedOnUtc = new DateTime(2010, 01, 03),
}
);
var fromDb = SaveAndLoadEntity(order);
fromDb.ShouldNotBeNull();
fromDb.Shipments.ShouldNotBeNull();
fromDb.Shipments.Count.ShouldEqual(1);
fromDb.Shipments.First().TrackingNumber.ShouldEqual("TrackingNumber 1");
}
示例12: CanRefund
/// <summary>
/// Gets a value indicating whether refund from admin panel is allowed
/// </summary>
/// <param name="order">Order</param>
/// <returns>A value indicating whether refund from admin panel is allowed</returns>
public virtual bool CanRefund(Order order)
{
if (order == null)
throw new ArgumentNullException("order");
if (order.OrderTotal == decimal.Zero)
return false;
//uncomment the lines below in order to allow this operation for cancelled orders
//if (order.OrderStatus == OrderStatus.Cancelled)
// return false;
if (order.PaymentStatus == PaymentStatus.Paid &&
_paymentService.SupportRefund(order.PaymentMethodSystemName))
return true;
return false;
}
示例13: CanVoidOffline
/// <summary>
/// Gets a value indicating whether order can be marked as voided
/// </summary>
/// <param name="order">Order</param>
/// <returns>A value indicating whether order can be marked as voided</returns>
public virtual bool CanVoidOffline(Order order)
{
if (order == null)
throw new ArgumentNullException("order");
if (order.OrderTotal == decimal.Zero)
return false;
//uncomment the lines below in order to allow this operation for cancelled orders
//if (order.OrderStatus == OrderStatus.Cancelled)
// return false;
if (order.PaymentStatus == PaymentStatus.Authorized)
return true;
return false;
}
示例14: CanPartiallyRefundOffline
/// <summary>
/// Gets a value indicating whether order can be marked as partially refunded
/// </summary>
/// <param name="order">Order</param>
/// <param name="amountToRefund">Amount to refund</param>
/// <returns>A value indicating whether order can be marked as partially refunded</returns>
public virtual bool CanPartiallyRefundOffline(Order order, decimal amountToRefund)
{
if (order == null)
throw new ArgumentNullException("order");
if (order.OrderTotal == decimal.Zero)
return false;
//uncomment the lines below in order to allow this operation for cancelled orders
//if (order.OrderStatus == OrderStatus.Cancelled)
// return false;
decimal canBeRefunded = order.OrderTotal - order.RefundedAmount;
if (canBeRefunded <= decimal.Zero)
return false;
if (amountToRefund > canBeRefunded)
return false;
if (order.PaymentStatus == PaymentStatus.Paid ||
order.PaymentStatus == PaymentStatus.PartiallyRefunded)
return true;
return false;
}
示例15: CanMarkOrderAsPaid
/// <summary>
/// Gets a value indicating whether order can be marked as paid
/// </summary>
/// <param name="order">Order</param>
/// <returns>A value indicating whether order can be marked as paid</returns>
public virtual bool CanMarkOrderAsPaid(Order order)
{
if (order == null)
throw new ArgumentNullException("order");
if (order.OrderStatus == OrderStatus.Cancelled)
return false;
if (order.PaymentStatus == PaymentStatus.Paid ||
order.PaymentStatus == PaymentStatus.Refunded ||
order.PaymentStatus == PaymentStatus.Voided)
return false;
return true;
}