Exemplo n.º 1
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Burger = await _db.Burger.FirstOrDefaultAsync(m => m.Id == id);

            if (Burger == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Exemplo n.º 2
0
        public void Price_returns_sum_of_all_packed_item_prices()
        {
            var burger = new Burger(BurgerTypes.Vegetable, SamplePrice);
            var drink  = new Drink(DrinkTypes.Cola, SamplePrice);
            var fries  = new Fries(SamplePrice);
            var bag    = new Bag {
                burger, drink, fries
            };
            var toy = new Toy(ToyTypes.Car, SamplePrice);

            var mealBag = new Bag {
                bag, toy
            };

            Assert.AreEqual((burger.Price + drink.Price + fries.Price + toy.Price), mealBag.Price);
        }
Exemplo n.º 3
0
        public Order OrderBurger(string cartId, Burger burger)
        {
            var order = _repository.GetOrderByCartId(cartId);

            if (order == null)
            {
                order = new Order(cartId, burger);
                _repository.SaveOrder(order);
            }
            else
            {
                order.AddBurger(burger);
            }

            return(order);
        }
Exemplo n.º 4
0
    /// <summary>
    /// grabs the next object from the unused collection and generates a new order from it
    /// </summary>
    private void GenerateNewOrder()
    {
        if (Unused.Count == 0)
        {
            return;
        }
        var          poppedObject = Unused.First();
        Burger       burger       = poppedObject.Key;
        BurgerVisual burgerVis    = poppedObject.Value.GetComponentInChildren <BurgerVisual>();

        Unused.Remove(burger);
        burger.InitBurger(pseudoRand);
        burgerVis.UpdateBurgerImages(burger);
        Used.Add(poppedObject.Key, poppedObject.Value);
        poppedObject.Value.SetActive(true);
    }
Exemplo n.º 5
0
    public bool Compare(IFood food)
    {
        if (food.GetType() != GetType())
        {
            return(false);
        }

        Burger b = (Burger)food;

        if (b == null)
        {
            return(false);
        }

        return(compareVal == b.compareVal);
    }
Exemplo n.º 6
0
        //CREATE BURGER
        public Burger Create(Burger burger)
        {
            //first @ indicates multi-line input
            //order of values must matach order of insert statement columns
            //DON"T USE STRING INTERPOLATION HERE, ESPECIALLY WITH USER INPUT
            //burger in line 52 is the object that dapper parses and references
            //from the values parameters two lines above
            int id = _db.ExecuteScalar <int>(@"
        INSERT INTO Burgers (name, description, price)
        VALUES (@Name, @Description, @Price);
        SELECT LAST_INSERT_ID();", burger
                                             );

            burger.Id = id;
            return(burger);
        }
Exemplo n.º 7
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Burger = await _db.Burger.FindAsync(id);

            if (Burger != null)
            {
                _db.Burger.Remove(Burger);
                await _db.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Exemplo n.º 8
0
        private void CallbackMethod(object oStateObject)
        {
            Random random   = new Random();
            float  discount = random.Next(5, 25);

            random = new Random();
            int    whichBurger = (int)random.Next(0, Burgers.Count - 1);
            Burger Burger      = Burgers[whichBurger];

            Burger.discount = discount;

            random = new Random();
            int    whichEvent       = (int)random.Next(0, events.Count - 1);
            string eventDescription = events[whichEvent];

            provider.Sale(new Burvent(eventDescription, Burger));
        }
Exemplo n.º 9
0
        public async Task AddBurgerAsync()
        {
            var burger = new Burger
            {
                Name       = AddName,
                Price      = AddPrice,
                Content    = AddContent,
                Restaurant = username
            };

            var response = await client.PostAsJsonAsync($"api/burgers", burger);

            if (response.IsSuccessStatusCode)
            {
                Burgers.Add(burger);
            }
        }
Exemplo n.º 10
0
        public Burger EditBurger(Burger burgerData)
        {
            var burger = GetBurgerById(burgerData.Id);

            burger.Name        = burgerData.Name;
            burger.Description = burgerData.Description;
            burger.Price       = burgerData.Price;

            bool success = _repo.SaveBurger(burger);

            if (!success)
            {
                throw new Exception("Nope I couldn't update the burger.... Please Try Again Later, or now is probably fine");
            }

            return(burger);
        }
Exemplo n.º 11
0
 public Burger EditBurger(int id, Burger burg)
 {
     try
     {
         return(_dB.QueryFirstOrDefault <Burger>($@"
 UPDATE burgers3 SET
 Name = @Name, 
 Description = @Description,
 Price = @Price
 WHERE Id =@id;
 SELECT * FROM burgers3 WHERE Id = @id;", burg));
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
         return(null);
     }
 }
Exemplo n.º 12
0
 public Burger EditBurger(int id, Burger newBurger)
 {
     try
     {
         return(_db.QueryFirstOrDefault <Burger>($@"
 UPDATE Burger SET
   Price = @Price,
   Description = @Description,
   Name = @Name
 WHERE Id = @Id;
 SELECT * FROM Burgers Where id= @Id", newBurger));
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
         return(null);
     }
 }
Exemplo n.º 13
0
 internal Burger CreateBurger(Burger burgerData)
 {
     try
     {
         //execute scalar let's you do multiple commands
         int id = _db.ExecuteScalar <int>(@"
   INSERT INTO burger (name, description)
   VALUES (@Name, @Description);
   SELECT LAST_INSERT_ID();
   ", burgerData);
         burgerData.Id = id;
         return(burgerData);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Exemplo n.º 14
0
 //NOTE GetItems gets the Items from the Burger and Message list
 public void GetItems()
 {
     Messages.Add("Burgers:");
     for (int i = 0; i < Burgers.Count; i++)
     {
         Burger burger = Burgers[i];
         Messages.Add($"{i + 1}: {burger.Name} - Cals:{burger.Calories} - {burger.BasePrice:c}");
     }
     Console.WriteLine();
     Messages.Add("Hot Dawgs:");
     for (int i = 0; i < HotDogs.Count; i++)
     {
         HotDog hotDog = HotDogs[i];
         Messages.Add($"{i + 1}: {hotDog.Name} - Cals:{hotDog.Calories} - {hotDog.BasePrice:c}");
     }
     Print();
     Messages.Clear();
 }
      // Update
      public Burger UpdateBurger(int id, Burger burger)
      {
          _db.ExecuteScalar <int>(@"
  UPDATE Burgers SET 
 Name = @Name,
 Description = @Description,
 Price = @Price
 WHERE id = @id; 
  SELECT LAST_INSERT_ID()"    , new
          {
              burger.Name,
              burger.Description,
              burger.Price,
              id
          });
          burger.id = id;
          return(burger);
      }
Exemplo n.º 16
0
        //CREATE BURGER
        public Burger Create(Burger burger)
        {
            // Dapper used below in VALUES line (The '@' symbol)
            int id = _db.ExecuteScalar <int>(@"
            INSERT INTO burgers (name, description, price)
            VALUES (@Name, @Description, @Price);
            SELECT LAST_INSERT_ID();", burger
                                             );

            //Or instead of burger, use instead: new {
            // Name = burger.Name,
            // Description = burger.Description,
            // Price = burger.Price
            //  }

            burger.Id = id;
            return(burger);
        }
Exemplo n.º 17
0
        public void Setup()
        {
            Burger burgerOne = new Burger("Biggest Baddest Burger", 5000, 250, 25, 500, "Ground Angus", 27.96, new List <string>()
            {
                "Bacon", "More Bacon", "Some Eggs"
            }, 3);
            Burger burgerTwo = new Burger("V-Burg", 650, 15, 35, 100, "Impossible Patty", 16.95, new List <string>()
            {
                "V-Cheese", "Tomato", "Lettuce"
            }, 2);
            Burger burgerThree = new Burger("Cowboys Last Ride", 777, 20, 70, 50, "Minecraft Horse Meat", 19.20, new List <string>()
            {
                "Freshly Ground Creeper", "Arrow Shot From Skeleton", "Blaze Rod Powder"
            }, 3);

            Burgers.AddRange(new FoodItem[] { burgerOne, burgerTwo, burgerThree });
            Milkshake shakeone   = new Milkshake("Chocolate", "Malt", "Chocolate Thundas Protein Shake", 200, 10, 50, 00, 9.99, 1);
            Milkshake shaketwo   = new Milkshake("Vanilla", "Classic Shake", "Vanilla Willy's Olde Fashioned", 200, 50, 5, 100, 12.15, 2);
            Milkshake shakeThree = new Milkshake("Strawberry", "Float", "Strawberry Sink or Float", 350, 25, 5, 0, 7.99, 2);

            Shakes.AddRange(new FoodItem[] { shakeone, shaketwo, shakeThree });
            Fries fryOne   = new Fries("Sweet Potato", "Criss-Cut", "Sweeties Sweet Potato Frydish", 750, 300, 20, 200, 8.75, 3);
            Fries fryTwo   = new Fries("Golden Russett", "Classic French", "Golden Frenchies", 400, 95, 10, 100, 5.95, 1);
            Fries fryThree = new Fries("Purple Potato", "Tater Tot", "Purple Power Balls", 450, 75, 17, 20, 12.39, 2);

            Fries.AddRange(new FoodItem[] { fryOne, fryTwo, fryThree });
            FrontDeskPie pieOne   = new FrontDeskPie("Hostess", 125, 9, 5, 25, 7.25, "Chocolate Sunrise", true);
            FrontDeskPie pieTwo   = new FrontDeskPie("Grandma", 200, 0, 20, 50, 12.12, "Mostly Love But Some Rhubarb Crisp", false);
            FrontDeskPie pieThree = new FrontDeskPie("Neighbor Joe", 150, 5, 10, 40, 10.99, "Mystery", true);

            Pies.AddRange(new FoodMerch[] { pieOne, pieTwo, pieThree });
            Food = Burgers;

            Messages.Add($@"
 _                                   _                _    
| |                                 | |              | |   
| |__  _   _ _ __ __ _  ___ _ __ ___| |__   __ _  ___| | __
| '_ \| | | | '__/ _` |/ _ \ '__/ __| '_ \ / _` |/ __| |/ /
| |_) | |_| | | | (_| |  __/ |  \__ \ | | | (_| | (__|   < 
|_.__/ \__,_|_|  \__, |\___|_|  |___/_| |_|\__,_|\___|_|\_\
                  __/ |                                    
                 |___/           ");
            Messages.Add("\nBurgers Available\n");
        }
Exemplo n.º 18
0
    public void AddIngredient(Checker checker, Burger burger)
    {
        Ingredients ingredient = Ingredients.nothing;

        //this can be simplified using a switch statement
        if (checker.gameObject.tag == "BottomBun")
        {
            ingredient = Ingredients.bottomBun;
        }
        else if (checker.gameObject.tag == "Patty")
        {
            ingredient = Ingredients.Patty;
        }
        else if (checker.gameObject.tag == "Lettuce")
        {
            ingredient = Ingredients.Lettuce;
        }
        else if (checker.gameObject.tag == "Cheese")
        {
            ingredient = Ingredients.Cheese;
        }
        else if (checker.gameObject.tag == "Tomato")
        {
            ingredient = Ingredients.tomato;
        }
        else if (checker.gameObject.tag == "onion")
        {
            ingredient = Ingredients.onion;
        }
        else if (checker.gameObject.tag == "TopBun")
        {
            ingredient = Ingredients.TopBun;
        }

        burger.ingredients.Add(ingredient);

        if (checker.checkerAboveMe != null)
        {
            AddIngredient(checker.checkerAboveMe, burger);
        }

        Debug.Log(ingredient);
    }
Exemplo n.º 19
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here

            SetContentView(Resource.Layout.BurgerDetailView);

            BurgerDataService dataService = new BurgerDataService();
            var selectedBurgerId          = Intent.Extras.GetInt("selectedBurgerId");

            _selectedBurger = dataService.GetBurgerById(selectedBurgerId);

            FindViews();

            BindData();

            HandleEvents();
        }
        public string BuiltBurger(Burger burger, string orderName, User u)
        {
            Order order = new Order {
                OrderName = orderName + "#_" + _maxOrderId
            };

            try
            {
                order.UserId   = Db.Users.FirstOrDefault(f => f.UserName == u.UserName)?.UserId;
                order.BurgerId = Db.Burgers.FirstOrDefault(f => f.BurgerName == burger.BurgerName)?.BurgerId;
                Db.Orders.Add(order);
                Db.SaveChanges();
                return(0.ToString());
            }
            catch (Exception e)
            {
                return(e.ToString());
            }
        }
Exemplo n.º 21
0
        public void burger()
        {
            string        bread = "Whole wheat", meat = "Turkey", cheese = "Cheddar";
            List <string> toppings = new List <string>(new string[] { "Lettuce", "Tomato", "Pickle", "Onions" });
            List <string> condiments = new List <string>(new string[] { "Mayonnaise", "Mustard" });
            bool          meltedCheese = false, stay = true;

            Sandwich burger1 = new Burger(bread, meat, cheese, toppings, condiments, meltedCheese, stay);
            Sandwich burger2 = new Burger();

            burger2.prepareRecipe(bread, meat, cheese, toppings, condiments, meltedCheese, stay);

            Assert.AreEqual(burger1.meat, burger2.meat);
            Assert.AreEqual(burger1.bread, burger2.bread);
            Assert.AreEqual(burger1.cheese, burger2.cheese);
            Assert.AreEqual(burger1.toppings, burger2.toppings);
            Assert.AreEqual(burger1.condiments, burger2.condiments);
            Assert.AreEqual(burger1.hotCheese, burger2.hotCheese);
        }
Exemplo n.º 22
0
        static void Main(string[] args)
        {
            var burgers = new Burger[]
            {
                new VeganBurger(),
                new WhopperBurger(),
            };

            foreach (var burger in burgers)
            {
                var burgerType = burger.GetType().Name;
                Console.WriteLine(burgerType);
                for (int i = 0; i < burger.Ingridients.Count; i++)
                {
                    var burgerIngridientsType = burger.Ingridients[i].GetType().Name;
                    Console.WriteLine(burgerIngridientsType);
                }
            }
        }
Exemplo n.º 23
0
        public async Task <ActionResult> Edit([Bind(Include = "Id,Name,BreadId,MeatId,CheeseId,SauceId,VeggieId")] Burger burger, HttpPostedFileBase ImageUrl)
        {
            if (ModelState.IsValid)
            {
                if (ImageUrl != null)
                {
                    ImageUrl.SaveAs(Server.MapPath("~/Content/BurgerImages/" + ImageUrl.FileName));
                    burger.ImageUrl = ImageUrl.FileName;
                }

                //Find and place the objects into the burger by their id
                burger.Meat   = db.Meats.Find(burger.MeatId);
                burger.Bread  = db.Breads.Find(burger.BreadId);
                burger.Sauce  = db.Sauces.Find(burger.SauceId);
                burger.Veggie = db.Veggies.Find(burger.VeggieId);
                burger.Cheese = db.Cheeses.Find(burger.CheeseId);

                //Calculate the Total Price of the burger

                burger.Price = GetTotalPrice(burger);

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

                //Dont modify property Image

                if (ImageUrl == null)
                {
                    db.Entry(burger).Property(m => m.ImageUrl).IsModified = false;
                }


                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.BreadId  = new SelectList(db.Breads, "Id", "Name", burger.BreadId);
            ViewBag.CheeseId = new SelectList(db.Cheeses, "Id", "Name", burger.CheeseId);
            ViewBag.MeatId   = new SelectList(db.Meats, "Id", "Name", burger.MeatId);
            ViewBag.SauceId  = new SelectList(db.Sauces, "Id", "Name", burger.SauceId);
            ViewBag.VeggieId = new SelectList(db.Veggies, "Id", "Name", burger.VeggieId);
            return(View(burger));
        }
Exemplo n.º 24
0
    public void nextBurger()
    {
        burger.makeInactive();
        burger = burgers[burgerNum];
        burger.makeActive();
        time = 180;
        cookedLevelGoodHigh = burger.cookedLevelGoodHigh;
        cookedLevelGoodLow  = burger.cookedLevelGoodLow;
        cookedLevelOkayHigh = burger.cookedLevelOkayHigh;
        cookedLevelOkayLow  = burger.cookedLevelOkayLow;

        okayMid           = (cookedLevelOkayHigh - cookedLevelOkayLow) / 2.0f + cookedLevelOkayLow - 50;
        okayBar.sizeDelta = new Vector2(cookedLevelOkayHigh - cookedLevelOkayLow, 20);
        okayBar.transform.localPosition = new Vector3(okayMid, okayBar.transform.localPosition.y, 1);
        goodMid           = (cookedLevelGoodHigh - cookedLevelGoodLow) / 2.0f + cookedLevelGoodLow - 50;
        goodBar.sizeDelta = new Vector2(cookedLevelGoodHigh - cookedLevelGoodLow, 20);
        goodBar.transform.localPosition = new Vector3(goodMid, goodBar.transform.localPosition.y, 1);

        playing = true;
    }
Exemplo n.º 25
0
        public void Light_Burguer_Should_Be_10_Percent_Cheaper()
        {
            const decimal discount = 0.90m;

            var repository = new TestRepository();
            var burger     = new Burger(BurgerType.XCustom.ToString(),
                                        new List <BurgerIngredient>()
            {
                new BurgerIngredient()
                {
                    Ingredient = repository.GetIngredientByType(IngredientType.Lettuce)
                }
            },
                                        BurgerType.XCustom);

            var burgerOriginalPrice = burger.Price();
            var burgerSalePrice     = burger.Price(new LightSale());

            Assert.AreEqual <decimal>(burgerOriginalPrice * discount, burgerSalePrice);
        }
Exemplo n.º 26
0
        // GET: Burger/Edit/5
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                // return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
                return(View("Error"));
            }
            Burger burger = await db.Burgers.FindAsync(id);

            if (burger == null)
            {
                return(View("Error"));
            }
            ViewBag.BreadId  = new SelectList(db.Breads, "Id", "Name", burger.BreadId);
            ViewBag.CheeseId = new SelectList(db.Cheeses, "Id", "Name", burger.CheeseId);
            ViewBag.MeatId   = new SelectList(db.Meats, "Id", "Name", burger.MeatId);
            ViewBag.SauceId  = new SelectList(db.Sauces, "Id", "Name", burger.SauceId);
            ViewBag.VeggieId = new SelectList(db.Veggies, "Id", "Name", burger.VeggieId);
            return(View(burger));
        }
Exemplo n.º 27
0
    /// <summary>
    /// checks if there's an order that matches what was served on the plate. if so, remove it from the list of active orders.
    /// </summary>
    public bool TryRemoveMatchingBurger(Dictionary <Burger.fillings, int> ingredientHistogram)
    {
        bool   ret   = false;
        Burger match = null;

        for (int i = 0; i < Used.Keys.Count(); i++)
        {
            if (Used.Keys.ElementAt(i).HistogramEquals(ingredientHistogram))
            {
                ret   = true;
                match = Used.Keys.ElementAt(i);
                break;
            }
        }
        if (match != null)
        {
            ReturnOrderToUnused(match);
        }
        return(ret);
    }
Exemplo n.º 28
0
        static void Main(string[] args)
        {
            Burger b1 = new BurgerBuilder(Size.large).AddCheese()
                        .AddLettuce()
                        .build();
            Burger b2 = new BurgerBuilder(Size.small).build();
            Burger b3 = new BurgerBuilder(Size.medium).AddTomato()
                        .AddLettuce()
                        .build();
            Burger b4 = new Burger(SpecialtyBurgerFactory.makeDeluxeBurger(Size.large));
            Burger b5 = new Burger(SpecialtyBurgerFactory.makeKidsCheeseBurger().AddPickles().AddMustard());

            Console.WriteLine("Burger1:\n" + b1.ToString());
            Console.WriteLine("Burger2:\n" + b2.ToString());
            Console.WriteLine("Burger3:\n" + b3.ToString());
            Console.WriteLine("Burger4:\n" + b4.ToString());
            Console.WriteLine("Burger5:\n" + b5.ToString());

            Console.Read();
        }
Exemplo n.º 29
0
        static void Main(string[] args)
        {
            Comida s = new Comida();
 
            Burger b;
            b = new Burger(s);
 
            Console.WriteLine("Burger com:");
            Console.WriteLine("{0:c}", b.Ingrediente);

            Console.WriteLine();
  
            Pizza p;
            p = new Pizza(s);
 
            Console.WriteLine("Pizza Com:");
            Console.WriteLine("{0:c}", p.Ingrediente);
 
            Console.ReadKey();
        }
Exemplo n.º 30
0
    //create a concept of the burger you have made

    public void CheckBurgerAgainstRecipe()
    {
        myBurger = TheBurgerIMade(bottomBunChecker);

        bool burgerFail = false;

        if (myBurger.ingredients.Count != recipe.ingredients.Count)
        {
            burgerFail = true;
        }

        for (int i = 0; i < recipe.ingredients.Count; i++)
        {
            //this iterates forward through a list

            if (i < myBurger.ingredients.Count)
            {
                Debug.Log("myburgers ingredient is " + myBurger.ingredients[i] + " and the recipe's ingredient is " + recipe.ingredients[i]);

                if (myBurger.ingredients[i] != recipe.ingredients[i])
                {
                    burgerFail = true;
                }
            }
            else //should happen if there are more ingredients in the burger or recipe
            {
                burgerFail = true;
            }
        }


        if (!burgerFail)
        {
            Debug.Log("it IS THE RIGHT BURGER");
            SceneManager.LoadScene("YouWin");
        }
        else
        {
            Debug.Log("its not the same burger");
        }
    }