示例#1
0
 public void AddOrder(Order order)
 {
     if (order != null)
     {
         orderDb.AddOrder(order);
     }
 }
        public int AddOrder(ModelLibrary.Order order)
        {
            var ordDb   = new OrderDb();
            var dbOrder = ConvertOrder(order);

            dbOrder.OrderLineItems.AddRange(ConvertOrderLineItemsToDb(order));

            return(ordDb.AddOrder(dbOrder));
        }
示例#3
0
 public static void AddOrder(Order order)
 {
     Console.WriteLine(order.Total);
     OrderDb.AddOrder(order.OrderId, order.Total, order.Note,
                      order.DateTime, order.UserId);
     foreach (var entry in order.OrderEntries)
     {
         OrderEntry.AddOrderEntry(entry);
     }
 }
        public void Add_Order_To_Database_Test()
        {
            //Setup
            var ordCtrl = new OrderCtrl();
            var ordDb   = new OrderDb();
            var dt      = new DateTime(2018, 11, 08, 12, 22, 33);
            var resDt   = new DateTime(2018, 11, 08, 18, 00, 00);
            var oli     = new List <OrderLineItem>();
            var item    = new ModelLibrary.Item();

            item.Id = 1000000;
            oli.Add(new OrderLineItem(item, 2));

            var order = new Order
            {
                OrderId             = (ordCtrl.GetLastOrderIdentity() + 1).ToString(),
                CustomerId          = "1000000",
                RestaurantId        = "1000000",
                DateTime            = "2018-11-08 12:22:33",
                ReservationDateTime = "2018-11-08 18:00:00",
                ItemsList           = oli,
                NoSeats             = "2",
                Payment             = "200.00",
                Accepted            = false
            };

            //Act
            var oliList = ordCtrl.ConvertOrderLineItemsToDb(order);
            var dbOrder = ordCtrl.ConvertOrder(order);

            for (var i = 0; i < dbOrder.OrderLineItems.Count - 1; i++)
            {
                dbOrder.OrderLineItems.Add(oliList[i]);
            }
            ordDb.AddOrder(dbOrder);

            //Assert
            Assert.IsTrue(ordCtrl.GetLastOrderIdentity() == Convert.ToInt32(order.OrderId));
        }