本文整理汇总了C#中Order.SetAuthorizationInfo方法的典型用法代码示例。如果您正苦于以下问题:C# Order.SetAuthorizationInfo方法的具体用法?C# Order.SetAuthorizationInfo怎么用?C# Order.SetAuthorizationInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Order
的用法示例。
在下文中一共展示了Order.SetAuthorizationInfo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BindOrderModel
private void BindOrderModel(Order order, OrderViewModel model, bool includeLineItemsAndSplits = false)
{
var workgroup = _repositoryFactory.WorkgroupRepository.GetById(model.Workgroup);
//TODO: automapper?
order.Vendor = model.Vendor == 0 ? null : _repositoryFactory.WorkgroupVendorRepository.GetById(model.Vendor);
order.Address = _repositoryFactory.WorkgroupAddressRepository.GetById(model.ShipAddress);
order.ShippingType = _repositoryFactory.ShippingTypeRepository.GetById(model.ShippingType);
order.DateNeeded = model.DateNeeded;
order.AllowBackorder = model.AllowBackorder;
order.Workgroup = workgroup;
order.Organization = workgroup.PrimaryOrganization; //TODO: why is this needed?
order.DeliverTo = model.ShipTo;
order.DeliverToEmail = model.ShipEmail;
order.DeliverToPhone = model.ShipPhone;
order.OrderType = order.OrderType ?? _repositoryFactory.OrderTypeRepository.GetById(OrderType.Types.OrderRequest);
order.CreatedBy = order.CreatedBy ?? _repositoryFactory.UserRepository.GetById(CurrentUser.Identity.Name); //Only replace created by if it doesn't already exist
order.Justification = model.Justification;
order.BusinessPurpose = model.BusinessPurpose;
order.RequestType = model.RequestType;
if (!string.IsNullOrWhiteSpace(model.Comments))
{
var comment = new OrderComment
{
DateCreated = DateTime.UtcNow.ToPacificTime(),
User = _repositoryFactory.UserRepository.GetById(CurrentUser.Identity.Name),
Text = model.Comments
};
order.AddOrderComment(comment);
}
if (model.CustomFields != null)
{
order.CustomFieldAnswers.Clear();
foreach (var customField in model.CustomFields.Where(x => !string.IsNullOrWhiteSpace(x.Answer)))
{
var answer = new CustomFieldAnswer
{
Answer = customField.Answer,
CustomField = _repositoryFactory.CustomFieldRepository.GetById(customField.Id)
};
order.AddCustomAnswer(answer);
}
}
if (model.Restricted != null && model.Restricted.IsRestricted)
{
var restricted = new ControlledSubstanceInformation
{
ClassSchedule = model.Restricted.Class,
Custodian = model.Restricted.Custodian,
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),
//.........这里部分代码省略.........