コード例 #1
0
        public void Dish_compare_ingredients_test()
        {
            Ingredient ing = new Ingredient()
            {
                Name = "ing1",
                Price = 200
            };
            Ingredient ing2 = new Ingredient()
            {
                Name = "ing2",
                Price = 200
            };

            Dish dish = new Dish()
            {
                Description = "asd",
                Ingredients = new List<Ingredient>() { ing, ing2 },
                Name = "dish1",
                Status = 0
            }; Dish dish2 = new Dish()
            {
                Description = "asd",
                Ingredients = new List<Ingredient>() { ing, ing2 },

                Name = "dish1",
                Status = 0
            };

            Assert.IsTrue(dish.Equals(dish2));
            dish.Ingredients.Add(new Ingredient() { Name = "changed", Price = 0 });

            Assert.IsFalse(dish.Equals(dish2));
            Assert.IsFalse(dish.Equals(null));
        }
コード例 #2
0
	private bool IngredientMatches(IngredientBase item, Ingredient ingredient)
	{
        if (item.burnt)
        {
            return false;
        }

		// not right type
		if (ingredient.Type != item.Type) return false;

		// incorrect number of operations done
		if (ingredient.Tasks.Count != item.TasksDone.Count) return false;

		for (int i = 0; i < item.TasksDone.Count; i++)
		{
			if (item.TasksDone[i] != ingredient.Tasks[i])
			{
				// wrong operation done
				return false;
			}
		}

		// aaaaaaaaaaaaallllllllllllllllgggggggggggggggg
		return true;
	}
コード例 #3
0
ファイル: InventoryItem.cs プロジェクト: bradur/FGJ-2016
    public void Init(Ingredient ingredient)
    {
        bool buyable = false;
        if (pickup != null)
        {
            Entity pickupEntity = pickup.GetComponent<Entity>();
            if (pickupEntity != null)
            {
                buyable = pickupEntity.Buyable;
            }
        }

        imgComponent.sprite = ingredient.Sprite;
        if (ingredient.AnimalType != AnimalType.None)
        {
            txtComponent.text = ingredient.AnimalType + " " + ingredient.AnimalState;
            if (buyable)
            {
                txtComponent.text += " " + ingredient.Cost + "$";
            }
        }
        else
        {
            txtComponent.text = ingredient.GatheredState + " " + ingredient.GatheredType;
            if (buyable)
            {
                txtComponent.text += " " + ingredient.Cost + "$";
            }
        }
        this.ingredient = ingredient;
    }
コード例 #4
0
        protected override void Before_all_specs()
        {
            SetupDatabase(ShopGunSpecBase.Database.ShopGun, typeof(Base).Assembly);
            

            var ingredient1 = new Ingredient {IngredientName = "Hop", LastUpdated = DateTime.Now};
            var ingredient2 = new Ingredient {IngredientName = "Malt", LastUpdated = DateTime.Now};
            var ingredient3 = new Ingredient {IngredientName = "Water", LastUpdated = DateTime.Now };

            _ingredientRepository = new Repository<Ingredient>(GetNewDataContext());
            _ingredientRepository.Add(ingredient1);
            _ingredientRepository.Add(ingredient2);
            _ingredientRepository.Add(ingredient3);
            _ingredientRepository.Persist();

            _product = ProductBuilder.BuildProduct();
            _product.AddIngredient(ingredient1);
            _product.AddIngredient(ingredient2);
            _product.AddIngredient(ingredient3);
            _productRepository = new Repository<Product>(GetNewDataContext());
            _productRepository.Add(_product);
            _productRepository.Persist();

            base.Before_each_spec();
        }
コード例 #5
0
ファイル: Icecream.cs プロジェクト: vsmida/ThreadingTalk
 public void AddIngredient( Ingredient ingredient, double volume )
 {
     double currentIngredientVolume;
     this.composition.TryGetValue( ingredient, out currentIngredientVolume );
     this.TotalVolume += volume;
     this.composition[ingredient] = currentIngredientVolume + volume;
 }
コード例 #6
0
ファイル: InventoryManager.cs プロジェクト: bradur/FGJ-2016
    public void AddItem(Ingredient itemToAdd)
    {
        if (items.Count >= inventoryLimit)
        {
            // inventory is full!
        }
        else
        {

            int factor = items.Count;
            if (factor > 2)
            {
                level = factor / 3;
                factor = factor % 3;
            }

            InventoryItem newItem = Instantiate(
                inventoryItemPrefab,
                new Vector3(
                    factor * gridMemberSize + factor * horizontal_padding + border_padding,
                    -(level * gridMemberSize + level * vertical_padding + border_padding),
                    0f
                ),
                Quaternion.identity) as InventoryItem;
            newItem.transform.SetParent(inventoryParent, false);
            newItem.Init(itemToAdd);
            items.Add(newItem);
        }

    }
コード例 #7
0
ファイル: PlayerHand.cs プロジェクト: hubatish/barVR
 public void MoveTo(Ingredient ingredient, Transform t, TweenCallback callback)
 {
     //Should tween
     //ingredient.transform.position = t.position;
     ingredient.GetComponent<Rigidbody>().DOMove(t.position, 1f).OnComplete(callback);
     ingredient.GetComponent<Rigidbody>().velocity = Vector3.zero;
 }
コード例 #8
0
        public void Menu_add_throws_exception_on_updated_dish_test()
        {
            Facade facade = new Facade();

            Ingredient ing1 = new Ingredient() { Name = "ing1", Price = 10 };
            Ingredient ing2 = new Ingredient() { Name = "ing2", Price = 12 };
            Ingredient ing3 = new Ingredient() { Name = "ing3", Price = 13 };
            Ingredient ing4 = new Ingredient() { Name = "ing4", Price = 15 };

            ing1 = facade.IngredientRepo().Add(ing1);
            ing2 = facade.IngredientRepo().Add(ing2);
            ing3 = facade.IngredientRepo().Add(ing3);
            ing4 = facade.IngredientRepo().Add(ing4);

            Dish dish1 = new Dish() { Description = "descrip 1", Name = "dish1", Status = 0, Ingredients = new List<Ingredient>() { ing1, ing2 } };
            Dish dish2 = new Dish() { Description = "descrip 2", Name = "dish2", Status = 1, Ingredients = new List<Ingredient>() { ing3, ing4 } };
            Dish dish3 = new Dish() { Description = "descrip 3", Name = "dish3", Status = 3, Ingredients = new List<Ingredient>() { ing1, ing2, ing3, ing4 } };

            dish1 = facade.DishRepo().Add(dish1);
            dish2 = facade.DishRepo().Add(dish2);
            dish3 = facade.DishRepo().Add(dish3);
            dish1.Name = "changed";
            Menu menu = new Menu() { Dishes = new List<Dish> { dish1, dish2, dish3 }, Name = "menu1" };
            menu = facade.MenuRepo().Add(menu);
        }
コード例 #9
0
        public void Dish_add_throws_exception_on_updated_ingredient_test()
        {
            Facade facade = new Facade();

            Ingredient ing2 = new Ingredient()
            {
                Name = "ing2",
                Price = 200
            };

            ing2 = facade.IngredientRepo().Add(ing2);

            ing2.Name = "Changed";
            List<Ingredient> list = new List<Ingredient>();
            list.Add(ing2);

            facade = new Facade();
            Dish dish = new Dish()
            {
                Description = "asd",
                Ingredients = list,
                Name = "dish1",
                Status = 0
            };
            dish = facade.DishRepo().Add(dish);
        }
コード例 #10
0
ファイル: Container.cs プロジェクト: Stumpstump/RoverGame
        public virtual void RemoveInventoryItem(Ingredient ingredient, int count)
        {
            if(ingredient != null)
            {
                if (ingredientsInInventory.Count < count)
                {
                    Debug.LogError("unable to comply, insufficient inventory ingredients");
                    return;
                }

                while (count > 0)
                {
                    for (int i = 0; i < ingredientsInInventory.Count; i++)
                    {
                        if (ingredientsInInventory[i].id == ingredient.id)
                        {
                            ingredientsInInventory.RemoveAt(i);
                            count--;
                            break;
                        }
                    }
                }

                InitializeInventorySlots();
            }
        }
