コード例 #1
0
        /// <summary>
        /// Method called by Controller to insert the order with the database structure, receiving only the client description of order.
        /// </summary>
        /// <param name="orderViewModel"></param>
        /// <returns></returns>
        public static bool InsertOrder(OrderViewModel orderViewModel)
        {
            try
            {
                var           context  = new RestaurantDBContext();
                List <string> itemList = new List <string>();
                List <int>    numbers  = new List <int>();
                itemList = orderViewModel.OrderDescription.Split(",").ToList();
                OrderObj order = GetOrderObj(itemList.FirstOrDefault().ToLower().Trim());
                itemList.RemoveRange(0, 1);
                numbers = ValidateOrder(itemList);

                if (numbers != null && numbers.Count > 0)
                {
                    OrderAccess.AddOrder(order);
                    return(InsertAllOrderItems(numbers));
                }

                return(false);
            }
            catch
            {
                return(false);
            }
        }
コード例 #2
0
        public void TestIfAddOrderCallsAddOrderInRepo()
        {
            // Arrange

            var repo    = new Mock <IOrderRepository>();
            var manager = new OrderAccess(repo.Object);


            // Act

            manager.AddOrder(It.IsAny <Order>());


            // Assert

            repo.Verify(x => x.AddOrder(It.IsAny <Order>()), Times.Exactly(1));
        }
コード例 #3
0
ファイル: TicketInfo.cs プロジェクト: yankun1991/EBooking
 /// <summary>
 /// 门票预订
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btBook_Click(object sender, EventArgs e)
 {
     if (scenery.SYUseNum >= scenery.SYTotal)
     {
         MessageBox.Show("当前时间的门票已售罄!");
     }
     else
     {
         Oreder order = new Oreder();
         order.TKType        = this.cbTicketType.SelectedIndex;
         order.TKReserveTime = DateTime.Now;
         order.TKUseTime     = Convert.ToDateTime(this.dtpUseTime.Text);
         order.TKNum         = Convert.ToInt32(this.nudTicketNum.Value);
         order.TKUserId      = UserId;
         order.TKSupplier    = scenery.SYSupplier;
         order.TKImagSrc     = scenery.SYImagSrc;
         order.TKPrice       = Convert.ToInt32(this.lbPrice2.Text);
         order.TKSYId        = scenery.SYId;
         #region  订票验证
         if (order.TKNum != 0)
         {
             if (UserId != -1)
             {
                 if (SceneryAccess.ShowSceneryByUseTime(order.TKUseTime))
                 {
                     if (this.cbTicketType.SelectedIndex != -1)
                     {
                         if (OrderAccess.AddOrder(order))
                         {
                             #region MyRegion
                             if (DistributorAccess.SelectById(UserId))
                             {
                                 this.Visible = false;
                                 DistributorUser distributorUser = new DistributorUser(UserId);
                                 distributorUser.Show();
                             }
                             else
                             {
                                 MessageBox.Show("预订成功!");
                                 this.Visible = false;
                                 Homepage homePage = new Homepage(UserId);
                                 homePage.Show();
                             }
                         }
                         else
                         {
                             MessageBox.Show("订票失败!");
                         }
                         #endregion
                     }
                     else
                     {
                         MessageBox.Show("请选择票型");
                     }
                 }
                 else
                 {
                     MessageBox.Show("当前门票暂时没有上线,请晚些时候再来!");
                 }
             }
             else
             {
                 MessageBox.Show("请登录后再订票!");
             }
             #endregion
         }
         else
         {
             MessageBox.Show("请选择预订数量!");
         }
     }
 }