public IActionResult Get(string id)
        {
            DataAccess  accessor      = new DataAccess();
            fermentable currentRecipe = accessor.Get <fermentable>(id);

            return(Json(currentRecipe));
        }
Example #2
0
        public void Change(object value, string name)
        {
            var str = value is IEnumerable <object>?string.Join(", ", (IEnumerable <object>) value) : value;

            if (Model.fermentables.Count == 0)
            {
                fermentable         hopw = new fermentable();
                fermentableAddition ha   = new fermentableAddition();
                Model.fermentables.Add(ha);
                Model.fermentables[0].fermentable = hopw;
                fermentableState.currentSelectedFermentableIndex = 0;
            }
            fermentableState.currentSelectedFermentableID = value.ToString();
            Model.fermentables[fermentableState.currentSelectedFermentableIndex].fermentable   = AllFermentables.Where(x => x.idString == value).FirstOrDefault();
            Model.fermentables[fermentableState.currentSelectedFermentableIndex].fermentableID = value.ToString();

            if (Model.fermentables.Count != 0)
            {
                fermentableName = Model.fermentables[fermentableState.currentSelectedFermentableIndex].fermentable.name;
            }
            else
            {
                fermentableName = "";
            }

            Save(false);

            StateHasChanged();
        }
Example #3
0
        public List <fermentableAddition> mapFermentableAdditions(List <fermentableObj> Fermentables)
        {
            List <fermentableAddition> fermentableAdditions = new List <fermentableAddition>();

            foreach (fermentableObj f in Fermentables)
            {
                fermentable fm = new fermentable();
                fm.name   = f.NAME;
                fm.yield  = f.YIELD == null ? 0 : f.YIELD.Value;
                fm.notes  = f.NOTES;
                fm.origin = f.ORIGIN;
                //fm.   f.POTENTIAL not used
                //fm.protein = f.PROTEIN.Value;  ?f.PROTEIN is a string... why...
                // f.RECOMMEND_MASH not used
                fm.type = f.TYPE;
                // f.ADD_AFTER_BOIL not used
                //fm.coarse_fine_diff = f.COARSE_FINE_DIFF;  //ALSO A STRING!!!
                // fm.diastatic_power = f.DIASTATIC_POWER  also a string
                //f.IBU_GAL_PER_LB
                //f.MAX_IN_BATCH not used
                //fm.moisture = f.MOISTURE  also a string
                fm.type     = f.TYPE;
                fm.color    = f.COLOR == null ? 0 : f.COLOR.Value;
                fm.maltster = f.ORIGIN;

                fermentableAddition addition = new fermentableAddition();
                addition.additionGuid = Guid.NewGuid().ToString();
                addition.fermentable  = fm;
                // addition.use = "Mash";
                addition.weight = (float)(f.AMOUNT * KGtoLB);//Amount is in kilograms
                fermentableAdditions.Add(addition);
            }
            return(fermentableAdditions);
        }
        public ActionResult DeleteConfirmed(int id)
        {
            fermentable fermentable = db.fermentables.Find(id);

            db.fermentables.Remove(fermentable);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public IActionResult Post([FromBody] fermentable value, string id)
        {
            //double ibu = MathFunctions.IBU.basicIBU(value, 1.07);

            DataAccess accessor = new DataAccess();

            value = GlobalFunctions.AddIdIfNeeded(value, id);

            return(Json(accessor.Post(value)));
        }
 public ActionResult Edit([Bind(Include = "id,name,ftype,amount,yield,color,add_after_boil,origin,supplier,notes,coarse_fine_diff,moisture,diastatic_power,protein,max_in_batch,recommend_mash,is_mashed,ibu_gal_per_lb,display_unit,display_scale,deleted,display,folder")] fermentable fermentable)
 {
     if (ModelState.IsValid)
     {
         db.Entry(fermentable).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(fermentable));
 }
        // GET: fermentables/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            fermentable fermentable = db.fermentables.Find(id);

            if (fermentable == null)
            {
                return(HttpNotFound());
            }
            return(View(fermentable));
        }
Example #8
0
 public string findFermentableIDFromSelecteFermentable()
 {
     resetSelector();
     if (fermentableState.currentSelectedFermentableIndex != -1 && Model.fermentables.Count != 0)
     {
         fermentable currentSelection = AllFermentables.Where(x => x.name == Model.fermentables[fermentableState.currentSelectedFermentableIndex].fermentable.name).FirstOrDefault();
         if (currentSelection == null)
         {
             return("-1");
         }
         else
         {
             return(currentSelection.idString);
         }
     }
     else
     {
         return("-1");
     }
 }