public ActionResult Edit([Bind(Include = "C_id,C_id_ingred,C_id_dish,kol")] RECIPE rECIPE)
 {
     if (ModelState.IsValid)
     {
         db.Entry(rECIPE).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.C_id_dish   = new SelectList(db.BOOK_DISH, "C_id_dish", "name_dish", rECIPE.C_id_dish);
     ViewBag.C_id_ingred = new SelectList(db.INGREDIENTs, "C_id_ingred", "name_ingredient", rECIPE.C_id_ingred);
     return(View(rECIPE));
 }
Пример #2
0
 public ActionResult Edit([Bind(Include = "RecipeId,Rating,SubmittedDate,ModifiedDate,Votes,SubmittedBy,ModifiedBy,Name,Description,Category,ImageURL")] RECIPE rECIPE)
 {
     if (ModelState.IsValid)
     {
         db.Entry(rECIPE).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Category    = new SelectList(db.RECIPE_CATEGORY, "Recipe_CategoryId", "Name", rECIPE.Category);
     ViewBag.ModifiedBy  = new SelectList(db.AspNetUsers, "Id", "FirstName", rECIPE.ModifiedBy);
     ViewBag.SubmittedBy = new SelectList(db.AspNetUsers, "Id", "FirstName", rECIPE.SubmittedBy);
     return(View(rECIPE));
 }
        public ActionResult Create([Bind(Include = "C_id,C_id_ingred,C_id_dish,kol")] RECIPE rECIPE)
        {
            if (ModelState.IsValid)
            {
                db.RECIPEs.Add(rECIPE);
                db.SaveChanges();
                return(RedirectToAction("Create"));
            }

            ViewBag.C_id_dish   = new SelectList(db.BOOK_DISH, "C_id_dish", "name_dish", rECIPE.C_id_dish);
            ViewBag.C_id_ingred = new SelectList(db.INGREDIENTs, "C_id_ingred", "name_ingredient", rECIPE.C_id_ingred);
            return(View(rECIPE));
        }
Пример #4
0
    //Code to execute when King change his idea. Change the recipe's ref. Need some other things for randomization and to deal with animations
    public void ChangeWhatKingWants()
    {
        KING_WANT_THAT = RecipesRef.RECIPES[Random.Range(0, RecipesRef.RECIPES.Count)];

        //Important mais fait chier
        tempRecipe.recipe_ingredients.Clear();
        tempRecipe.recipe_bonuses.Clear();
        tempRecipe.recipe_bonuses.AddRange(KING_WANT_THAT.recipe_bonuses);
        tempRecipe.recipe_ingredients.AddRange(KING_WANT_THAT.recipe_ingredients);
        tempRecipe.recipe_name = KING_WANT_THAT.recipe_name;

        kingTextRef.text = "I WANT " + KING_WANT_THAT.recipe_name;
    }
Пример #5
0
        // GET: Recipes/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RECIPE rECIPE = db.RECIPE.Find(id);

            if (rECIPE == null)
            {
                return(HttpNotFound());
            }
            return(View(rECIPE));
        }
        // GET: RECIPEs/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RECIPE rECIPE = db.RECIPEs.Find(id);

            if (rECIPE == null)
            {
                return(HttpNotFound());
            }
            ViewBag.C_id_dish   = new SelectList(db.BOOK_DISH, "C_id_dish", "name_dish", rECIPE.C_id_dish);
            ViewBag.C_id_ingred = new SelectList(db.INGREDIENTs, "C_id_ingred", "name_ingredient", rECIPE.C_id_ingred);
            return(View(rECIPE));
        }
Пример #7
0
        /**
         * A method for uploading a Recipe object to the database.
         */
        public static bool CreateRecipe(FullRecipe fullRecipe)
        {
            using (var db = new RecipeDBConnection())
            {
                RECIPE tmpRECIPE = new RECIPE(fullRecipe.GetName(), fullRecipe.Description);
                db.RECIPEs.Add(tmpRECIPE);
                foreach (var ingredient_in_recipe in fullRecipe.Ingredients)
                {
                    db.INGREDIENT_IN_RECIPE.Add(new INGREDIENT_IN_RECIPE(ingredient_in_recipe.amount, ingredient_in_recipe.unit, (int)tmpRECIPE.ID_RECIPE));
                }

                db.SaveChanges();
            }

            return(false);
        }
