コード例 #1
0
        // GET: FoodIngredients/Details/5
        public ActionResult Details(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            FoodIngredient foodIngredient = db.foodIngredients.Find(id);

            if (foodIngredient == null)
            {
                return(HttpNotFound());
            }
            return(View(foodIngredient));
        }
コード例 #2
0
ファイル: Details.cshtml.cs プロジェクト: 0f11/OrderFood
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            FoodIngredient = await _context.FoodIngredient
                             .Include(f => f.FoodItem).FirstOrDefaultAsync(m => m.FoodIngredientId == id);

            if (FoodIngredient == null)
            {
                return(NotFound());
            }
            return(Page());
        }
コード例 #3
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            FoodIngredient = await _context.FoodIngredient.FindAsync(id);

            if (FoodIngredient != null)
            {
                _context.FoodIngredient.Remove(FoodIngredient);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
コード例 #4
0
ファイル: Edit.cshtml.cs プロジェクト: 0f11/OrderFood
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            FoodIngredient = await _context.FoodIngredient
                             .Include(f => f.FoodItem).FirstOrDefaultAsync(m => m.FoodIngredientId == id);

            if (FoodIngredient == null)
            {
                return(NotFound());
            }
            ViewData["FoodItemId"] = new SelectList(_context.FoodItems, "FoodItemId", "FoodItemId");
            return(Page());
        }
コード例 #5
0
        public override async Task <ProductDto> Update(ProductDto input)
        {
            var product = _productRepository.Get(input.Id);

            _objectMapper.Map(input, product);
            await _productRepository.UpdateAsync(product);

            //find corresponding food ingredient
            var foodIngredient = _foodIngredientRepository.GetAllIncluding(o => o.FoodIngredient_Product_Mapping)
                                 .Where(o => o.IsProduct)
                                 .Where(o => o.FoodIngredient_Product_Mapping.All(x => x.ProductId == input.Id))
                                 .FirstOrDefault();

            if (foodIngredient == null)
            {
                foodIngredient = new FoodIngredient
                {
                    Name            = input.Name,
                    UnitOfMeasureId = input.UnitOfMeasureId,
                    IsProduct       = true
                };
                foodIngredient.FoodIngredient_Product_Mapping.Add(new FoodIngredient_Product
                {
                    ProductId       = product.Id,
                    Quantity        = 1,
                    UnitOfMeasureId = input.UnitOfMeasureId
                });

                await _foodIngredientRepository.InsertAndGetIdAsync(foodIngredient);
            }
            else
            {
                foodIngredient.Name            = input.Name;
                foodIngredient.UnitOfMeasureId = input.UnitOfMeasureId;
                var fipm = foodIngredient.FoodIngredient_Product_Mapping.FirstOrDefault();
                fipm.UnitOfMeasureId = input.UnitOfMeasureId;
            }

            await _foodIngredientRepository.InsertOrUpdateAndGetIdAsync(foodIngredient);


            return(product.MapTo <ProductDto>());
        }
コード例 #6
0
ファイル: Spawner.cs プロジェクト: songhyunji/Realhungry
    IEnumerator SpawnIngRoutine()
    {
        while (true)
        {
            next_ing             = ingDB.GetRandomIngredient();
            nextIng_Image.sprite = next_ing.sprite;

            yield return(new WaitForSeconds(spawnCoolTime));

            FoodIngredient ing = next_ing;

            var ing_Object = IngredientObject.Pull_Ob();

            Vector3 x_offset = new Vector3(Random.Range(-0.1f, 0.1f), 0f, 0f);

            ing_Object.transform.position = transform.position + x_offset;
            ing_Object.Init(ing);
        }
    }
コード例 #7
0
ファイル: Spawner.cs プロジェクト: songhyunji/Realhungry
    IEnumerator SpawningTrash()
    {
        int randTime = 0;

        while (true)
        {
            FoodIngredient next_trash = ingDB.GetRandomTrash();

            randTime = Random.Range(5, 16);
            yield return(new WaitForSeconds(randTime));

            var ing_Object = IngredientObject.Pull_Ob();

            Vector3 x_offset = new Vector3(Random.Range(-0.1f, 0.1f), 0f, 0f);

            ing_Object.transform.position = transform.position + x_offset;
            ing_Object.Init(next_trash);
        }
    }
コード例 #8
0
    public void AddIngredient(FoodIngredient ingredient)
    {
        // 쓰레기 체크
        if (ingredient.id >= 5)
        {
            FoodGameManager.Instance.Score += ingredient.score;
            ingredients.Clear();
            ingredientUI.ResetUI();
            return;
        }

        ingredients.Add(ingredient);
        ingredientUI.SetUI(ingredients);

        // TO-DO: 연출 필요
        if (ingredients.Count >= 4)
        {
            MakeRecipe();
        }
    }
