本文整理汇总了C#中LineItem类的典型用法代码示例。如果您正苦于以下问题:C# LineItem类的具体用法?C# LineItem怎么用?C# LineItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LineItem类属于命名空间,在下文中一共展示了LineItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PopulateFromApi
public virtual void PopulateFromApi(LineItem model)
{
string add1 = null;
string add2 = null;
string city = null;
string state = null;
string postalCode = null;
var response = this.SearchProApi(model);
if ((response != null) && (!response.IsFailure))
{
var bestMatch = response.Results.FirstOrDefault();
if (bestMatch != null)
{
var bestLocation = bestMatch.BestLocation;
if (bestLocation != null)
{
add1 = bestLocation.StandardAddressLine1;
add2 = bestLocation.StandardAddressLine2;
city = bestLocation.City;
state = bestLocation.StateCode;
postalCode = bestLocation.PostalCode;
}
}
}
model.StreetAddress1 = add1;
model.StreetAddress2 = add2;
model.City = city;
model.State = state;
model.PostalCode = postalCode;
}
示例2: Create
public ActionResult Create(LineItem lineitem)
{
lineitem.CartId = ExtentionMethods.GetCartId(this);
if (ModelState.IsValid)
{
var currentLineItem = db.LineItems.AsEnumerable().Where(l => l.Equals(lineitem)).SingleOrDefault();
if (currentLineItem != null)
{
currentLineItem.Quantity++;
db.Entry(currentLineItem).State = EntityState.Modified;
}
else
{
lineitem.Quantity = 1;
db.LineItems.Add(lineitem);
currentLineItem = lineitem;
}
db.SaveChanges();
if (Request.IsAjaxRequest())
{
var lineitems = db.LineItems.Include(l => l.Product).Where(l => l.CartId == lineitem.CartId);
ViewBag.CurrentItem = currentLineItem;
return PartialView("_Cart", lineitems);
}
else
{
return RedirectToAction("Index", "Home");
}
}
else
{
TempData["Notice"] = "Model state is invalid.";
return RedirectToAction("Index", "Home");
}
}
示例3: PopulateVariationInfo
private void PopulateVariationInfo(CatalogEntryDto.CatalogEntryRow entryRow, LineItem lineItem)
{
CatalogEntryDto.VariationRow variationRow = entryRow.GetVariationRows().FirstOrDefault();
if (variationRow != null)
{
lineItem.MaxQuantity = variationRow.MaxQuantity;
lineItem.MinQuantity = variationRow.MinQuantity;
CustomerContact customerContact = CustomerContext.Current.GetContactById(lineItem.Parent.Parent.CustomerId);
Money? newListPrice = GetItemPrice(entryRow, lineItem, customerContact);
if (newListPrice.HasValue)
{
Money oldListPrice = new Money(Math.Round(lineItem.ListPrice, 2), lineItem.Parent.Parent.BillingCurrency);
if (oldListPrice != newListPrice.Value)
{
AddWarningSafe(Warnings,
"LineItemPriceChange-" + lineItem.Parent.LineItems.IndexOf(lineItem).ToString(),
string.Format("Price for \"{0}\" has been changed from {1} to {2}.", lineItem.DisplayName, oldListPrice.ToString(), newListPrice.ToString()));
// Set new price on line item.
lineItem.ListPrice = newListPrice.Value.Amount;
if (lineItem.Parent.Parent.ProviderId.ToLower().Equals("frontend"))
{
lineItem.PlacedPrice = newListPrice.Value.Amount;
}
}
}
}
}
示例4: CanAddItemToOrderAndCalculate
public void CanAddItemToOrderAndCalculate()
{
RequestContext c = new RequestContext();
MerchantTribeApplication app = MerchantTribeApplication.InstantiateForMemory(c);
c.CurrentStore = new Accounts.Store();
c.CurrentStore.Id = 1;
Order target = new Order();
LineItem li = new LineItem() { BasePricePerItem = 19.99m,
ProductName = "Sample Product",
ProductSku = "ABC123",
Quantity = 2 };
target.Items.Add(li);
app.CalculateOrder(target);
Assert.AreEqual(39.98m, target.TotalOrderBeforeDiscounts, "SubTotal was Incorrect");
Assert.AreEqual(39.98m, target.TotalGrand, "Grand Total was incorrect");
bool upsertResult = app.OrderServices.Orders.Upsert(target);
Assert.IsTrue(upsertResult, "Order Upsert Failed");
Assert.AreEqual(c.CurrentStore.Id, target.StoreId, "Order store ID was not set correctly");
Assert.AreNotEqual(string.Empty, target.bvin, "Order failed to get a bvin");
Assert.AreEqual(1, target.Items.Count, "Item count should be one");
Assert.AreEqual(target.bvin, target.Items[0].OrderBvin, "Line item didn't receive order bvin");
Assert.AreEqual(target.StoreId, target.Items[0].StoreId, "Line item didn't recieve storeid");
}
示例5: GetEntryRowForLineItem
/// <summary>
/// Get entry row from a line item
/// </summary>
/// <param name="lineItem">line item</param>
protected static CatalogEntryDto.CatalogEntryRow GetEntryRowForLineItem(LineItem lineItem)
{
var responseGroup = new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.Variations);
CatalogEntryDto entryDto = CatalogContext.Current.GetCatalogEntryDto(lineItem.Code, responseGroup);
return entryDto.CatalogEntry.FirstOrDefault();
}
示例6: GetCartContents
/// <summary>
/// This should return a list of "LineItem" objects for every item in the cart, but I don't yet know how to add items
/// to a cart after creating it, so this method currently will never return success.
/// </summary>
/// <param name="steamId"></param>
/// <returns></returns>
public async Task<List<LineItem>> GetCartContents(long steamId)
{
List<WebRequestParameter> requestParameters = new List<WebRequestParameter>();
WebRequestParameter steamIdParameter = new WebRequestParameter("steamid", steamId.ToString());
requestParameters.Add(steamIdParameter);
// send the request and wait for the response
JObject data = await PerformSteamRequestAsync("ISteamMicroTxn", "GetCartContents", 1, requestParameters);
bool success = TypeHelper.CreateBoolean(data["result"]["success"]);
if (!success)
throw new Exception(E_HTTP_RESPONSE_RESULT_FAILED);
try
{
List<LineItem> lineItems = new List<LineItem>();
foreach (JObject groupObject in data["result"]["lineitems"])
{
LineItem lineItem = new LineItem();
lineItems.Add(lineItem);
}
return lineItems;
}
catch
{
throw new Exception(E_JSON_DESERIALIZATION_FAILED);
}
}
示例7: lineitem_null_description_fails
public void lineitem_null_description_fails()
{
Validator<LineItem> liValidator = new LineItemValidator();
LineItem li = new LineItem();
var results = liValidator.Validate(li);
Assert.Greater(results.Count, 0);
}
示例8: PopulateInventoryInfo
private void PopulateInventoryInfo(InventoryRecord inventoryRecord, LineItem lineItem)
{
lineItem.AllowBackordersAndPreorders = inventoryRecord.BackorderAvailableQuantity > 0 | inventoryRecord.PreorderAvailableUtc > SafeBeginningOfTime;
lineItem.BackorderQuantity = inventoryRecord.BackorderAvailableQuantity;
lineItem.InStockQuantity = inventoryRecord.PurchaseAvailableQuantity + inventoryRecord.AdditionalQuantity;
lineItem.PreorderQuantity = inventoryRecord.PreorderAvailableQuantity;
lineItem.InventoryStatus = inventoryRecord.IsTracked ? 1 : 0;
}
示例9: CheckoutIndex
/// <summary>
/// CTR
/// </summary>
public CheckoutIndex()
{
LineItems = new LineItem[] { };
Countries = new Country[] { };
DeliveryAddress = new CreateOrderRequest.Address();
var url = new UrlHelper(HttpContext.Current.Request.RequestContext);
CheckoutShippingCostsUrl = url.Action(MVC.Store.Checkout.VariableCosts());
}
示例10: DeleteInvalidItem
private static void DeleteInvalidItem(OrderForm[] orderForms, LineItem lineItem)
{
foreach (var form in orderForms)
{
form.RemoveLineItemFromShipments(lineItem);
}
lineItem.Delete();
}
示例11: Add
public void Add(PropertyDescriptor property, PropertyMap map)
{
var index = GetIndex(property.NameId);
var line = _lines[index];
if (line == null)
_lines[index] = line = new LineItem();
line.Property = property;
line.Map = map;
}
示例12: TotalCostTest_promotionAvailable_returnsPromotionCostCalculation
public void TotalCostTest_promotionAvailable_returnsPromotionCostCalculation() {
LineItem lineItem = new LineItem(new Item("Apple"));
lineItem.PricePerUnit = 1.5;
lineItem.Quantity = 2;
Promotion promotion = new QuantityPricePromotion(new Item("Apple"), "[email protected]");
lineItem.Promotion = promotion;
Assert.AreEqual(promotion.GetPromotionAdjustedTotalCost(lineItem), lineItem.TotalCost);
}
示例13: DeleteLineItemFromShipment
private void DeleteLineItemFromShipment(Shipment shipment, LineItem lineItem)
{
var orderForm = OrderGroup.OrderForms.ToArray().Where(of => of.LineItems.ToArray().Contains(lineItem)).FirstOrDefault();
if (orderForm != null)
{
var lineItemIndex = orderForm.LineItems.IndexOf(lineItem);
decimal shipmentQty = Shipment.GetLineItemQuantity(shipment, lineItem.LineItemId);
lineItem.Quantity -= shipmentQty;
shipment.RemoveLineItemIndex(lineItemIndex);
}
}
示例14: CanGetLineTotalWithDiscounts
public void CanGetLineTotalWithDiscounts()
{
LineItem target = new LineItem();
target.BasePricePerItem = 39.99m;
target.DiscountDetails.Add(new Marketing.DiscountDetail(){ Amount = -20.01m});
target.DiscountDetails.Add(new Marketing.DiscountDetail() { Amount = -5m });
Decimal actual = target.LineTotal;
Assert.AreEqual((39.99m - 20.01m - 5m), actual, "Total was not correct.");
}
示例15: GetCustomLineItemDiscountAmount
private decimal GetCustomLineItemDiscountAmount(LineItem lineItem)
{
decimal retVal = 0m;
foreach (LineItemDiscount lineItemDiscount in lineItem.Discounts)
{
if (lineItemDiscount.DiscountName.StartsWith("@"))
{
retVal += lineItemDiscount.DiscountValue;
}
}
return retVal;
}