Пример #8
0
        // GET: Recipes/Details/5
        public ActionResult SearchRecipe(string search)
        {
            if (string.IsNullOrEmpty(search))
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RECIPE recipe = db.RECIPE.Where(r => r.Name.Contains(search)).FirstOrDefault();

            if (recipe == null)
            {
                return(HttpNotFound());
            }

            CocktailViewModel model = GenerateViewModel(recipe);

            return(View("Details", model));
        }
Пример #9
0
        // GET: Recipes/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RECIPE recipe = db.RECIPE.Find(id);

            if (recipe == null)
            {
                return(HttpNotFound());
            }

            CocktailViewModel model = GenerateViewModel(recipe);

            return(View(model));
        }
Пример #10
0
        // GET: Recipes/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RECIPE rECIPE = db.RECIPE.Find(id);

            if (rECIPE == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Category    = new SelectList(db.RECIPE_CATEGORY, "Recipe_CategoryId", "Name", rECIPE.Category);
            ViewBag.ModifiedBy  = new SelectList(db.AspNetUsers, "Id", "FirstName", rECIPE.ModifiedBy);
            ViewBag.SubmittedBy = new SelectList(db.AspNetUsers, "Id", "FirstName", rECIPE.SubmittedBy);
            return(View(rECIPE));
        }