コード例 #9
0
        public IActionResult EditMenu(ViewModelFood edited)
        {
            var old = GetViewModel();

            old.CurrentFood = _context.Food.SingleOrDefault(f => f.FoodId == edited.CurrentFood.FoodId);
            edited.CurrentFood.Ingredients = new List <Ingredient>();

            foreach (var item in edited.AllIngredients)
            {
                if (item.Selected == true)
                {
                    if (old.CurrentFood.Ingredients.FirstOrDefault(i => i.IngredientId == item.IngredientId) == null)
                    {
                        FoodIngredient foodIng = new FoodIngredient();
                        foodIng.FoodId       = edited.CurrentFood.FoodId;
                        foodIng.IngredientId = item.IngredientId;

                        _context.Add(foodIng);
                        _context.SaveChanges();
                    }
                }
                else
                {
                    if (old.CurrentFood.Ingredients.FirstOrDefault(i => i.IngredientId == item.IngredientId) != null)
                    {
                        var foodIng = _context.FoodIngredient.FirstOrDefault(i => i.IngredientId == item.IngredientId &&
                                                                             i.FoodId == edited.CurrentFood.FoodId);

                        _context.Remove(foodIng);
                        _context.SaveChanges();
                    }
                }
            }


            _context.Entry(old.CurrentFood).CurrentValues.SetValues(edited.CurrentFood);
            _context.SaveChanges();

            return(RedirectToAction("ManageMenu"));
        }
コード例 #10
0
 private void Save_Click(object sender, RoutedEventArgs e)
 {
     if (FoodName.Text == "Food Name")
     {
         MessageBox.Show("Ey yo! Món ăn phải có tên nè");
         FoodName.Focus();
     }
     else if (FoodIngredient.Text == "Ingredient")
     {
         MessageBox.Show("Hey! Món ăn thì phải có thành phần, nguyên liệu chứ nhờ");
         FoodIngredient.Focus();
     }
     else if (String.IsNullOrEmpty(thumbnailPath))
     {
         MessageBox.Show("Hmmmm! Món ăn phải có hình mới hấp dẫn chớ");
     }
     else if (Steps.Count == 0)
     {
         MessageBox.Show("Oh no! Phải có ít nhất một bước nấu ăn chớ");
     }
     else
     {
         Recipe recipe = new Recipe(FoodName.Text, FoodIngredient.Text, thumbnailPath, YoutubeLink.Text, false, Steps, "HeartOutline", "White");
         int    err    = recipe.SaveToFiles($"{pathRoot}");
         if (err == 0)
         {
             MessageBox.Show("Đã thêm công thức");
         }
         else if (err == 1)
         {
             MessageBox.Show("Tên công thức món ăn này đã tồn tại. Hãy đổi thành tên khác");
         }
         else
         {
             MessageBox.Show("Chưa thêm được công thức\nLiên hệ nhà phát triển.");
         }
     }
 }
コード例 #11
0
        public override async Task <ProductDto> Create(ProductDto input)
        {
            var product = input.MapTo <Product>();
            await _productRepository.InsertAndGetIdAsync(product);

            var foodIngredient = new FoodIngredient
            {
                Name            = input.Name,
                UnitOfMeasureId = input.UnitOfMeasureId,
                IsProduct       = true
            };

            foodIngredient.FoodIngredient_Product_Mapping.Add(new FoodIngredient_Product
            {
                ProductId       = product.Id,
                Quantity        = 1,
                UnitOfMeasureId = input.UnitOfMeasureId
            });


            await _foodIngredientRepository.InsertAndGetIdAsync(foodIngredient);

            return(product.MapTo <ProductDto>());
        }
コード例 #12
0
 public RecipeEntry(FoodIngredient ing, int c**t)
 {
     ingredient = ing;
     count      = c**t;
 }
コード例 #13
0
 public static void SetTo(this FoodIngredientView view, FoodIngredient model)
 {
     Mapper.Map(view, model);
 }
コード例 #14
0
 public static FoodIngredientView ToView(this FoodIngredient model)
 {
     return(Mapper.Map <FoodIngredientView>(model));
 }
コード例 #15
0
 public void Init(FoodIngredient ing)
 {
     data = ing;
     spRenderer.sprite = data.sprite;
     rigid.sharedMaterial.bounciness = data.weight;
 }
