當前位置: 首頁>>代碼示例>>C#>>正文


C# User.Create方法代碼示例

本文整理匯總了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;
        }
開發者ID:commentatorboy,項目名稱:PizzaWaiter,代碼行數:48,代碼來源:PizzaWaiterTestService.cs


注:本文中的Models.User.Create方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。