コード例 #11
0
        public void Starting()
        {

            //Testing ListOfIngredients
            Ingredient F1 = new Ingredient("Banana", 500, 3000);
            Ingredient F2 = new Ingredient("Apple", 700, 3300);
            //#########################

            ProductVarietyCmbBx.Items.Add(G3Controller.ProductVariety.Luxury);
            ProductVarietyCmbBx.Items.Add(G3Controller.ProductVariety.Everyday);
            ProductVarietyCmbBx.Items.Add(G3Controller.ProductVariety.Discount);

            ProductSizeCmbBx.Items.Add(G3Controller.ProductSizeLuxury.g175);
            ProductSizeCmbBx.Items.Add(G3Controller.ProductSizeLuxury.g350);
            ProductSizeCmbBx.Items.Add(G3Controller.ProductSizeEveryDAy.g400);
            ProductSizeCmbBx.Items.Add(G3Controller.ProductSizeEveryDAy.g600);
            ProductSizeCmbBx.Items.Add(G3Controller.ProductSizeEveryDAy.g800);
            ProductSizeCmbBx.Items.Add(G3Controller.ProductSizeDiscount.g500);
            ProductSizeCmbBx.Items.Add(G3Controller.ProductSizeDiscount.g1000);

            ContainerTypeCmbBx.Items.Add(G3Controller.ContainerType.Jar);
            ContainerTypeCmbBx.Items.Add(G3Controller.ContainerType.Plastic);

            for (int i = 0; i < G3Controller.ListOfIngredients.Count; i++)
            {
                string NameOfIngredient = G3Controller.ListOfIngredients[i].Type;
                IngredientOneCmbBx.Items.Add(NameOfIngredient);
                IngredientTwoCmbBx.Items.Add(NameOfIngredient);
            }

        }
コード例 #12
0
ファイル: Alchemy.cs プロジェクト: Somfin/TroubleBrewing
 public override void process(Ingredient ingredient)
 {
     if (!ingredientSet)
     {
         currentIngredient = ingredient;
         ingredientSet = true;
     }
     else
     {
         bool comboFound = false;
         foreach (GameObject combination in combinations)
         {
             Combination combo = combination.GetComponent<Combination>();
             if ((combo.in1 == currentIngredient && combo.in2 == ingredient)
                 || (combo.in2 == currentIngredient && combo.in1 == ingredient))
             {
                 comboFound = true;
                 GameObject combined = GameObject.Instantiate(combo.combinedIngredient) as GameObject;
                 combined.transform.position = spawnPoint.transform.position;
             }
         }
         if (!comboFound)
         {
             // failure event
         }
         else
         {
             GetComponent<AudioSource>().Stop();
             GetComponent<AudioSource>().Play();
         }
         ingredientSet = false;
     }
 }
コード例 #13
0
        protected override void Before_all_specs()
        {
            SetupDatabase(ShopGunSpecBase.Database.ShopGun, typeof(Base).Assembly);

            IConfiguration configuration = new BasicConfiguration();
            var container = configuration.Container;

            _ingredientRepository = new IngredientRepository(GetNewDataContext());
            _semaphoreRepository = new Repository<Semaphore>(GetNewDataContext());
            _mentorRepository = new Repository<Mentor>(GetNewDataContext());

            _ingredientAdviceRepository = new Repository<IngredientAdvice>(GetNewDataContext());
            _ingredientAdviceDomainService = new IngredientAdviceDomainService(_ingredientRepository,
                                                                               _ingredientAdviceRepository,
                                                                               GetNewDataContext());

           

            _mentor = MentorBuilder.BuildMentor();
            _mentorRepository.Add(_mentor);
            _mentorRepository.Persist();

            _redSemaphore = SemaphoreBuilder.BuildRedSemaphore();
            _semaphoreRepository.Add(_redSemaphore);
            _greenSemaphore = SemaphoreBuilder.BuildGreenSemaphore();
            _semaphoreRepository.Add(_greenSemaphore);
            _semaphoreRepository.Persist();

            _ingredient = IngredientBuilder.BuildIngredient();
            _ingredientRepository.Add(_ingredient);
            _ingredientRepository.Persist();

            base.Before_each_spec();
        }
コード例 #14
0
        public ActionResult CreateIngredient(Ingredient ingredient, FormCollection form)
        {
            //if (ModelState.IsValid)
            //{

            //Ingredient ingredient = new Ingredient();
            // Deserialize (Include white list!)
            bool isModelUpdated = TryUpdateModel(ingredient, new[] { "IngredientName" }, form.ToValueProvider());
            
            // Validate
            if (String.IsNullOrEmpty(ingredient.IngredientName))
                ModelState.AddModelError("IngredientName", "Ingredient Name is required!");

            if (ModelState.IsValid)
            {
                var newIngredient = _ingredientApplicationService.CreateIngredient(ingredient.IngredientName);

                if (newIngredient != null)
                {
                    return RedirectToAction("EditIngredient", new{id = newIngredient.Id});
                }
                ModelState.AddModelError("IngredientName", "Ingredient or AlternativeIngredientName already exists!");
            }

            return View(ingredient);
        }
コード例 #15
0
ファイル: Pot.cs プロジェクト: smokingpot/smokingpot
 public void OnIngredientCaught(Ingredient ingredient)
 {
     if (IngredientCaught != null)
     {
         IngredientCaught(ingredient);
     }
 }
コード例 #16
0
ファイル: ToolTip.cs プロジェクト: Stumpstump/RoverGame
        /// <summary>
        /// initialize to ingredient details
        /// </summary>
        /// <param name="ingredient"></param>
        public void SetContent(Ingredient ingredient)
        {
            titleText.text = ingredient.displayName;
            descriptionText.text = ingredient.description;

            gameObject.GetComponent<RectTransform>().position = new Vector3 (Input.mousePosition.x - 1024f, Input.mousePosition.y - 768f, 0f);
        }
コード例 #17
0
        public Menu MakeMenu()
        {
            Facade facade = new Facade();

            Ingredient ing1 = new Ingredient() { Name = "ing1", Price = 10 };
            Ingredient ing2 = new Ingredient() { Name = "ing2", Price = 12 };
            Ingredient ing3 = new Ingredient() { Name = "ing3", Price = 13 };
            Ingredient ing4 = new Ingredient() { Name = "ing4", Price = 15 };

            ing1 = facade.IngredientRepo().Add(ing1);
            ing2 = facade.IngredientRepo().Add(ing2);
            ing3 = facade.IngredientRepo().Add(ing3);
            ing4 = facade.IngredientRepo().Add(ing4);

            Dish dish1 = new Dish() { Description = "descrip 1", Name = "dish1", Status = 0, Ingredients = new List<Ingredient>() { ing1, ing2 } };
            Dish dish2 = new Dish() { Description = "descrip 2", Name = "dish2", Status = 1, Ingredients = new List<Ingredient>() { ing3, ing4 } };
            Dish dish3 = new Dish() { Description = "descrip 3", Name = "dish3", Status = 3, Ingredients = new List<Ingredient>() {ing1, ing2, ing3, ing4 } };

            dish1 = facade.DishRepo().Add(dish1);
            dish2 = facade.DishRepo().Add(dish2);
            dish3 = facade.DishRepo().Add(dish3);

            Menu menu = new Menu() { Dishes = new List<Dish> { dish1, dish2, dish3 }, Name = "menu1" };
            menu = facade.MenuRepo().Add(menu);
            return menu;
        }
コード例 #18
0
        public void Dish_getall_includes_ingredients_test()
        {
            Facade facade = new Facade();
            Ingredient ing = new Ingredient()
            {
                Name = "ing1",
                Price = 200
            };
            Ingredient ing2 = new Ingredient()
            {
                Name = "ing2",
                Price = 200
            };
            ing = facade.IngredientRepo().Add(ing);
            ing2 = facade.IngredientRepo().Add(ing2);

            List<Ingredient> list = new List<Ingredient>();
            list.Add(ing);
            list.Add(ing2);

            facade = new Facade();
            Dish dish = new Dish()
            {
                Description = "asd",
                Ingredients = list,
                Name = "dish1",
                Status = 0
            };
            dish = facade.DishRepo().Add(dish);
            facade = new Facade();

            Assert.AreEqual(facade.DishRepo().GetAll().ToList().FirstOrDefault(x => x.Id == dish.Id).Ingredients.Count, 2);
        }
コード例 #19
0
ファイル: Recipe.cs プロジェクト: Somfin/TroubleBrewing
 public bool ingredientCheck(int index, Ingredient next)
 {
     if (ingredients[index] == next){
         return true;
     }
     return false;
 }
