本文整理匯總了C#中Models.User.Create方法的典型用法代碼示例。如果您正苦於以下問題:C# User.Create方法的具體用法?C# User.Create怎麽用?C# User.Create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Models.User
的用法示例。
在下文中一共展示了User.Create方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: ProcessOrder
public bool ProcessOrder(List<PartOrder> partOrders, string phoneNr, string address)
{
//Create the user to be inserted into the database.
UserDB userDB = new UserDB();
User user = userDB.GetUserByPhone(phoneNr);
//if the user does not exist already, create one.
if (user == null)
{
user = new User();
user.PhoneNumber = phoneNr;
user.RankID = 0;
user.Create();
}
//Create the address to be inserted into the database.
AddressDB addressDB = new AddressDB();
Address userAddress = addressDB.GetByAddress(address);
//if the address does not exist already, create one.
if (userAddress == null)
{
userAddress = new Address();
userAddress.UserAddress = address;
userAddress.UserID = user.ID;
userAddress.Create();
}
//Create the order to be inserted to the database
Order order = new Order();
order.AddressID = userAddress.ID;
order.UserID = user.ID;
order.StatusID = OrderStatus.WAITING;
order.Create();
//The partorders are inserted to the database
PartOrderDB poDB = new PartOrderDB();
//For debugging Part Orders when something happens.
CustomHandlers.DatabaseLibrary.Response<PartOrder> r = poDB.CreateBatch(order.ID, partOrders);
foreach (string s in r.Messages)
{
Console.WriteLine(s);
}
return r.Success;
}