コード例 #16
0
    public static void BuildIngredientDatabase()
    {
        // CSV 데이터 파일 체크 및 파싱
        var dataDic = CSVParser.Read(rootDataPath + "/ingredientDB");

        if (dataDic == null)
        {
            Debug.LogError("[Ing.DB Build] CSV parsing result is null");
            return;
        }

        // 데이터베이스 파일 생성 또는 초기화
        FoodIngredientDatabase db = Resources.Load <FoodIngredientDatabase>(rootDataPath + "/IngredientDatabase");

        if (db == null)
        {
            db = ScriptableObject.CreateInstance <FoodIngredientDatabase>();

            string databasePath = "Assets/Resources/" + rootDataPath + "/IngredientDatabase.asset";
            AssetDatabase.CreateAsset(db, databasePath);
            EditorUtility.SetDirty(db);
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();

            Debug.Log("[Ing.DB Build] SO is created at " + databasePath);
        }
        else
        {
            db.Clear();
        }

        // 서브 데이터 디렉토리 체크
        string dataDirectoryPath = "Assets/Resources/" + rootDataPath + "/Ingredients";

        if (!Directory.Exists(dataDirectoryPath))
        {
            Directory.CreateDirectory(dataDirectoryPath);
        }

        // 기존 파일 탐색
        FoodIngredient[] unconnectedData = Resources.LoadAll <FoodIngredient>(rootDataPath + "/Ingredients");
        for (int i = 0; i < unconnectedData.Length; i++)
        {
            db.ingredients.Add(unconnectedData[i]);
            db.ingredients[i].SetData(dataDic[i]);
            EditorUtility.SetDirty(db.ingredients[i]);
        }

        // 재사용할 데이터 파일 없으면 생성
        int charCount = dataDic.Count;

        for (int i = unconnectedData.Length; i < charCount; i++)
        {
            FoodIngredient newData = ScriptableObject.CreateInstance <FoodIngredient>();
            newData.SetData(dataDic[i]);

            string subDataPath = dataDirectoryPath + "/ing_" + i.ToString("0") + ".asset";
            AssetDatabase.CreateAsset(newData, subDataPath);
            EditorUtility.SetDirty(newData);
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();

            db.ingredients.Add(newData);
        }
        EditorUtility.SetDirty(db);
        AssetDatabase.SaveAssets();
        AssetDatabase.Refresh();

        Debug.Log("[Ing.DB Build] Success.");
    }
コード例 #17
0
 public void SetUI(FoodIngredient newData)
 {
     data       = newData;
     img.sprite = data.sprite;
     txt.text   = data.nameStr;
 }
コード例 #18
0
    public override bool Doable(AreaInteractable interactable, out string message)
    {
        switch (actionType)
        {
        case Type.WashDishes:
            if (room.dishesWashed)
            {
                message = string.Format($"<color={GameAction.errorColor}>Dishes are already washed.");
                return(false);
            }
            break;

        case Type.EatMeal:
            if (room.meals <= 0)
            {
                message = string.Format($"<color={GameAction.errorColor}>There are no meals.");
                return(false);
            }
            if (!room.dishesWashed)
            {
                message = string.Format($"<color={GameAction.errorColor}>All the dishes are dirty.");
                return(false);
            }
            break;

        case Type.EatIngredients:
            AttributeValues.RemoveAll(e => (e.type == Person.AttributeTypes.Hunger));
            Required req = new Required();
            req.type      = Person.AttributeTypes.Hunger;
            req.netAmount = room.CheckIngredientsConsumption();

            if (req.netAmount <= 0)
            {
                message = string.Format($"<color={GameAction.errorColor}>No ingredients in the kitchen.");
                return(false);
            }

            AttributeValues.Add(req);
            break;

        case Type.PrepareMeal:
            if (room.meals >= room.maxMeals)
            {
                message = string.Format($"<color={GameAction.errorColor}>Meals are at full capacity. [{room.meals}/{room.maxMeals}]");
            }
            if (room.ingredients < mealCost)
            {
                message = string.Format($"<color={GameAction.errorColor}>Not enough ingredients for a meal. [{room.ingredients}/{mealCost}]");
                return(false);
            }
            break;

        case Type.AddIngredients:
            FoodIngredient ingredient = interactable as FoodIngredient;
            if (ingredient)
            {
                int waste;
                if ((waste = room.CheckIngredients(ingredient.nutritionValue)) > 0)
                {
                    if (ingredient.nutritionValue - waste <= 0)
                    {
                        message = string.Format($"<color={GameAction.errorColor}>Full food ingredient capacity [{room.ingredients}/{room.maxIngredients}]");
                        return(false);
                    }

                    message  = string.Format($"<color={GameAction.okColor}>{ingredient.foodName} +{ingredient.nutritionValue-waste} ingredients.");
                    message += string.Format($"<color={GameAction.errorColor}> \n -{waste} Wasted");
                }
                else
                {
                    message = string.Format($"<color={GameAction.okColor}>{ingredient.foodName} +{ingredient.nutritionValue} food ingredients.");
                }
                return(true);
            }
            break;

        default:
            break;
        }
        return(base.Doable(interactable, out message));
    }