示例#1
0
 public override double CalculateHappiness(double happiness)
 {
     MainFood.CalculateHappiness(happiness);
     Effect           = 1;
     MainFood.Effect *= 0;
     return(happiness + Effect);
 }
示例#2
0
        public void Arrange()
        {
            _repo = new Main_Repository();
            _main = new MainFood("Double CheeseBurger", "Two flambroiled patties with cheese on each pattie layed on a charred brioche bun. Then topped with pickles, ketchup, and mustard.", "Two flamebroiled patties, 1 brioche bun, pickles, 1Tbl of mayo, 1Tbl ketchup", 6.95, 1);

            _repo.AddContentToMainFood(_main);
        }
示例#3
0
 public MainFood AddMainFood(MainFood mainFood)
 {
     if (string.IsNullOrEmpty(mainFood.MainFoodName))
     {
         throw new ArgumentException("Main Food needs a name.");
     }
     return(_mainFoodRepo.CreateMainFood(mainFood));
 }
        public void createMainfoodWithoutName()
        {
            var menu = new MainFood()
            {
            };
            Exception ex = Assert.ThrowsException <ArgumentException>(() =>
                                                                      mainFoodService.AddMainFood(menu));

            Assert.AreEqual("Main Food needs a name.", ex.Message);
        }
        public void FindByIdWithoutId()
        {
            var menu = new MainFood()
            {
                Id = 0
            };
            Exception ex = Assert.ThrowsException <ArgumentException>(() =>
                                                                      mainFoodService.FindMainFoodIdIncludeRecipAlrg(menu.Id));

            Assert.AreEqual("ID requires to be greater than 0.", ex.Message);
        }
        public void UpdateMainFoodWithoutName()
        {
            var menu = new MainFood()
            {
                Id = 1
            };
            Exception ex = Assert.ThrowsException <ArgumentException>(() =>
                                                                      mainFoodService.FindMainFoodIdIncludeRecipAlrg(menu.Id));

            Assert.AreEqual("Main Food needs a name.", ex.Message);
        }
        public void deleteWithoutIdLowerThan1()
        {
            var menu = new MainFood()
            {
                Id = 0
            };
            Exception ex = Assert.ThrowsException <ArgumentException>(() =>
                                                                      mainFoodService.DeleteMainFood(menu.Id));

            Assert.AreEqual("ID requires to be greater than 0.", ex.Message);
        }
示例#8
0
        public void SetTitle_ShouldSetCorrectString()
        {
            MainFood content = new MainFood()
            {
                MainFoodName = "burger"
            };

            string expected = "burger";
            string actual   = content.MainFoodName;

            Assert.AreEqual(expected, actual);
        }
示例#9
0
 public MainFood UpdateMainFood(MainFood mainFoodUpdate)
 {
     if (string.IsNullOrEmpty(mainFoodUpdate.MainFoodName))
     {
         throw new ArgumentException("Main Food needs a name.");
     }
     else if (mainFoodUpdate.Id < 1)
     {
         throw new ArgumentException("You need to have an higher id than 0");
     }
     return(_mainFoodRepo.UpdateMainFood(mainFoodUpdate));
 }
