Пример #1
0
 //
 // GET: /Order/
 public OrderController()
 {
     im = new OrderIM(db);
     om = new OrderOM(db);
     order_itemOM = new Order_ItemOM(db);
     menu_itemOM = new MenuItemOM(db);
 }
Пример #2
0
 public BillController()
 {
     im = new BillIM(db);
     om = new BillOM(db);
     orderIM = new OrderIM(db);
     orderOM = new OrderOM(db);
     order_itemIM = new Order_ItemIM(db);
     order_itemOM = new Order_ItemOM(db);
 }
Пример #3
0
        public Boolean edit(order_item order_item)
        {
            Order_ItemIM im = new Order_ItemIM(db);
            OrderOM orderOM = new OrderOM(db);
            order_item dbVersion = im.find(order_item.id);
            if (dbVersion.version == order_item.version)
            {
                ((IObjectContextAdapter)db).ObjectContext.Detach(dbVersion);
                db.Entry(order_item).State = EntityState.Modified;

                order_item.version = order_item.version + 1;
                db.SaveChanges();
                orderOM.edit(db.orders.Find(order_item.order_id));
                return true;
            }
            return false;
        }
Пример #4
0
        public void DeleteItemActiveExceptionTest()
        {
            //Arrange
            db = new touch_for_foodEntities();
            OrderOM target = new OrderOM(db);
            orderItem1.order_item_status = (int)OrderStatusHelper.OrderItemStatusEnum.PROCESSING;
            db.Entry(orderItem1).State = EntityState.Modified;
            db.SaveChanges();

            //Act
            int actual = target.delete(order1.id);

            //Assert
            db = new touch_for_foodEntities();
            Assert.IsFalse(db.orders.Find(order1.id).order_status ==
                (int)OrderStatusHelper.OrderStatusEnum.DELETED);
            Assert.IsFalse(db.order_item.Find(orderItem1.id).order_item_status ==
                (int)OrderStatusHelper.OrderItemStatusEnum.DELETED);
        }
Пример #5
0
 public Order_ItemController()
 {
     om = new Order_ItemOM(db);
     im = new Order_ItemIM(db);
     orderOM = new OrderOM(db);
 }
Пример #6
0
        public void DeleteTest()
        {
            //Arrange
            db = new touch_for_foodEntities();
            OrderOM target = new OrderOM(db);
            int expected = 2;
            int version = order1.version;
            //Check-Setup
            Assert.IsFalse(db.orders.Find(order1.id).order_status ==
                (int)OrderStatusHelper.OrderStatusEnum.DELETED);
            Assert.IsFalse(db.order_item.Find(orderItem1.id).order_item_status ==
                (int)OrderStatusHelper.OrderItemStatusEnum.DELETED);

            //Act
            int actual = target.delete(order1.id);

            //Assert
            db = new touch_for_foodEntities();
            order o = db.orders.Find(order1.id);
            Assert.IsTrue(o.order_status ==
                (int)OrderStatusHelper.OrderStatusEnum.DELETED);
            Assert.AreEqual(o.version, ++version);
            Assert.IsTrue(db.order_item.Find(orderItem1.id).order_item_status ==
                (int)OrderStatusHelper.OrderItemStatusEnum.DELETED);
            Assert.AreEqual(expected, actual);
        }