コード例 #20
0
    public Ingredient PostSave(Ingredient ingredient) {
        if (ingredient.Id > 0)
            DatabaseContext.Database.Update(ingredient);
        else
            DatabaseContext.Database.Save(ingredient);

        return ingredient;
    }
コード例 #21
0
ファイル: ToolTip.cs プロジェクト: Stumpstump/RoverGame
        /// <summary>
        /// Open tooltip and initialize to ingredient values
        /// </summary>
        /// <param name="ingredient"></param>
        public virtual void Open(Ingredient ingredient)
        {
            titleText.text = ingredient.displayName;
            descriptionText.text = ingredient.description;

            gameObject.GetComponent<RectTransform>().position = Input.mousePosition;
            Open();
        }
コード例 #22
0
ファイル: UIDragManager.cs プロジェクト: AntlerOwl/GGJ-Demons
    public void BeginDrag(Ingredient ingredient, int fromSummonSlot = -1)
    {
        

        dragImage.gameObject.SetActive(true);
        dragImage.sprite = ingredient.icon;
        curIngredient = ingredient;
        this.fromSummonSlot = fromSummonSlot;
    }
コード例 #23
0
 public static bool IsInChoices(Ingredient.INGREDIENT_TYPE other)
 {
     for (int i = 0; i < answerChoices.Length; i++) {
         if (other == answerChoices[i]) {
             return true;
         }
     }
     return false;
 }
コード例 #24
0
 public static void AddAnswerChoice(Ingredient ingredient)
 {
     if (curPlayerNum > playerChoices.Length) {
         Debug.Log("OUT OF ARRAY");
         return;
     }
     answerChoices [curAnswerNum] = ingredient.GetType();
     curAnswerNum++;
 }
コード例 #25
0
 public IngredientEntry(Ingredient i, Measurement m, string amount)
 {
     _ingredient = i;
     _measurement = m;
     if(!double.TryParse(amount, out _amount))
     {
         _amount = 0.00;
     }
 }
コード例 #26
0
ファイル: QuestRequirement.cs プロジェクト: bradur/FGJ-2016
    public bool Check(Ingredient ingredient)
    {
        bool match = true;
        if (animalType == AnimalType.Any)
        {
            if(ingredient.AnimalType == AnimalType.None)
            {
                match = false;
            }
        }
        else if (animalType != ingredient.AnimalType)
        {
            match = false;
        }
        if (animalState == AnimalState.Any)
        {
            if (ingredient.AnimalState == AnimalState.None)
            {
                match = false;
            }
        }
        else if (animalState != ingredient.AnimalState)
        {
            match = false;
        }

        if (gatheredType == GatheredType.Any)
        {
            if (ingredient.GatheredType == GatheredType.None)
            {
                match = false;
            }
        }
        else if (gatheredType == GatheredType.AnyPlant)
        {
            if (ingredient.GatheredType != GatheredType.Flower && ingredient.GatheredType != GatheredType.Weed)
            {
                match = false;
            }
        }
        else if (gatheredType != ingredient.GatheredType)
        {
            match = false;
        }
        if (gatheredState == GatheredState.Any)
        {
            if (ingredient.GatheredState == GatheredState.None)
            {
                match = false;
            }
        }
        else if (gatheredState != ingredient.GatheredState)
        {
            match = false;
        }
        return match;
    }
コード例 #27
0
 //returns true if something is in choices
 private bool IsInChoices(Ingredient.INGREDIENT_TYPE other)
 {
     for (int i = 0; i < choices.Length; i++) {
         if (other == choices[i].GetType()) {
             return true;
         }
     }
     return false;
 }
コード例 #28
0
ファイル: Container.cs プロジェクト: Stumpstump/RoverGame
 public virtual void AddInventoryItem(Ingredient ingredient, int count)
 {
     for (int i = count; i > 0; i--)
     {
         ingredientsInInventory.Add(ingredient);
     }
     Debug.Log("item added");
     InitializeInventorySlots();
 }
コード例 #29
0
ファイル: MenuItem.cs プロジェクト: bjorntore/KebabOslo
 public MenuItem()
 {
     Name = "Kebab";
     MeatType = IngredientDB.Meats.OrderBy(x => x.Cost).First();
     VegetableType = IngredientDB.Vegetables.OrderBy(x => x.Cost).First();
     SauceType = IngredientDB.Sauces.OrderBy(x => x.Cost).First();
     Price = Convert.ToInt32(GetProductionCost() * 1.3);
     IsActive = false;
 }
コード例 #30
0
ファイル: Ingredient.cs プロジェクト: FreeReign/imaginenation
		public static IngredientInfo Get( Ingredient ingredient )
		{
			int index = (int)ingredient;

			if ( index >= 0 && index < m_Table.Length )
				return m_Table[index];
			else
				return m_Table[0];
		}
コード例 #31
0
 public PizzaBuilder AddIngredient(Ingredient newIngredient)
 {
     Ingredients.Add(newIngredient);
     return(this);
 }
コード例 #32
0
 public Tomato(Ingredient ingredient) : base(ingredient)
 {
     this.ingredient = ingredient;
 }
コード例 #33
0
 public ActionResult Update(Ingredient request)
 {
     _ingredientService.Update(request);
     return(RedirectToAction(Request.Form["View"], EntityType.Ingredient.ToString()));
 }
コード例 #34
0
 public IActionResult createIngredient(Ingredient ing)
 {
     _context.ingredients.Add(ing);
     _context.SaveChanges();
     return(RedirectToAction("adminIngredients"));
 }
コード例 #35
0
    public double profit;    // the profit text: "Profit: $"

    public RestaurantRecipe(double userInputCost, Recipe recipeInfo, List <Tech> upgrades)
    {
        manufacturingCost = 0.0;
        recipe            = recipeInfo;
        for (int i = 0; i < recipeInfo.ingredients.Length; i++)
        {
            double ingredientPrice = 0;
            ingredientPrice = (Ingredient.IngredientCost(recipe.ingredients[i].ingredient) * (Ingredient.TierToMultiplier(recipe.ingredients[i].tier)));

            if (upgrades.Contains(Tech.STEAK_HOUSE) && (int)recipe.ingredients[i].ingredient < 5 && (int)recipe.ingredients[i].ingredient >= 0)
            {
                ingredientPrice *= 0.95;
                Debug.Log("Your meat costs 5% less due to steak house upgrade");
            }
            if (upgrades.Contains(Tech.CUTTING_CORNERS) && recipe.ingredients[i].tier == 0)
            {
                ingredientPrice *= 0.90;
                Debug.Log("Your tier 0 ingredient costs 10% less due to cutting corners upgrade");
            }
            if (upgrades.Contains(Tech.FRESH_PRODUCE) && (int)recipe.ingredients[i].ingredient >= 20)
            {
                ingredientPrice *= 0.90;
                Debug.Log("Your misc ingredient costs 10% less due to fresh produce upgrade");
            }
            if (upgrades.Contains(Tech.CHEAPER_INGREDIENTS))
            {
                ingredientPrice *= 0.90;
                Debug.Log("Your ingredients costs 10% less due to cheaper ingredients upgrade");
            }
            manufacturingCost += ingredientPrice;

            Debug.Log("Manu facturing cost is " + manufacturingCost + " right now");
        }

        sellingPrice = userInputCost;   //Set selling Price
        baseCost     = userInputCost;
        profit       = 0.0;
        multiplier   = 1f;
        theoreticalManufacturingCost = manufacturingCost;
    }
コード例 #36
0
 public void RemoveAllergen(Patient patient, Ingredient allergen)
 {
     _patientService.RemoveAllergen(patient, allergen);
 }