示例#10
0
        public ActionResult <MainFood> Post([FromBody] MainFood mFood)
        {
            try
            {
                return(Ok(_mainFoodService.AddMainFood(mFood)));
            }

            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
示例#11
0
        public List <MainFood> loadMainFood()
        {
            List <MainFood> foodList = new List <MainFood>();
            DataTable       data     = DataProvider.Instance.ExecuteQuery("USP_GetMainFoodList");

            foreach (DataRow item in data.Rows)
            {
                MainFood food = new MainFood(item);
                foodList.Add(food);
            }
            return(foodList);
        }
        public void UpdateMainFoodWithIdLowerThan1()
        {
            var menu = new MainFood()
            {
                Id           = 0,
                MainFoodName = "pasta"
            };
            Exception ex = Assert.ThrowsException <ArgumentException>(() =>
                                                                      mainFoodService.UpdateMainFood(menu));

            Assert.AreEqual("You need to have an higher id than 0", ex.Message);
        }
示例#13
0
        public void GetDirectory_ShouldReturnCurrentCollection()
        {
            MainFood        content = new MainFood();
            Main_Repository repo    = new Main_Repository();

            repo.AddContentToMainFood(content);

            List <MainFood> contents = repo.GetAllContent();

            bool directoryHasContent = contents.Contains(content);

            Assert.IsTrue(directoryHasContent);
        }
示例#14
0
        private void SeedContent()
        {
            MainFood spaghetti = new MainFood("Spaghetti", "Cooked noodles with meaty tomato sauce.", "Spaghetti, water, salt, meaty tomato sauce", 12.35, 1);

            _repo.AddContentToMainFood(spaghetti);

            MainFood macDaddy = new MainFood("MacDaddy", "Tripple beef burger covered in bbq sauce with onion rings.", "3 burger patties, bun, bbq sauce, onion rings", 10.35, 2);

            _repo.AddContentToMainFood(macDaddy);

            MainFood ribs = new MainFood("Ribs", "Slow cooked ribs slathered in house made bbq sauce served with fries.", "St Louis ribs, house rub, bbq sauce, house fries", 16.92, 3);

            _repo.AddContentToMainFood(ribs);
        }
示例#15
0
        public ActionResult <MainFood> Put(int id, [FromBody] MainFood mFood)
        {
            try
            {
                var entity = _mainFoodService.UpdateMainFood(mFood);
                entity.MainFoodName = mFood.MainFoodName;
                return(Ok(entity));
            }

            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
示例#16
0
        private void DeleteContentByTitle()
        {
            Console.Clear();
            Console.WriteLine("Enter Item Name you want to delete by name.");
            string   itemName        = Console.ReadLine();
            MainFood existingContent = _repo.GetFoodByName(itemName);

            if (existingContent == null)
            {
                Console.WriteLine("There isn't any items under that menu number.\n" +
                                  "Press any key to continue.");
                Console.ReadKey();
            }
            else
            {
                Console.WriteLine("Your Item has been removed.\n" +
                                  "Press any key to continue.");
                Console.ReadKey();
            }
        }
示例#17
0
        public MainFood UpdateMainFood(MainFood foodUpdate)
        {
            List <RecipeLine>      newRecipeLines  = new List <RecipeLine>();
            List <AllergensInMenu> newAllegensMenu = new List <AllergensInMenu>();

            if (foodUpdate.RecipeLines != null)
            {
                newRecipeLines = new List <RecipeLine>(foodUpdate.RecipeLines);
            }
            if (foodUpdate.AllergensInMenu != null)
            {
                newAllegensMenu = new List <AllergensInMenu>(foodUpdate.AllergensInMenu);
            }

            _ctx.Attach(foodUpdate).State = EntityState.Modified;



            _ctx.RecipeLine.RemoveRange(
                _ctx.RecipeLine.Where(m => m.MainFoodId == foodUpdate.Id)
                );

            _ctx.AllergensInMenu.RemoveRange(
                _ctx.AllergensInMenu.Where(ol => ol.MainFoodId == foodUpdate.Id)
                );

            foreach (var RL in newRecipeLines)

            {
                _ctx.Entry(RL).State = EntityState.Added;
            }

            foreach (var AM in newAllegensMenu)
            {
                _ctx.Entry(AM).State = EntityState.Added;
            }
            // Save it

            _ctx.SaveChanges();
            return(foodUpdate);
        }
示例#18
0
        //create
        private void AddContentToMainFood()
        {
            MainFood content = new MainFood();

            Console.WriteLine("Enter item name.");
            content.MainFoodName = Console.ReadLine();

            Console.WriteLine("Add Descritption of item.");
            content.MainFoodName = Console.ReadLine();

            Console.WriteLine("What is the menu number for item?");
            content.MenuNumber = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("Ingredients to make item.");
            content.MainIngredients = Console.ReadLine();

            Console.WriteLine("Last step, what is the price of the item?");
            content.MainPrice = Convert.ToDouble(Console.ReadLine());

            _repo.AddContentToMainFood(content);
            Console.WriteLine("Your item has been added. Press any key to return to the menu.");
            Console.ReadKey();
        }
示例#19
0
 public override string ToString()
 {
     return($"food={MainFood.ToString()}, extras=[Mustard]");
 }
示例#20
0
 public MainFood CreateMainFood(MainFood mainFood)
 {
     _ctx.Attach(mainFood).State = EntityState.Added;
     _ctx.SaveChanges();
     return(mainFood);
 }
 public override string ToString()
 {
     return($"food={MainFood.ToString()}, extras=[Ketchup]");
 }
示例#22
0
        public void GetItemByName_ShouldReturnCorrectItem()
        {
            MainFood searchResult = _repo.GetFoodByName("Double CheeseBurger");

            Assert.AreEqual(_main, searchResult);
        }
示例#23
0
        public void GetItemByNumber_ShouldReturnCorrectItem()
        {
            MainFood searchResult = _repo.GetFoodByNumber(1);

            Assert.AreEqual(_main, searchResult);
        }