本文整理汇总了C#中OrderItem.Place方法的典型用法代码示例。如果您正苦于以下问题:C# OrderItem.Place方法的具体用法?C# OrderItem.Place怎么用?C# OrderItem.Place使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OrderItem
的用法示例。
在下文中一共展示了OrderItem.Place方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessRequest
//.........这里部分代码省略.........
!string.IsNullOrEmpty(context.Request.Form["items"]))
{
var items = jsonSerializer.Deserialize<List<Item>>(context.Request.Form["items"]);
if (items != null && items.Count > 0)
{
// Place Order
var o = new OrdrWish
{
Mobile = m.Mobile,
Address = m.Address,
UpdateTime = DateTime.Now,
Description = string.Empty,
OrderType = OrderBaseType.Wish,
MemberID = m.ID,
MemberName = m.Name,
Payment = string.Empty,
Price = 0,
Sale = null,
Deposit = null,
Status = OrderStatusType.Draft,
Rate = 0,
CreateTime = DateTime.Now,
IsActive = true,
Remark = "来自结算购物车"
};
//Get the Order ID after Insert new one
object key;
_repo.Insert(o, out key, trans);
oid = Convert.ToInt32(key);
// Place OrderItem
var dict = new Dictionary<string, int>();
// Organize Dictionary
foreach (var item in items)
{
if (dict.ContainsKey(item.code))
{
dict[item.code]++;
}
else
{
dict.Add(item.code, 1);
}
}
// Place every product into orderItem
if (dict.Count > 0)
{
foreach (var d in dict)
{
var p = Product.Cache.Load(d.Key);
if (p != null && p.IsActive && p.ProductType.Equals(ProductType.Other))
{
var oi = new OrderItem
{
Quantity = d.Value,
Size = string.Empty,
Remark = string.Empty,
OrderID = oid
};
oi.Place(m, p, trans);
}
}
}
}
trans.Commit();
responseText = jsonSerializer.Serialize(new { OrderID = oid });
}
}
else
{
throw new Exception("当前用户处于未登录状态");
}
}
else
{
// Request was sent incorrectly somehow
throw new Exception("客户端应发起POST请求");
}
}
catch (Exception ex)
{
trans.Rollback();
responseText = jsonSerializer.Serialize(new { result = "error", error_msg = ex.Message });
}
}
context.Response.Clear();
context.Response.ContentType = "text/json";
context.Response.Write(responseText);
context.Response.End();
}