コード例 #37
0
        public async Task <ViewResult> DatabaseOperations()
        {
            // CREATE operation
            Company MyCompany = new Company();

            MyCompany.symbol    = "MCOB";
            MyCompany.name      = "ISM";
            MyCompany.date      = "ISM";
            MyCompany.isEnabled = true;
            MyCompany.type      = "ISM";
            MyCompany.iexId     = "ISM";

            Quote MyCompanyQuote1 = new Quote();

            //MyCompanyQuote1.EquityId = 123;
            MyCompanyQuote1.date             = "11-23-2018";
            MyCompanyQuote1.open             = 46.13F;
            MyCompanyQuote1.high             = 47.18F;
            MyCompanyQuote1.low              = 44.67F;
            MyCompanyQuote1.close            = 47.01F;
            MyCompanyQuote1.volume           = 37654000;
            MyCompanyQuote1.unadjustedVolume = 37654000;
            MyCompanyQuote1.change           = 1.43F;
            MyCompanyQuote1.changePercent    = 0.03F;
            MyCompanyQuote1.vwap             = 9.76F;
            MyCompanyQuote1.label            = "Nov 23";
            MyCompanyQuote1.changeOverTime   = 0.56F;
            MyCompanyQuote1.symbol           = "MCOB";

            Quote MyCompanyQuote2 = new Quote();

            //MyCompanyQuote1.EquityId = 123;
            MyCompanyQuote2.date             = "11-23-2018";
            MyCompanyQuote2.open             = 46.13F;
            MyCompanyQuote2.high             = 47.18F;
            MyCompanyQuote2.low              = 44.67F;
            MyCompanyQuote2.close            = 47.01F;
            MyCompanyQuote2.volume           = 37654000;
            MyCompanyQuote2.unadjustedVolume = 37654000;
            MyCompanyQuote2.change           = 1.43F;
            MyCompanyQuote2.changePercent    = 0.03F;
            MyCompanyQuote2.vwap             = 9.76F;
            MyCompanyQuote2.label            = "Nov 23";
            MyCompanyQuote2.changeOverTime   = 0.56F;
            MyCompanyQuote2.symbol           = "MCOB";

            dbContext.Companies.Add(MyCompany);
            dbContext.Quotes.Add(MyCompanyQuote1);
            dbContext.Quotes.Add(MyCompanyQuote2);

            dbContext.SaveChanges();

            // READ operation
            Company CompanyRead1 = dbContext.Companies
                                   .Where(c => c.symbol == "MCOB")
                                   .First();

            Company CompanyRead2 = dbContext.Companies
                                   .Include(c => c.Quotes)
                                   .Where(c => c.symbol == "MCOB")
                                   .First();

            // UPDATE operation
            CompanyRead1.iexId = "MCOB";
            dbContext.Companies.Update(CompanyRead1);
            //dbContext.SaveChanges();
            await dbContext.SaveChangesAsync();

            // DELETE operation
            //dbContext.Companies.Remove(CompanyRead1);
            //await dbContext.SaveChangesAsync();

            Recipe MyRecipe = new Recipe();

            MyRecipe.recipeId   = "1";
            MyRecipe.recipeName = "Chicken Marsala";

            Recipe MyRecipe2 = new Recipe();

            MyRecipe2.recipeId   = "2";
            MyRecipe2.recipeName = "Salisbury Steak";

            Ingredient MyIngredient = new Ingredient();

            MyIngredient.ingredientId   = "1";
            MyIngredient.ingredientName = "Chicken";

            Ingredient MyIngredient2 = new Ingredient();

            MyIngredient2.ingredientId   = "2";
            MyIngredient2.ingredientName = "Beef";

            Preparation MyPreparation = new Preparation();

            MyPreparation.menu = "Dinner";

            dbContext.Ingredients.Add(MyIngredient);
            dbContext.Ingredients.Add(MyIngredient2);
            dbContext.Recipes.Add(MyRecipe);
            dbContext.Recipes.Add(MyRecipe2);

            dbContext.Preparations.Add(MyPreparation);

            dbContext.SaveChanges();


            return(View());
        }
コード例 #38
0
 public Step(Commands command, Ingredient ingredient)
 {
     this.command    = command;
     this.ingredient = ingredient;
 }
コード例 #39
0
        public static void Initialize(
            ApplicationDbContext context,
            UserManager <ApplicationUser> userManager,
            RoleManager <IdentityRole> roleManager)
        {
            // Users & Roles
            var adminRole = new IdentityRole {
                Name = "Admin"
            };
            var roleResult = roleManager.CreateAsync(adminRole).Result;

            var aUser = new ApplicationUser
            {
                UserName     = "******",
                Email        = "*****@*****.**",
                Address      = "sjövägen 3",
                Zipcode      = "11320",
                CustomerName = "Kunden",
                PhoneNumber  = "0720302020"
            };

            var adminUser = new ApplicationUser
            {
                UserName     = "******",
                Email        = "*****@*****.**",
                Address      = "sjövägen 3",
                Zipcode      = "11320",
                CustomerName = "Admin",
                PhoneNumber  = "0720302020"
            };

            var userResult      = userManager.CreateAsync(aUser, "pass").Result;
            var adminUserResult = userManager.CreateAsync(adminUser, "pass").Result;
            var adminRoleResult = userManager.AddToRoleAsync(adminUser, "Admin").Result;

            // Ingredients
            var cheese = new Ingredient {
                Name = "Cheese", AddExtraPrice = 5, IsActive = true
            };
            var tomatoe = new Ingredient {
                Name = "Tomatoe", AddExtraPrice = 5, IsActive = true
            };
            var ham = new Ingredient {
                Name = "Ham", AddExtraPrice = 10, IsActive = true
            };
            var mushroom = new Ingredient {
                Name = "Mushroom", AddExtraPrice = 10, IsActive = true
            };
            var pineapple = new Ingredient {
                Name = "Pineapple", AddExtraPrice = 10, IsActive = true
            };

            // Categories
            var pizza = new Category {
                Name = "Pizza", IsActive = true
            };
            var pasta = new Category {
                Name = "Pasta", IsActive = true
            };

            // Dishes
            var capricciosa = new BaseDish {
                Name = "Capricciosa", Price = 100, IsActive = true, Category = pizza
            };
            var margherita = new BaseDish {
                Name = "Margherita", Price = 90, IsActive = true, Category = pizza
            };
            var hawaii = new BaseDish {
                Name = "Hawaii", Price = 100, IsActive = true, Category = pizza
            };
            var pastacarbonara = new BaseDish {
                Name = "Pasta carbonara", Price = 90, IsActive = true, Category = pasta
            };

            // Orders
            var order1 = new Order
            {
                TotalPrice  = 200,
                User        = aUser,
                OrderDate   = DateTime.Now,
                Address     = "Testvägen 3",
                Email       = "*****@*****.**",
                PhoneNumber = "23920323223",
                Zipcode     = "12321",
                IsComplete  = true
            };
            var order2 = new Order
            {
                TotalPrice  = 100,
                OrderDate   = DateTime.Now,
                Address     = "Testvägen 3",
                Email       = "*****@*****.**",
                PhoneNumber = "23920323223",
                Zipcode     = "12321",
                IsComplete  = false
            };

            var orderedDish1 = new OrderedDish {
                Name = "Capricciosa", Price = 100, Category = pizza
            };

            orderedDish1.OrderedDishIngredients = new List <OrderedDishIngredient>
            {
                new OrderedDishIngredient {
                    OrderedDish = orderedDish1, Ingredient = cheese
                },
                new OrderedDishIngredient {
                    OrderedDish = orderedDish1, Ingredient = tomatoe
                },
                new OrderedDishIngredient {
                    OrderedDish = orderedDish1, Ingredient = ham
                },
                new OrderedDishIngredient {
                    OrderedDish = orderedDish1, Ingredient = mushroom
                }
            };

            var orderedDish2 = new OrderedDish {
                Name = "Margaritha", Price = 90, Category = pizza
            };

            orderedDish2.OrderedDishIngredients = new List <OrderedDishIngredient>
            {
                new OrderedDishIngredient {
                    OrderedDish = orderedDish2, Ingredient = cheese
                },
                new OrderedDishIngredient {
                    OrderedDish = orderedDish2, Ingredient = tomatoe
                },
                new OrderedDishIngredient {
                    OrderedDish = orderedDish2, Ingredient = mushroom
                }
            };

            var orderedDish3 = new OrderedDish {
                Name = "Hawaii", Price = 100, Category = pizza
            };

            orderedDish3.OrderedDishIngredients = new List <OrderedDishIngredient>
            {
                new OrderedDishIngredient {
                    OrderedDish = orderedDish3, Ingredient = cheese
                },
                new OrderedDishIngredient {
                    OrderedDish = orderedDish3, Ingredient = tomatoe
                },
                new OrderedDishIngredient {
                    OrderedDish = orderedDish3, Ingredient = ham
                },
                new OrderedDishIngredient {
                    OrderedDish = orderedDish3, Ingredient = pineapple
                }
            };

            capricciosa.BaseDishIngredients = new List <BaseDishIngredient>
            {
                new BaseDishIngredient {
                    BaseDish = capricciosa, Ingredient = cheese
                },
                new BaseDishIngredient {
                    BaseDish = capricciosa, Ingredient = tomatoe
                },
                new BaseDishIngredient {
                    BaseDish = capricciosa, Ingredient = ham
                },
                new BaseDishIngredient {
                    BaseDish = capricciosa, Ingredient = mushroom
                }
            };

            margherita.BaseDishIngredients = new List <BaseDishIngredient>
            {
                new BaseDishIngredient {
                    BaseDish = margherita, Ingredient = cheese
                },
                new BaseDishIngredient {
                    BaseDish = margherita, Ingredient = ham
                }
            };

            hawaii.BaseDishIngredients = new List <BaseDishIngredient>
            {
                new BaseDishIngredient {
                    BaseDish = hawaii, Ingredient = cheese
                },
                new BaseDishIngredient {
                    BaseDish = hawaii, Ingredient = ham
                },
                new BaseDishIngredient {
                    BaseDish = hawaii, Ingredient = pineapple
                }
            };

            order1.OrderedDishes = new List <OrderedDish> {
                orderedDish1, orderedDish2
            };
            order2.OrderedDishes = new List <OrderedDish> {
                orderedDish3
            };

            context.AddRange(cheese, tomatoe, ham, mushroom, pineapple);
            context.AddRange(capricciosa, margherita, hawaii, pastacarbonara);
            context.AddRange(order1, order2);
            context.AddRange(orderedDish1, orderedDish2, orderedDish3);
            context.AddRange(pizza, pasta);

            context.SaveChanges();
        }
