Exemplo n.º 1
0
        public void RemoveLine(MenuItem menuItem)
        {
            if(lineCollection.All(l => l.MenuItem.Id != menuItem.Id))
                throw new ArgumentException("No this type of item");

            lineCollection.RemoveAll(l => l.MenuItem.Id == menuItem.Id);
        }
Exemplo n.º 2
0
        public void RemoveLines_no_this_type_of_menu_items()
        {
            //Arrange
            var cart = new Cart();
            var testMenuItem = new MenuItem();

            //Act
            cart.RemoveLine(testMenuItem);
        }
        public MenuItem(MenuItem menuItemToCopy)
            : base(menuItemToCopy)
        {
            if(menuItemToCopy == null)
                throw new ArgumentNullException("menuItemToCopy");

            Name = menuItemToCopy.Name;
            Description = menuItemToCopy.Description;
            Category = new MenuItemCategory(menuItemToCopy.Category);
            Price = menuItemToCopy.Price;
        }
Exemplo n.º 4
0
 public void AddItem(MenuItem menuItem, int quantity)
 {
     var line = lineCollection.FirstOrDefault(p => p.MenuItem.Id == menuItem.Id);
     if (line == null)
     {
         lineCollection.Add(new MenuItemQuantity
         {
             MenuItem = menuItem,
             Quantity = quantity
         });
     }
     else
     {
         line.Quantity += quantity;
     }
 }
Exemplo n.º 5
0
        public bool EditMenuItem(int managerId, MenuItem menuItemToEdit)
        {
            if (!CheckHasUserRole(managerId, UserRole.Manager))
                throw new SecurityException(String.Format("User id = {0} is not logged in or is no manager", managerId));

            if (menuItemToEdit == null)
                throw new ArgumentNullException("menuItemToEdit");

            using(var db = new DataAccessProvider())
            {
                MenuItemEntity editedMenuItemEntity = db.MenuItems.Find(menuItemToEdit.Id);
                if (editedMenuItemEntity == null || editedMenuItemEntity.IsDeleted)
                    return false;

                //db.Entry(editedMenuItem).State = System.Data.Entity.EntityState.Detached;
                //db.MenuItems.Attach(menuItemToEdit);
                //db.Entry(menuItemToEdit).State = System.Data.Entity.EntityState.Modified;

                editedMenuItemEntity.CopyData(menuItemToEdit);
                MenuItemCategoryEntity editedMenuItemCategoryEntity =
                    db.MenuItemCategories.Find(menuItemToEdit.Category.Id);

                if (editedMenuItemCategoryEntity != null)
                    editedMenuItemEntity.Category = editedMenuItemCategoryEntity;

                db.Entry(editedMenuItemEntity).State = EntityState.Modified;

                db.SaveChanges();
                return true;
            }
        }
        private void AddItemToMenuItemLists(MenuItem testMenuItem)
        {
            var previousMenuItemQuantity = _menuItemsInCart.FirstOrDefault(m => m.MenuItem.Id == testMenuItem.Id);
            var previousMenuItemCount = previousMenuItemQuantity != null ? previousMenuItemQuantity.Quantity : 0;

            _cart.AddItem(testMenuItem, 1);

            Assert.AreEqual(previousMenuItemCount + 1, _menuItemsInCart.First( m => m.MenuItem.Id == testMenuItem.Id).Quantity);
        }
Exemplo n.º 7
0
        public void TestCleanup()
        {
            if (order1 != null)
                dataWipe.WipeOrder(order1.Id);

            if (managerContext1 != null)
                dataWipe.WipeUser(managerContext1.Id);

            if (clientContext1 != null)
                dataWipe.WipeUser(clientContext1.Id);

            if (waiterContext1 != null)
                dataWipe.WipeUser(waiterContext1.Id);

            if (waiterContext2 != null)
                dataWipe.WipeUser(waiterContext2.Id);

            if (menuItem1 != null)
                dataWipe.WipeMenuItem(menuItem1.Id);

            if (menuItem2 != null)
                dataWipe.WipeMenuItem(menuItem2.Id);

            if (menuItem3 != null)
                dataWipe.WipeMenuItem(menuItem3.Id);

            if (category1 != null)
                dataWipe.WipeMenuItemCategory(category1.Id);

            if (table1 != null)
                dataWipe.WipeTable(table1.Id);

            order1 = null;
            managerContext1 = null;
            waiterContext1 = null;
            waiterContext2 = null;
            clientContext1 = null;
            category1 = null;
            menuItem1 = null;
            menuItem2 = null;
            menuItem3 = null;
            table1 = null;
        }
Exemplo n.º 8
0
        public void AddNewMenuItemTest()
        {
            if (category1 == null)
                AddNewCategoryTest();

            ManagerLogInTest();

            menuItem1 = managerDataAccess.AddMenuItem(managerContext1.Id, menuItemName1, menuItemDescription1,
                category1.Id, menuItemPrice1);
            menuItem2 = managerDataAccess.AddMenuItem(managerContext1.Id, menuItemName2, menuItemDescription2,
                category1.Id, menuItemPrice2);
            menuItem3 = managerDataAccess.AddMenuItem(managerContext1.Id, menuItemName3, menuItemDescription3,
                category1.Id, menuItemPrice3);

            Assert.IsNotNull(menuItem1);
            Assert.AreNotEqual(menuItem1.Id, 0);
            Assert.AreEqual(menuItem1.Name, menuItemName1);
            Assert.AreEqual(menuItem1.Description, menuItemDescription1);
            Assert.IsNotNull(menuItem1.Category);
            Assert.AreEqual(menuItem1.Category.Name, categoryName1);
            Assert.AreEqual(menuItem1.Category.Description, categoryDescription1);

            Assert.IsNotNull(menuItem2);
            Assert.AreNotEqual(menuItem2.Id, 0);
            Assert.AreEqual(menuItem2.Name, menuItemName2);
            Assert.AreEqual(menuItem2.Description, menuItemDescription2);
            Assert.IsNotNull(menuItem2.Category);
            Assert.AreEqual(menuItem2.Category.Name, categoryName1);
            Assert.AreEqual(menuItem2.Category.Description, categoryDescription1);

            Assert.IsNotNull(menuItem3);
            Assert.AreNotEqual(menuItem3.Id, 0);
            Assert.AreEqual(menuItem3.Name, menuItemName3);
            Assert.AreEqual(menuItem3.Description, menuItemDescription3);
            Assert.IsNotNull(menuItem3.Category);
            Assert.AreEqual(menuItem3.Category.Name, categoryName1);
            Assert.AreEqual(menuItem3.Category.Description, categoryDescription1);

            ManagerLogOutTest();
        }
 /// <summary>
 /// Konstruktor kopiujący
 /// </summary>
 /// <param name="menuItemQuantityToCopy"> Element zamówienia do skopiowania</param>
 public MenuItemQuantity(MenuItemQuantity menuItemQuantityToCopy)
 {
     MenuItem = new MenuItem((menuItemQuantityToCopy.MenuItem));
     Quantity = menuItemQuantityToCopy.Quantity;
 }
Exemplo n.º 10
0
 public MenuItemQuantity(MenuItemQuantityEntity menuItemQuantity)
     : base(menuItemQuantity)
 {
     MenuItem = new MenuItem(menuItemQuantity.MenuItem);
     Quantity = menuItemQuantity.Quantity;
 }
Exemplo n.º 11
0
 public bool EditMenuItem(int managerId, MenuItem menuItemToEdit)
 {
     return EditMenuItemWeb(managerId, menuItemToEdit);
 }