Пример #11
0
        public ActionResult Create([Bind(Include = "ID_RECIPE,ID_CATEGORY,ID_MEDIDA_YIELD,ID_MEDIDA_PORTION,ID_PREP_TIME,ID_COOK_TIME,ID_SHELF_TIME,YIELD,PORTION_SIZE,PORTION_NUMBER,PRICE,PREP_TIME,COOK_TIME,SHELF_LIFE,IMAGEN,NAME,ACTIVE")] RECIPE rECIPE)
        {
            if (ModelState.IsValid)
            {
                db.RECIPEs.Add(rECIPE);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ID_MEDIDA_YIELD   = new SelectList(db.MEDIDAs, "ID_MEDIDA", "NOMBRE", rECIPE.ID_MEDIDA_YIELD);
            ViewBag.ID_MEDIDA_PORTION = new SelectList(db.MEDIDAs, "ID_MEDIDA", "NOMBRE", rECIPE.ID_MEDIDA_PORTION);
            ViewBag.ID_CATEGORY       = new SelectList(db.CATEGORies, "ID_CATEGORY", "ID_CATEGORY", rECIPE.ID_CATEGORY);
            ViewBag.ID_COOK_TIME      = new SelectList(db.CATEGORies, "ID_CATEGORY", "ID_CATEGORY", rECIPE.ID_COOK_TIME);
            ViewBag.ID_PREP_TIME      = new SelectList(db.CATEGORies, "ID_CATEGORY", "ID_CATEGORY", rECIPE.ID_PREP_TIME);
            ViewBag.ID_SHELF_TIME     = new SelectList(db.CATEGORies, "ID_CATEGORY", "ID_CATEGORY", rECIPE.ID_SHELF_TIME);
            return(View(rECIPE));
        }
Пример #12
0
        public ActionResult Edit([Bind(Include = "ID_RECIPE,ID_CATEGORY,ID_MEDIDA_YIELD,ID_MEDIDA_PORTION,ID_PREP_TIME,ID_COOK_TIME,ID_SHELF_TIME,YIELD,PORTION_SIZE,PORTION_NUMBER,PRICE,PREP_TIME,COOK_TIME,SHELF_LIFE,IMAGEN,NAME,ACTIVE")] RECIPE rECIPE)
        {
            if (ModelState.IsValid)
            {
                db.Entry(rECIPE).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            var idUser = User.Identity.GetUserId();

            ViewBag.ID_USER_SUPPLIER_INSUMO = new SelectList(db.USER_SUPPLIER_INSUMO.Where(x => x.ID_USER == idUser && x.ACTIVE == true).ToList(), "ID_USER_SUPPLIER_INSUMO", "NAME");

            ViewBag.ID_MEDIDA_YIELD   = new SelectList(db.MEDIDAs, "ID_MEDIDA", "NOMBRE", rECIPE.ID_MEDIDA_YIELD);
            ViewBag.ID_MEDIDA_PORTION = new SelectList(db.MEDIDAs, "ID_MEDIDA", "NOMBRE", rECIPE.ID_MEDIDA_PORTION);
            ViewBag.ID_CATEGORY       = new SelectList(db.CATEGORies.Where(x => x.ID_CATEGORY == 4), "ID_CATEGORY", "NAME", rECIPE.ID_CATEGORY);

            ViewBag.ID_COOK_TIME  = new SelectList(db.CATEGORies, "ID_CATEGORY", "NAME", rECIPE.ID_COOK_TIME);
            ViewBag.ID_PREP_TIME  = new SelectList(db.CATEGORies, "ID_CATEGORY", "NAME", rECIPE.ID_PREP_TIME);
            ViewBag.ID_SHELF_TIME = new SelectList(db.CATEGORies, "ID_CATEGORY", "NAME", rECIPE.ID_SHELF_TIME);
            return(View(rECIPE));
        }
Пример #13
0
        // GET: RECIPEs/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RECIPE rECIPE = db.RECIPEs.Find(id);

            if (rECIPE == null)
            {
                return(HttpNotFound());
            }
            var idUser = User.Identity.GetUserId();

            ViewBag.ID_USER_SUPPLIER_INSUMO = new SelectList(db.USER_SUPPLIER_INSUMO.Where(x => x.ID_USER == idUser && x.ACTIVE == true).ToList(), "ID_USER_SUPPLIER_INSUMO", "NAME");
            ViewBag.ID_PORTIONED_BY         = new SelectList(db.MEDIDAs, "ID_MEDIDA", "NOMBRE");
            ViewBag.ID_MEDIDA_YIELD         = new SelectList(db.MEDIDAs, "ID_MEDIDA", "NOMBRE", rECIPE.ID_MEDIDA_YIELD);
            ViewBag.ID_MEDIDA_PORTION       = new SelectList(db.MEDIDAs, "ID_MEDIDA", "NOMBRE", rECIPE.ID_MEDIDA_PORTION);
            ViewBag.ID_CATEGORY             = new SelectList(db.CATEGORies.Where(x => x.ID_CATEGORY == 4), "ID_CATEGORY", "NAME", rECIPE.ID_CATEGORY);
            ViewBag.ID_COOK_TIME            = new SelectList(db.CATEGORies, "ID_CATEGORY", "NAME", rECIPE.ID_COOK_TIME);
            ViewBag.ID_PREP_TIME            = new SelectList(db.CATEGORies, "ID_CATEGORY", "NAME", rECIPE.ID_PREP_TIME);
            ViewBag.ID_SHELF_TIME           = new SelectList(db.CATEGORies, "ID_CATEGORY", "NAME", rECIPE.ID_SHELF_TIME);
            return(View(rECIPE));
        }
Пример #14
0
        private const double KGtoOZ = KGtoLB * 16;//35.71428571428571;

        public recipe ParseBeerXML(string xml)
        {
            //All the converted items
            RECIPE recipeFromXML = new RECIPE();
            List <fermentableObj> Fermentables = new List <fermentableObj>();
            List <hopObj>         Hops         = new List <hopObj>();
            List <yeastObj>       Yeasts       = new List <yeastObj>();
            List <miscObj>        Miscs        = new List <miscObj>();
            styleObj Style = new styleObj();

            //Load the string into an xml object
            XmlDocument   xdoc       = new XmlDocument();
            XmlSerializer serializer = new XmlSerializer((typeof(RECIPE)));

            xdoc.LoadXml(xml);

            //convert the xml object to json
            string  json = JsonConvert.SerializeXmlNode(xdoc);
            JObject recipeInfoFromXML = JObject.Parse(json);

            // get the recipe info
            JToken results = recipeInfoFromXML["RECIPES"]["RECIPE"];

            recipeFromXML = results.ToObject <RECIPE>();

            //same with style
            results = recipeInfoFromXML["RECIPES"]["RECIPE"]["STYLE"];
            Style   = results.ToObject <styleObj>();

            /*
             * When it converts xml to json, due to the way that Json uses list objects and XML does not
             * the parser can't tell the difference between a list and not a list...
             *
             * So we come to this...
             *
             * The try catches handle list vs not list.
             *
             * For example
             * recipeInfoFromXML["RECIPES"]["RECIPE"]["FERMENTABLES"].Children().Children().Children()
             *
             * retrieves items if they are encapsulated in a json list.
             *
             * recipeInfoFromXML["RECIPES"]["RECIPE"]["FERMENTABLES"].Children().Children()
             *
             * retrieves items if they are not encapsulated in a list.
             *
             * So this should handle both instances because if you parse too deep it can't figure out what object you're
             * trying to map into and it throws an exception.
             *
             * */
            try
            {
                IList <JToken> fermentablesList = recipeInfoFromXML["RECIPES"]["RECIPE"]["FERMENTABLES"].Children().Children().Children().ToList();
                foreach (JToken result in fermentablesList)
                {
                    // JToken.ToObject is a helper method that uses JsonSerializer internally
                    fermentableObj searchResult = result.ToObject <fermentableObj>();
                    Fermentables.Add(searchResult);
                }
            }
            catch (Exception e)
            {
                IList <JToken> fermentablesList = recipeInfoFromXML["RECIPES"]["RECIPE"]["FERMENTABLES"].Children().Children().ToList();
                foreach (JToken result in fermentablesList)
                {
                    // JToken.ToObject is a helper method that uses JsonSerializer internally
                    fermentableObj searchResult = result.ToObject <fermentableObj>();
                    Fermentables.Add(searchResult);
                }
            }

            try
            {
                IList <JToken> hopsList = recipeInfoFromXML["RECIPES"]["RECIPE"]["HOPS"].Children().Children().Children().ToList();
                foreach (JToken result in hopsList)
                {
                    // JToken.ToObject is a helper method that uses JsonSerializer internally
                    hopObj searchResult = result.ToObject <hopObj>();
                    Hops.Add(searchResult);
                }
            }
            catch (Exception e)
            {
                IList <JToken> hopsList = recipeInfoFromXML["RECIPES"]["RECIPE"]["HOPS"].Children().Children().ToList();
                foreach (JToken result in hopsList)
                {
                    // JToken.ToObject is a helper method that uses JsonSerializer internally
                    hopObj searchResult = result.ToObject <hopObj>();
                    Hops.Add(searchResult);
                }
            }


            try
            {
                IList <JToken> yeastList = recipeInfoFromXML["RECIPES"]["RECIPE"]["YEASTS"].Children().Children().Children().ToList();
                foreach (JToken result in yeastList)
                {
                    // JToken.ToObject is a helper method that uses JsonSerializer internally
                    yeastObj searchResult = result.ToObject <yeastObj>();
                    Yeasts.Add(searchResult);
                }
            }
            catch (Exception e)
            {
                IList <JToken> yeastList = recipeInfoFromXML["RECIPES"]["RECIPE"]["YEASTS"].Children().Children().ToList();
                foreach (JToken result in yeastList)
                {
                    // JToken.ToObject is a helper method that uses JsonSerializer internally
                    yeastObj searchResult = result.ToObject <yeastObj>();
                    Yeasts.Add(searchResult);
                }
            }

            try
            {
                IList <JToken> miscList = recipeInfoFromXML["RECIPES"]["RECIPE"]["MISCS"].Children().Children().Children().ToList();
                foreach (JToken result in miscList)
                {
                    // JToken.ToObject is a helper method that uses JsonSerializer internally
                    miscObj searchResult = result.ToObject <miscObj>();
                    Miscs.Add(searchResult);
                }
            }
            catch (Exception e)
            {
                IList <JToken> miscList = recipeInfoFromXML["RECIPES"]["RECIPE"]["MISCS"].Children().Children().ToList();
                foreach (JToken result in miscList)
                {
                    // JToken.ToObject is a helper method that uses JsonSerializer internally
                    miscObj searchResult = result.ToObject <miscObj>();
                    Miscs.Add(searchResult);
                }
            }

            recipe final = MapRecipeInfo(recipeFromXML, Fermentables, Hops, Yeasts, Miscs, Style);

            final.equipmentProfile = getDefaultEquipmentProfile();
            final.recipeStats      = makeEmptyRecipeStats();
            final.recipeStats      = MathFunctions.GlobalFunctions.updateStats(final);
            DataAccess accessor = new DataAccess();

            accessor.PostRecipe(final);

            return(final);
        }