コード例 #40
0
 public void Delete(Ingredient ingredient)
 {
     foodContext.Ingredients.Remove(ingredient);
     foodContext.SaveChanges();
 }
コード例 #41
0
 public Ingredients MapIngredient(Ingredient ingredient)
 {
     return(new Ingredients());
 }
コード例 #42
0
 public void Add(Ingredient ingredient)
 {
     foodContext.Ingredients.Add(ingredient);
     foodContext.SaveChanges();
 }
コード例 #43
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (textBox1.Text.Equals("") || textBox1.Text.Equals(string.Empty))
            {
                tabControl1.SelectTab(0);
                MessageBox.Show("Please select table first!");
                return;
            }

            if (listView2.Items.Count <= 0)
            {
                MessageBox.Show("Please insert at least one order!");
                return;
            }

            int tableId = data.Tables.Where(x => x.tableNo.Equals(textBox1.Text)).Select(x => x.tableId).First();

            Order o = new Order();

            o.tableId    = tableId;
            o.status     = "in progress";
            o.totalPrice = decimal.Parse(label15.Text);
            o.createdAt  = DateTime.Now;
            o.updatedAt  = DateTime.Now;

            try
            {
                data.Orders.Add(o);

                Table tbl = data.Tables.Find(tableId);
                tbl.status = "booked";

                try
                {
                    foreach (ListViewItem items in listView2.Items)
                    {
                        OrderDetail od = new OrderDetail();
                        od.orderId  = o.orderId;
                        od.menuId   = int.Parse(items.SubItems[0].Text);
                        od.qty      = int.Parse(items.SubItems[2].Text);
                        od.price    = decimal.Parse(items.SubItems[3].Text) / int.Parse(items.SubItems[2].Text);
                        od.subTotal = decimal.Parse(items.SubItems[3].Text);
                        od.status   = "in progress";

                        try
                        {
                            data.OrderDetails.Add(od);

                            var menuIngredients = data.MenuIngredients.Where(x => x.menuId.Equals(od.menuId)).ToList();
                            foreach (var b in menuIngredients)
                            {
                                Ingredient ingredient = data.Ingredients.Find(b.ingredientsId);
                                if (ingredient.stock >= (b.qty * od.qty))
                                {
                                    ingredient.stock -= (b.qty * od.qty);
                                }
                                else
                                {
                                    MessageBox.Show("Sorry, stock of ingredients for the menu is out of stock");
                                    return;
                                }

                                try
                                {
                                    data.SaveChanges();
                                }
                                catch (Exception ex)
                                {
                                    MessageBox.Show(ex.ToString());
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                    }

                    MessageBox.Show("Thank you, order in progress..");
                    button6.PerformClick();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #44
0
ファイル: MainForm.cs プロジェクト: khoacoivn/ProjectOOSD
        public void AddIngredient(Ingredient ingredient)
        {
            data.ingredientsList.Add(ingredient);

            SetUpGrid(ingredientsGrid, data.ingredientsList.ToArray());
        }
コード例 #45
0
 public Guacamole(Ingredient ingredient) : base(ingredient)
 {
     this.ingredient = ingredient;
     //this.Description = "Chicken";
     //this.Price1 = 15;
 }
コード例 #46
0
 public IngredientChangeWindowViewModel(Ingredient Ing)
 {
     MeaningIng = Ing;
     name       = MeaningIng.Name.ToString();
 }
コード例 #47
0
 public void AddAllergen(Patient patient, Ingredient allergen)
 {
     _patientService.AddAllergen(patient, allergen);
 }
コード例 #48
0
        public static void SandboxCode(IServiceProvider serviceProvider)
        {
            Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);

            var siteUrl = @"http://www.1001recepti.com/recipes/";
            var web     = new HtmlWeb {
                OverrideEncoding = Encoding.GetEncoding("windows-1251")
            };
            var doc = web.Load(siteUrl);

            var categories = doc.DocumentNode.SelectNodes(".//div[@id='cont_recipe_browse_big']//div").Take(7);

            foreach (var category in categories)
            {
                var categoryName = category.InnerText.Trim();
                var url          = category.SelectSingleNode(".//a").Attributes["href"].Value;
                var db           = serviceProvider.GetService <AppRContext>();

                try
                {
                    var doc1    = web.Load(url);
                    var recipes = doc1.DocumentNode.SelectNodes(@".//table[@class='rec search_results']");

                    for (int i = 0; i < 5; i++)
                    {
                        var recipeUrl          = recipes[i].SelectSingleNode(@".//td[@class='td1']//a");
                        var recipeSmallPicture = recipes[i].SelectSingleNode(@".//img[@class='pic']")?.Attributes["src"]?.Value;
                        var recipeName         = recipeUrl.InnerText.Trim();
                        var recipeDoc          = web.Load(recipeUrl.Attributes["href"].Value);
                        var recipeBigPicUrl    = recipeDoc.DocumentNode.SelectSingleNode(".//div[@id='r1']//p//img")?.Attributes["src"]?.Value;
                        if (string.IsNullOrEmpty(recipeBigPicUrl))
                        {
                            continue;
                        }
                        var recipeSmallPicUrl = recipeSmallPicture;
                        var content           = recipeDoc.DocumentNode.SelectSingleNode(@".//p[@class='recipe_step']").InnerText.Trim();
                        var ingredients       = recipeDoc.DocumentNode.SelectNodes(@".//span[@typeof='v:RecipeIngredient']");
                        var ingredietList     = new List <Ingredient>();
                        foreach (var ingredient in ingredients)
                        {
                            var amount = ingredient.SelectSingleNode(@".//span[@property='v:amount']").InnerText.Trim();
                            var name   = ingredient.SelectSingleNode(@".//a[@property='v:name']").InnerText.Trim();
                            var ingrDb = db.Ingredients.Where(x => x.Name == name && x.Quantity == amount).FirstOrDefault();
                            if (ingrDb == null)
                            {
                                ingrDb = new Ingredient
                                {
                                    Name     = name,
                                    Quantity = amount
                                };
                            }
                            ingredietList.Add(ingrDb);
                        }

                        var cookTime    = recipeDoc.DocumentNode.SelectSingleNode(".//span[@property='v:totalTime']").InnerText.Trim();
                        var kcal        = decimal.Parse(recipeDoc.DocumentNode.SelectSingleNode(".//span[@property='v:calories']").InnerText.Trim());
                        var fat         = decimal.Parse(recipeDoc.DocumentNode.SelectSingleNode(".//span[@property='v:fat']").InnerText.Trim());
                        var saturates   = decimal.Parse(recipeDoc.DocumentNode.SelectSingleNode(".//span[@property='v:saturatedFat']").InnerText.Trim());
                        var protein     = decimal.Parse(recipeDoc.DocumentNode.SelectSingleNode(".//span[@property='v:protein']").InnerText.Trim());
                        var carbs       = decimal.Parse(recipeDoc.DocumentNode.SelectSingleNode(".//span[@property='v:carbohydrates']").InnerText.Trim());
                        var serviceSize = recipeDoc.DocumentNode.SelectSingleNode(".//span[@property='v:servingSize']").InnerText.Trim();

                        var nutrition = new Nutrition
                        {
                            Kcal        = kcal,
                            Fat         = fat,
                            Saturates   = saturates,
                            Protein     = protein,
                            Carbs       = carbs,
                            ServiceSize = serviceSize
                        };

                        var categoryDb = db.Categories.Where(s => s.Name == categoryName).FirstOrDefault();
                        if (categoryDb == null)
                        {
                            categoryDb = new Category
                            {
                                Name = categoryName
                            };
                            db.Categories.Add(categoryDb);
                            db.SaveChanges();
                        }


                        var r = new Recipe
                        {
                            Category   = categoryDb,
                            Name       = recipeName,
                            Directions = new Directions
                            {
                                CookTime  = cookTime,
                                Method    = content,
                                Serves    = 4,
                                PrepTime  = "10",
                                CookSkill = 1
                            },
                            Author          = "Uncknown",
                            BigPictureUrl   = recipeBigPicUrl,
                            SmallPictureUrl = recipeSmallPicUrl,
                            Ingredients     = ingredietList,
                            Nutrition       = nutrition
                        };
                        Console.WriteLine($"{r.Category.Name} => {r.Name}");
                        db.Recipes.Add(r);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    continue;
                }

                db.SaveChanges();
            }
        }
コード例 #49
0
 public InventoryIngredient(Ingredient _equipment, int _chargesLeft)
 {
     item        = _equipment;
     chargesLeft = _chargesLeft;
 }
コード例 #50
0
 public InvalidFormException(Ingredient ing, IngredientForm form)
 {
     Ingredient = ing;
     Form       = form;
 }
コード例 #51
0
        protected override void Seed(MyNutrition.Models.MyNutritionDbContext context)
        {
            var vegetables = new IngredientType {
                Name = "vegetables"
            };
            var protein = new IngredientType {
                Name = "protein"
            };
            var fruits = new IngredientType {
                Name = "fruits"
            };
            var grains = new IngredientType {
                Name = "grains"
            };
            var dairy = new IngredientType {
                Name = "dairy"
            };

            context.IngredientTypes.AddOrUpdate(i => i.Name, new IngredientType[] { vegetables, protein, fruits, grains, dairy });
            context.SaveChanges();

            var bran = new Ingredient {
                Name = "bran", IngredientType = grains, BaseServingSize = 100
            };

            bran.Calories = new Calories()
            {
                Overall = 25
            };
            bran.Carbohydrates = new Carbohydrates()
            {
                DietaryFiber = 15, Starch = 20, Sugars = new Sugars()
                {
                    Fructose = 50
                }
            };
            bran.Fats = new Fats()
            {
                SaturatedFat = 25
            };
            bran.Protein = new Protein()
            {
                Overall = 21
            };
            bran.Vitamins = new Vitamins()
            {
                A = 0.2f, C = 0.5f
            };
            bran.Minerals = new Minerals()
            {
                Calcium = 0.13f, Copper = 0.22f, Magnesium = 0.2f
            };
            var reisin = new Ingredient {
                Name = "reisin", IngredientType = fruits, BaseServingSize = 100
            };

            reisin.Calories = new Calories()
            {
                Overall = 25
            };
            reisin.Carbohydrates = new Carbohydrates()
            {
                DietaryFiber = 22, Starch = 33, Sugars = new Sugars()
                {
                    Galactose = 50
                }
            };
            reisin.Fats = new Fats()
            {
                SaturatedFat = 11
            };
            reisin.Protein = new Protein()
            {
                Overall = 21
            };
            reisin.Vitamins = new Vitamins()
            {
                D = 0.1f, C = 0.5f
            };
            reisin.Minerals = new Minerals()
            {
                Manganese = 0.13f, Copper = 0.22f, Fluoride = 0.2f
            };
            var water = new Ingredient {
                Name = "water", BaseServingSize = 100
            };

            water.Calories = new Calories()
            {
                Overall = 11
            };
            water.Carbohydrates = new Carbohydrates()
            {
                DietaryFiber = 22, Starch = 33, Sugars = new Sugars()
                {
                    Galactose = 50
                }
            };
            water.Fats = new Fats()
            {
                SaturatedFat = 11
            };
            water.Protein = new Protein()
            {
                Overall = 21
            };
            water.Vitamins = new Vitamins()
            {
                K = 0.1f, B6 = 0.5f
            };
            water.Minerals = new Minerals()
            {
                Manganese = 0.13f, Phosphorus = 0.22f, Fluoride = 0.2f
            };
            var butter = new Ingredient {
                Name = "butter", IngredientType = dairy, BaseServingSize = 100
            };

            butter.Calories = new Calories()
            {
                Overall = 332
            };
            butter.Carbohydrates = new Carbohydrates()
            {
                DietaryFiber = 22, Starch = 33, Sugars = new Sugars()
                {
                    Lactose = 76
                }
            };
            butter.Fats = new Fats()
            {
                MonounsaturatedFat = 11
            };
            butter.Protein = new Protein()
            {
                Overall = 45
            };
            butter.Vitamins = new Vitamins()
            {
                E = 0.1f, B6 = 0.5f, Riboflavin = 0.4f, PantothenicAcid = 0.2f
            };
            butter.Minerals = new Minerals()
            {
                Manganese = 0.13f, Phosphorus = 0.22f, Fluoride = 0.2f
            };
            var sugar = new Ingredient {
                Name = "sugar", BaseServingSize = 100
            };

            sugar.Calories = new Calories()
            {
                Overall = 332
            };
            sugar.Carbohydrates = new Carbohydrates()
            {
                DietaryFiber = 22, Starch = 33, Sugars = new Sugars()
                {
                    Lactose = 76
                }
            };
            sugar.Fats = new Fats()
            {
                MonounsaturatedFat = 11
            };
            sugar.Protein = new Protein()
            {
                Overall = 45
            };
            sugar.Vitamins = new Vitamins()
            {
                E = 0.1f, B6 = 0.5f, Riboflavin = 0.4f, PantothenicAcid = 0.2f
            };
            sugar.Minerals = new Minerals()
            {
                Manganese = 0.13f, Phosphorus = 0.22f, Fluoride = 0.2f
            };
            var vegerableOil = new Ingredient {
                Name = "vegetable oil", BaseServingSize = 100
            };

            vegerableOil.Calories = new Calories()
            {
                Overall = 332
            };
            vegerableOil.Carbohydrates = new Carbohydrates()
            {
                DietaryFiber = 22, Starch = 33, Sugars = new Sugars()
                {
                    Lactose = 76
                }
            };
            vegerableOil.Fats = new Fats()
            {
                MonounsaturatedFat = 11
            };
            vegerableOil.Protein = new Protein()
            {
                Overall = 45
            };
            vegerableOil.Vitamins = new Vitamins()
            {
                E = 0.1f, B6 = 0.5f, Riboflavin = 0.4f, PantothenicAcid = 0.2f
            };
            vegerableOil.Minerals = new Minerals()
            {
                Manganese = 0.13f, Phosphorus = 0.22f, Fluoride = 0.2f
            };
            var egg = new Ingredient {
                Name = "eggs", BaseServingSize = 1
            };

            egg.Calories = new Calories()
            {
                Overall = 332
            };
            egg.Carbohydrates = new Carbohydrates()
            {
                DietaryFiber = 22, Starch = 33, Sugars = new Sugars()
                {
                    Lactose = 76
                }
            };
            egg.Fats = new Fats()
            {
                MonounsaturatedFat = 11
            };
            egg.Protein = new Protein()
            {
                Overall = 45
            };
            egg.Vitamins = new Vitamins()
            {
                E = 0.1f, B6 = 0.5f, Riboflavin = 0.4f, PantothenicAcid = 0.2f
            };
            egg.Minerals = new Minerals()
            {
                Manganese = 0.13f, Phosphorus = 0.22f, Fluoride = 0.2f
            };
            var flour = new Ingredient {
                Name = "flour", IngredientType = grains, BaseServingSize = 100
            };

            flour.Calories = new Calories()
            {
                Overall = 332
            };
            flour.Carbohydrates = new Carbohydrates()
            {
                DietaryFiber = 22, Starch = 33, Sugars = new Sugars()
                {
                    Lactose = 76
                }
            };
            flour.Fats = new Fats()
            {
                MonounsaturatedFat = 11
            };
            flour.Protein = new Protein()
            {
                Overall = 45
            };
            flour.Vitamins = new Vitamins()
            {
                E = 0.1f, B6 = 0.5f, Riboflavin = 0.4f, PantothenicAcid = 0.2f
            };
            flour.Minerals = new Minerals()
            {
                Manganese = 0.13f, Phosphorus = 0.22f, Fluoride = 0.2f
            };
            var bakingPowder = new Ingredient {
                Name = "baking powder", BaseServingSize = 100
            };

            bakingPowder.Calories = new Calories()
            {
                Overall = 332
            };
            bakingPowder.Carbohydrates = new Carbohydrates()
            {
                DietaryFiber = 22, Starch = 33, Sugars = new Sugars()
                {
                    Lactose = 76
                }
            };
            bakingPowder.Fats = new Fats()
            {
                MonounsaturatedFat = 11
            };
            bakingPowder.Protein = new Protein()
            {
                Overall = 45
            };
            bakingPowder.Vitamins = new Vitamins()
            {
                E = 0.1f, B6 = 0.5f, Riboflavin = 0.4f, PantothenicAcid = 0.2f
            };
            bakingPowder.Minerals = new Minerals()
            {
                Manganese = 0.13f, Phosphorus = 0.22f, Fluoride = 0.2f
            };
            context.Ingredients.AddOrUpdate(i => i.Name, new Ingredient[] { bran, reisin, water, butter, sugar, vegerableOil, egg, flour, bakingPowder });
            context.SaveChanges();

            var recipe = new Recipe {
                Name = "Bran Muffins", PreparationTime = 30, CookingTime = 45, Description = "Lightly coat a muffin tin with 1/2-cup capacity cups with melted butter, and fit a pastry bag with a large tip (if desired). Set aside. (Editor's Note: Not sure if your muffin tins hold 1/2 cup? A good way to check is to start pouring a measured cup of water in, stop when it's full, and see how much is left in the measuring cup. When in doubt, underfill and pour any extra batter at the end into another mini loaf pan or ramekins.) Adjust the oven rack to the middle setting and preheat the oven to 350º F. Spread the bran on the baking sheet and toast for 6 to 8 minutes, stirring halfway through to make sure it doesn't burn. In a small saucepan, combine 1 cup of the raisins and 1 cup of water and simmer on low heat until the liquid has been absorbed, about 15 minutes. Place in a blender or in a food processor fitted with the steel blade, and process until puréed.l puréed. Pour the bran into a large bowl, add the buttermilk and remaining 1/2 cup water, and stir to combine. Stir in the raisin purée, orange zest, and brown sugar. Add the oil, the whole egg, and the egg white, mixing well to combine. Sift the flours, baking powder, baking soda, and salt into the raisin mixture. Add the remaining whole raisins and stir to combine. Fill the pastry bag half full and pipe or spoon the batter into the prepared muffin tins, mounding the batter slightly but taking care not to overfill. Bake for about 25 minutes, until the muffins are well-browned and firm to the touch.", ServingSize = 12, Ingredients = context.Ingredients.ToList(), Image = File.ReadAllBytes(@"D:\Software Engineering Folder\GitHub\MyNutrition\trunk\MyNutrition\Pictures\bran-muffins.jpg")
            };
            var recipeBrulee = new Recipe {
                Name = "Brulee", PreparationTime = 50, CookingTime = 45, Description = "Толумбичките се правят по стара рецепта на баба...която е тайна...", ServingSize = 12, Ingredients = context.Ingredients.ToList(), Image = File.ReadAllBytes(@"D:\Software Engineering Folder\GitHub\MyNutrition\trunk\MyNutrition\Pictures\brulee.jpg")
            };
            var recipeCake = new Recipe {
                Name = "Chocolate Cake", PreparationTime = 15, CookingTime = 45, Description = "Толумбичките се правят по стара рецепта на баба...която е тайна...", ServingSize = 12, Ingredients = context.Ingredients.ToList(), Image = File.ReadAllBytes(@"D:\Software Engineering Folder\GitHub\MyNutrition\trunk\MyNutrition\Pictures\chokolate_cake.jpg")
            };
            var recipeTolumbichki = new Recipe {
                Name = "Tolumbichki", PreparationTime = 22, CookingTime = 45, Description = "Толумбичките се правят по стара рецепта на баба...която е тайна...", ServingSize = 12, Ingredients = context.Ingredients.ToList(), Image = File.ReadAllBytes(@"D:\Software Engineering Folder\GitHub\MyNutrition\trunk\MyNutrition\Pictures\tolumbichki.jpg")
            };

            recipe.IngredientAmounts.Add(new IngredientAmount {
                IngredientId = 1, RecipeId = 1, ServingSize = 500
            });
            recipe.IngredientAmounts.Add(new IngredientAmount {
                IngredientId = 2, RecipeId = 1, ServingSize = 20
            });
            recipe.IngredientAmounts.Add(new IngredientAmount {
                IngredientId = 3, RecipeId = 1, ServingSize = 200
            });
            recipe.IngredientAmounts.Add(new IngredientAmount {
                IngredientId = 4, RecipeId = 1, ServingSize = 100
            });
            recipe.IngredientAmounts.Add(new IngredientAmount {
                IngredientId = 5, RecipeId = 1, ServingSize = 150
            });
            recipe.IngredientAmounts.Add(new IngredientAmount {
                IngredientId = 6, RecipeId = 1, ServingSize = 30
            });
            recipe.IngredientAmounts.Add(new IngredientAmount {
                IngredientId = 7, RecipeId = 1, ServingSize = 40
            });
            recipe.IngredientAmounts.Add(new IngredientAmount {
                IngredientId = 8, RecipeId = 1, ServingSize = 1
            });
            recipe.IngredientAmounts.Add(new IngredientAmount {
                IngredientId = 9, RecipeId = 1, ServingSize = 300
            });

            recipeBrulee.IngredientAmounts.Add(new IngredientAmount {
                IngredientId = 5, RecipeId = 2, ServingSize = 200
            });
            recipeBrulee.IngredientAmounts.Add(new IngredientAmount {
                IngredientId = 3, RecipeId = 2, ServingSize = 150
            });
            recipeBrulee.IngredientAmounts.Add(new IngredientAmount {
                IngredientId = 8, RecipeId = 2, ServingSize = 80
            });

            recipeCake.IngredientAmounts.Add(new IngredientAmount {
                IngredientId = 5, RecipeId = 3, ServingSize = 121
            });
            recipeCake.IngredientAmounts.Add(new IngredientAmount {
                IngredientId = 1, RecipeId = 3, ServingSize = 300
            });
            recipeCake.IngredientAmounts.Add(new IngredientAmount {
                IngredientId = 7, RecipeId = 3, ServingSize = 150
            });

            recipeTolumbichki.IngredientAmounts.Add(new IngredientAmount {
                IngredientId = 2, RecipeId = 4, ServingSize = 145
            });
            recipeTolumbichki.IngredientAmounts.Add(new IngredientAmount {
                IngredientId = 8, RecipeId = 4, ServingSize = 120
            });
            recipeTolumbichki.IngredientAmounts.Add(new IngredientAmount {
                IngredientId = 9, RecipeId = 4, ServingSize = 90
            });

            context.Recipes.Add(recipe);
            context.Recipes.Add(recipeBrulee);
            context.Recipes.Add(recipeCake);
            context.Recipes.Add(recipeTolumbichki);

            context.SaveChanges();
        }
コード例 #52
0
 public static IngredientDto ToDto(Ingredient ingredient)
 {
     return(new IngredientDto(ingredient.Name, ingredient.Price, ingredient.ImageUrl, ingredient.ImageUrlMain, ToDto(ingredient.Category), ingredient.Index));
 }
コード例 #53
0
        public async Task <IActionResult> Create(
            [Bind("RecipeName", "RecipeDescription", "Servings", "PrepareTime",
                  "UserID", "Image", "Ingredients", "RecipeSteps")] RecipeCreateViewModel model)
        {
            Recipe recipe  = new Recipe();
            int    counter = 0;

            foreach (IngredientViewModel ingredient in model.Ingredients)
            {
                if (string.IsNullOrEmpty(ingredient.IngredientName) || string.IsNullOrEmpty(ingredient.ServingContent))
                {
                    counter++;
                    continue;
                }
                Category category = _context.Category.Where(c => c.CategoryName.ToLower().Contains(ingredient.IngredientName.ToLower())).FirstOrDefault();

                Product product = null;

                if (category != null)
                {
                    product = await _context.Product.Include(p => p.ServingType).Include(p => p.Category)
                              .Where(p => p.Category.CategoryName == category.CategoryName).OrderByDescending(p => p.ProductStock).FirstOrDefaultAsync();
                }
                else
                {
                    product = await _context.Product.Include(p => p.ServingType).Where(p => p.ProductName.ToLower().Contains(ingredient.IngredientName.ToLower()))
                              .OrderByDescending(p => p.ProductStock)
                              .FirstOrDefaultAsync();
                }

                if (product == null)
                {
                    ModelState.AddModelError("", "Unable to find matched product for " + ingredient.IngredientName);
                }
                else
                {
                    //MIGHT NEED CHANGE COMPARE SERVING CONTENT
                    Ingredient ingredientModel = new Ingredient()
                    {
                        ProductID      = product.ProductID,
                        ServingContent = ingredient.ServingContent,
                        IngredientName = ingredient.IngredientName,
                        Quantity       = 1
                    };

                    recipe.Ingredients.Add(ingredientModel);
                }
            }

            if (counter == model.Ingredients.Count)
            {
                ModelState.AddModelError("", "Recipe is Required to Have Minimum of 1 Ingredient");
            }

            if (ModelState.IsValid)
            {
                string          uniqueFileName = ProcessUploadedFile(model.Image);
                ApplicationUser user           = await _UserManager.FindByIdAsync(model.UserID);

                bool isAdmin = await _UserManager.IsInRoleAsync(user, "ADMIN");

                recipe.RecipeApprovalStatus = isAdmin? RecipeApprovalStatus.Approved : RecipeApprovalStatus.Pending;
                recipe.AddedDate            = DateTime.Now;
                if (isAdmin)
                {
                    recipe.ApprovedDate = DateTime.Now;
                }
                recipe.RecipeName        = model.RecipeName;
                recipe.UserID            = model.UserID;
                recipe.PrepareTime       = model.PrepareTime;
                recipe.Servings          = model.Servings;
                recipe.RecipeDescription = model.RecipeDescription;
                recipe.RecipeSteps       = model.RecipeSteps;
                recipe.ImageUrl          = uniqueFileName;

                if (model.PrepareTime.Any(char.IsDigit))
                {
                    Regex regex = new Regex(@"^(?<NUMVALUE>\d+.?\d*)\s*(?<STRVALUE>[A-Za-z]*)$", RegexOptions.Singleline);
                    Match match = regex.Match(recipe.PrepareTime);

                    recipe.PrepareTimeDuration    = match.Groups["NUMVALUE"].Value;
                    recipe.PrepareTimeMeasurement = match.Groups["STRVALUE"].Value;
                }
                _context.Add(recipe);
                await _context.SaveChangesAsync();

                //Change the return URL LATER

                if (isAdmin)
                {
                    return(RedirectToAction("Index", "AdminRecipes"));
                }
                else
                {
                    return(RedirectToAction("Index", "Manage", new { pageName = "MyRecipes" }));
                }
            }

            return(View(model));
        }
コード例 #54
0
 public void AddIngredient(Ingredient ingredient)
 {
     ingredientList.Enqueue(ingredient);
 }
コード例 #55
0
 public RestaurantRecipe(Recipe recipeInfo)
 {
     manufacturingCost = 0.0;
     recipe            = recipeInfo;
     for (int i = 0; i < recipeInfo.ingredients.Length; i++)
     {
         manufacturingCost += (Ingredient.IngredientCost(recipeInfo.ingredients[i].ingredient) * (Ingredient.TierToMultiplier(recipeInfo.ingredients[i].tier)));
         Debug.Log("Manu facturing cost is " + manufacturingCost + " right now");
     }
     sellingPrice = manufacturingCost * 2;   //Set selling Price automatically to a default
     baseCost     = manufacturingCost * 2;
     profit       = 0.0;
     multiplier   = 1f;
 }
コード例 #56
0
ファイル: IngredientIcon.cs プロジェクト: HealthJam/Snap2Go
    public void Initialize(Ingredient data)
    {
        //ingredientImage.sprite = data.ingredientImage;

        ingredientName.text = data.name;
    }
コード例 #57
0
    //Issues of not changing the player's selling price and base cost cost means they could have recipe now sell for more than the bounds normally allow.
    public void RecalculateRecipeManufacturingCost(List <Tech> upgrades)
    {
        manufacturingCost = 0.0;
        for (int i = 0; i < recipe.ingredients.Length; i++)
        {
            double ingredientPrice = 0;
            ingredientPrice = (Ingredient.IngredientCost(recipe.ingredients[i].ingredient) * (Ingredient.TierToMultiplier(recipe.ingredients[i].tier)));

            if (upgrades.Contains(Tech.STEAK_HOUSE) && (int)recipe.ingredients[i].ingredient < 5 && (int)recipe.ingredients[i].ingredient >= 0)
            {
                ingredientPrice *= 0.95;
                Debug.Log("Your meat costs 5% less due to steak house upgrade");
            }
            if (upgrades.Contains(Tech.CUTTING_CORNERS) && recipe.ingredients[i].tier == 0)
            {
                ingredientPrice *= 0.90;
                Debug.Log("Your tier 0 ingredient costs 10% less due to steak house upgrade");
            }
            if (upgrades.Contains(Tech.FRESH_PRODUCE) && (int)recipe.ingredients[i].ingredient >= 20)
            {
                ingredientPrice *= 0.90;
                Debug.Log("Your misc ingredient costs 10% less due to fresh produce upgrade");
            }
            manufacturingCost += ingredientPrice;

            Debug.Log("Manu facturing cost is " + manufacturingCost + " right now");
        }

        //update the below values relative to change
        //sellingPrice = ;   //Set selling Price
        //baseCost = ;
    }
コード例 #58
0
 public IngredientPage(Ingredient ingredient)
 {
     Ingredient = ingredient;
     InitializeComponent();
 }
コード例 #59
0
 public bool Update(Ingredient ingredient)
 {
     return(UpdateEntity(_context.Ingredients, ingredient));
 }
コード例 #60
0
    public void Select()
    {
        if (selectedSurface != null)
        {
            selectedSurface.Hide();
        }

        if (selectedChair != null)
        {
            selectedChair.UnSelectMeshes();
        }

        if (selectedGenerator != null)
        {
            selectedGenerator.DeSelected();
        }

        selectedGenerator = null;
        selectedSurface   = null;
        groundObject      = null;
        selectedChair     = null;
        selectedDeliverer = null;

        RaycastHit hitInfo;

        if (Physics.Raycast(new Vector3(transform.position.x, height, transform.position.z), transform.forward, out hitInfo, interactRadius, layers))
        {
            groundObject = hitInfo.collider.gameObject.GetComponent <Ingredient>();
            if (!groundObject)
            {
                selectedChair = hitInfo.collider.gameObject.GetComponent <Chair>();

                if (selectedChair)
                {
                    selectedChair.SelectMeshes();
                }
                else
                {
                    selectedWigDispenser = hitInfo.collider.gameObject.GetComponent <WigDispenser>();

                    if (!selectedWigDispenser)
                    {
                        selectedGenerator = hitInfo.collider.gameObject.GetComponent <ObjectGenerator>();
                        if (selectedGenerator)
                        {
                            selectedGenerator.Selected();
                        }
                        else
                        {
                            selectedDeliverer = hitInfo.collider.GetComponentInParent <RecipeDeliverer>();

                            if (!selectedDeliverer)
                            {
                                selectedSurface = hitInfo.collider.GetComponentInParent <PlaceableSurface>();
                                if (selectedSurface)
                                {
                                    selectedSurface.Show();
                                }
                            }
                        }
                    }
                }
            }
        }
    }