本文整理汇总了C#中Order.Total方法的典型用法代码示例。如果您正苦于以下问题:C# Order.Total方法的具体用法?C# Order.Total怎么用?C# Order.Total使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Order
的用法示例。
在下文中一共展示了Order.Total方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenderateRandomOrder
/// <summary>
/// Generate Random orders
/// </summary>
/// <param name="users">List of users to select from</param>
/// <param name="vendors">List of vendors to select from</param>
/// <param name="statusCode">Status code to set the order approved through</param>
/// <returns></returns>
private static Order GenderateRandomOrder(Workgroup workgroup, OrderStatusCode statusCode, ISession session, WorkgroupPermission user = null, WorkgroupPermission excludeUser = null )
{
var randomizedPerms = workgroup.Permissions.Select(a => new {Permission = a, Key = Guid.NewGuid()});
var requester = user ?? (excludeUser == null ?
randomizedPerms.Where(a=>a.Permission.Role.Id == "RQ").OrderBy(a => a.Key).Select(a => a.Permission).FirstOrDefault()
: randomizedPerms.Where(a=>a.Permission.Role.Id == "RQ" && a.Permission != excludeUser).OrderBy(a => a.Key).Select(a => a.Permission).FirstOrDefault());
var approver = randomizedPerms.Where(a => a.Permission.Role.Id == "AP" && a.Permission.User.Id !="zoidberg").OrderBy(a => a.Key).Select(a => a.Permission).FirstOrDefault();
var conditionalApprover = session.Load<User>("zoidberg"); //workgroup.Permissions.Where(a => a.User.Id == "zoidberg").FirstOrDefault();
var accountmgr = randomizedPerms.Where(a => a.Permission.Role.Id == "AM").OrderBy(a => a.Key).Select(a => a.Permission).FirstOrDefault();
var purchaser = randomizedPerms.Where(a => a.Permission.Role.Id == "PR").OrderBy(a => a.Key).Select(a => a.Permission).FirstOrDefault();
var order = new Order()
{
Justification = _justifications.Skip(_random.Next() % 5).Take(1).FirstOrDefault(),
OrderType = session.Load<OrderType>("OR"),
Workgroup = workgroup,
Organization = workgroup.PrimaryOrganization,
Vendor = workgroup.Vendors.Skip(_random.Next() % workgroup.Vendors.Count).Take(1).FirstOrDefault(),
Address = workgroup.Addresses.Skip(_random.Next() % workgroup.Addresses.Count).Take(1).FirstOrDefault(),
ShippingType = session.QueryOver<ShippingType>().Skip(_random.Next() % 3).Take(1).SingleOrDefault(),
DeliverTo = "Mr. Smith",
DateNeeded = DateTime.Now.AddDays(_random.Next() % 30),
AllowBackorder = _random.Next() % 2 == 1,
EstimatedTax = 8.89m,
CreatedBy = requester.User,
StatusCode = statusCode
};
order.GenerateRequestNumber();
// add the tracking
order.AddApproval(new Approval() { StatusCode = session.Load<OrderStatusCode>("RQ"), Completed = true, User = requester.User });
order.AddApproval(new Approval() { StatusCode = session.Load<OrderStatusCode>("AP"), Completed = statusCode.Level > 2 , User = approver.User });
order.AddApproval(new Approval() { StatusCode = session.Load<OrderStatusCode>("AM"), Completed = statusCode.Level > 3 , User = accountmgr.User });
order.AddApproval(new Approval() { StatusCode = session.Load<OrderStatusCode>("PR"), Completed = statusCode.Level > 4 , User = purchaser.User });
// add the approvals
var daysBack = ((-1)*(_random.Next()%10)) - 10;
order.AddTracking(new OrderTracking() { User = requester.User, DateCreated = DateTime.Now.AddDays(daysBack), Description = "Order submitted by " + requester.User.FullName, StatusCode = session.Load<OrderStatusCode>("RQ") });
if (statusCode.Level > 2)
{
order.AddTracking(new OrderTracking() { User = approver.User, DateCreated = DateTime.Now.AddDays(daysBack + 1), Description = "Order reviewed by " + approver.User.FullName, StatusCode = session.Load<OrderStatusCode>("AP") });
}
if (statusCode.Level > 3)
{
order.AddTracking(new OrderTracking() { User = accountmgr.User, DateCreated = DateTime.Now.AddDays(daysBack + 3), Description = "Order reviewed by " + accountmgr.User.FullName, StatusCode = session.Load<OrderStatusCode>("AM") });
}
if (statusCode.Level > 4)
{
order.AddTracking(new OrderTracking() { User = purchaser.User, DateCreated = DateTime.Now.AddDays(daysBack + (_random.Next() % 4)+3), Description = "Order reviewed by " + purchaser.User.FullName, StatusCode = session.Load<OrderStatusCode>("PR") });
order.AddTracking(new OrderTracking() { User = purchaser.User, DateCreated = DateTime.Now.AddDays(daysBack + (_random.Next() % 4)+8), Description = "Order marked complete by " + purchaser.User.FullName, StatusCode = session.Load<OrderStatusCode>("CN") });
}
// add the conditional stuff if we feel like it
if (_random.Next() % 2 == 1)
{
order.AddApproval(new Approval() { StatusCode = session.Load<OrderStatusCode>("CA"), Completed = statusCode.Level > 2 , User = conditionalApprover });
if (statusCode.Level > 2)
{
order.AddTracking(new OrderTracking() { User = conditionalApprover, DateCreated = DateTime.Now.AddDays(daysBack + 2), Description = "Order reviewed by " + conditionalApprover.FullName, StatusCode = session.Load<OrderStatusCode>("AP") });
}
}
// add the line items
var numLineItems = (_random.Next()%5) + 1; // minimum of 1 line item
for (var i = 0; i < numLineItems; i++)
{
var item = _items.Skip(_random.Next()%_items.Count()).Take(1).FirstOrDefault();
order.AddLineItem(new LineItem() { Quantity = _random.Next() % 10, UnitPrice = item.Value + (item.Value * ((_random.Next() % 10)+1 / 10)), Unit = "each", Description = item.Key });
}
// account information
var splitType = _random.Next()%2;
if (splitType == 1) {
var numSplits = _random.Next()%2;
var skip = _random.Next()%18;
var accounts = session.QueryOver<Account>().Skip(skip+numSplits>=18 ? 18-numSplits : skip).Take(numSplits);
foreach (var act in accounts.List())
{
order.AddSplit(new Split(){Account = act.Id, Amount = order.Total()/numSplits});
}
}
// set shipping
//.........这里部分代码省略.........
示例2: BindOrderModel
//.........这里部分代码省略.........
EndUser = model.Restricted.Users,
StorageSite = model.Restricted.StorageSite,
Use = model.Restricted.Use,
PharmaceuticalGrade = model.Restricted.PharmaceuticalGrade
};
order.SetAuthorizationInfo(restricted);
}
else
{
order.ClearAuthorizationInfo();
}
if (includeLineItemsAndSplits)
{
_bugTrackingService.CheckForClearedOutSubAccounts(order, model.Splits, model);
decimal number;
order.EstimatedTax = decimal.TryParse(model.Tax != null ? model.Tax.TrimEnd('%') : null, out number) ? number : order.EstimatedTax;
order.ShippingAmount = decimal.TryParse(model.Shipping != null ? model.Shipping.TrimStart('$') : null, out number) ? number : order.ShippingAmount;
order.FreightAmount = decimal.TryParse(model.Freight != null ? model.Freight.TrimStart('$') : null, out number) ? number : order.FreightAmount;
order.LineItems.Clear(); //replace line items and splits
order.Splits.Clear();
//Add in line items
foreach (var lineItem in model.Items)
{
if (lineItem.IsValid())
{
Commodity commodity = null;
if (!string.IsNullOrWhiteSpace(lineItem.CommodityCode))
{
commodity = _repositoryFactory.CommodityRepository.Queryable.SingleOrDefault(a => a.Id == lineItem.CommodityCode && a.IsActive);
}
//TODO: could use automapper later, but need to do validation
var orderLineItem = new LineItem
{
CatalogNumber = lineItem.CatalogNumber,
Commodity = commodity,
Description = lineItem.Description,
Notes = lineItem.Notes,
Quantity = decimal.Parse(lineItem.Quantity),
Unit = lineItem.Units,//TODO: shouldn't this link to UOM?
UnitPrice = decimal.Parse(lineItem.Price),
Url = lineItem.Url
};
order.AddLineItem(orderLineItem);
if (model.SplitType == OrderViewModel.SplitTypes.Line)
{
var lineItemId = lineItem.Id;
//Go through each split created for this line item
foreach (var split in model.Splits.Where(x => x.LineItemId == lineItemId))
{
if (split.IsValid())
{
order.AddSplit(new Split
{
Account = split.Account,
Amount = decimal.Parse(split.Amount),
LineItem = orderLineItem,
SubAccount = split.SubAccount,
Project = split.Project
});
}
}
}
}
}
//TODO: note that I am not checking an order split actually has valid splits, or that they add to the total.
if (model.SplitType == OrderViewModel.SplitTypes.Order)
{
foreach (var split in model.Splits)
{
if (split.IsValid())
{
order.AddSplit(new Split
{
Account = split.Account,
Amount = decimal.Parse(split.Amount),
SubAccount = split.SubAccount,
Project = split.Project
});
}
}
}
else if (model.SplitType == OrderViewModel.SplitTypes.None)
{
order.AddSplit(new Split { Amount = order.Total(), Account = model.Account, SubAccount = model.SubAccount, Project = model.Project }); //Order with "no" splits get one split for the full amount
}
order.TotalFromDb = order.Total();
order.LineItemSummary = order.GenerateLineItemSummary();
}
}