コード例 #1
0
        //update the recipe yield
        public ActionResult UpdateRecipeYield(int RecipeIdInput, string YieldMultiplierInput)
        {
            RecipeIdInputStatic = RecipeIdInput;
            var db          = new BakeryInventoryEntities();
            var rec         = db.Recipe;
            var recToUpdate = (from r in rec where r.RecipeId == RecipeIdInput select r).First();
            var yieldAdjustmentCalculations = new YieldCalculations();
            var yieldMultiplier             = 0m;

            if (YieldMultiplierInput.Contains('/'))   //if the value is a fraction, then convert it to a rounded decimal
            {
                var parseFractionToDecimal = new ParseFractionToDecimal();
                yieldMultiplier = parseFractionToDecimal.CalculateFractionToDecimal(YieldMultiplierInput);
            }
            else
            {
                yieldMultiplier = System.Convert.ToDecimal(YieldMultiplierInput);
            }
            if (recToUpdate.Yield == 0)
            {
                recToUpdate.Yield = yieldAdjustmentCalculations.RoundToInteger(yieldMultiplier);
            }
            recToUpdate.Yield = yieldAdjustmentCalculations.RoundToInteger(recToUpdate.Yield * yieldMultiplier);
            db.SaveChanges();
            return(RedirectToAction("RecipeIngredients", new { RecipeIdInput = RecipeIdInputStatic }));
        }
コード例 #2
0
        //InsertMethods
        public ActionResult InsertIngredient(int RecipeIdInput, string NameInput, string WeightValueInput, int WeightIdInput, string MeasurementValueInput, int MeasurementTypeIdInput, int IngredientTypeIdInput)
        {
            var db  = new BakeryInventoryEntities();
            var rec = db.Recipe;

            ViewBag.AllRecipes = (from r in rec select r).ToList();
            var intTypes = db.IngredientType;

            ViewBag.AllIngredientTypes = (from it in intTypes select it).ToList();
            var measTypes = db.MeasurementType;

            ViewBag.AllMeasurementTypes = (from mt in measTypes select mt).ToList();
            var wType = db.Weight;

            ViewBag.AllWeights = (from w in wType select w).ToList();
            var ingDets = db.vw_IngredientDetails;

            ViewBag.AllIngredientDetails = (from id in ingDets select id).ToList();
            var ing = db.Ingredient;
            var ins = new Ingredient {
                Name              = NameInput,
                RecipeId          = RecipeIdInput,
                WeightValue       = System.Convert.ToDecimal(WeightValueInput),
                WeightId          = WeightIdInput,
                MeasurementValue  = System.Convert.ToDecimal(MeasurementValueInput),
                MeasurementTypeId = MeasurementTypeIdInput,
                IngredientTypeId  = IngredientTypeIdInput
            };

            db.Ingredient.Add(ins);
            db.SaveChanges();
            return(View("Ingredient"));
        }
コード例 #3
0
        public vw_RecipeDetails GetRecipeInfo(int RecipeIdInput)
        {
            var db      = new BakeryInventoryEntities();
            var rec     = db.vw_RecipeDetails;
            var recDets = (from r in rec where r.RecipeId == RecipeIdInput select r).First();

            return(recDets);
        }
コード例 #4
0
        public List <RecipeType> GetAllRecipeTypes()
        {
            var db          = new BakeryInventoryEntities();
            var rTypes      = db.RecipeType;
            var recipeTypes = (from rt in rTypes orderby rt.Name select rt).ToList();

            return(recipeTypes);
        }
コード例 #5
0
        public List <Recipe> GetAllRecipesPlain()
        {
            var db   = new BakeryInventoryEntities();
            var rec  = db.Recipe;
            var recs = (from r in rec orderby r.Name select r).ToList();

            return(recs);
        }
コード例 #6
0
        //RetrieveDataMethods
        public List <vw_RecipeDetails> GetAllRecipes()
        {
            var db      = new BakeryInventoryEntities();
            var rec     = db.vw_RecipeDetails;
            var recDets = (from r in rec orderby r.RecipeTypeName, r.RecipeName select r).ToList();

            return(recDets);
        }
コード例 #7
0
        public List <vw_RecipeDetails> GetAllRecipesForRecipeTypeView(int RecipeTypeIdInput)
        {
            var db      = new BakeryInventoryEntities();
            var rec     = db.vw_RecipeDetails;
            var recDets = (from r in rec where r.RecipeTypeId == RecipeTypeIdInput select r).ToList();

            return(recDets);
        }
コード例 #8
0
        public vw_IngredientDetails GetSingleIngredientDetails(int IngredientIdInput)
        {
            var db      = new BakeryInventoryEntities();
            var ings    = db.vw_IngredientDetails;
            var ingDets = (from i in ings where i.IngredientId == IngredientIdInput select i).First();

            return(ingDets);
        }
コード例 #9
0
        public List <Brand> GetAllBrandNames()
        {
            var db            = new BakeryInventoryEntities();
            var brands        = db.Brand;
            var allBrandNames = (from b in brands select b).ToList();

            return(allBrandNames);
        }
コード例 #10
0
        public List <Weight> GetAllWeight()
        {
            var db        = new BakeryInventoryEntities();
            var weight    = db.Weight;
            var allWeight = (from w in weight orderby w.Name select w).ToList();

            return(allWeight);
        }
コード例 #11
0
        public List <MeasurementType> GetAllMeasurementType()
        {
            var db       = new BakeryInventoryEntities();
            var measType = db.MeasurementType;
            var allMT    = (from mt in measType orderby mt.Name select mt).ToList();

            return(allMT);
        }
コード例 #12
0
        public List <vw_IngredientDetails> GetIngredientDetails()
        {
            var db         = new BakeryInventoryEntities();
            var ingDets    = db.vw_IngredientDetails;
            var allIngDets = (from iD in ingDets orderby iD.RecipeName, iD.IngredientTypeName, iD.Measurement select iD).ToList();

            return(allIngDets);
        }
コード例 #13
0
        public List <IngredientType> GetAllIngredientTypes()
        {
            var db       = new BakeryInventoryEntities();
            var types    = db.IngredientType;
            var allTypes = (from t in types orderby t.TypeName select t).ToList();

            return(allTypes);
        }
コード例 #14
0
        public List <Ingredient> GetAllIngredients()
        {
            var db      = new BakeryInventoryEntities();
            var ings    = db.Ingredient;
            var allIngs = (from i in ings select i).ToList();

            return(allIngs);
        }
コード例 #15
0
        public List <Recipe> GetAllRecipesForRecipeType(int RecipeTypeIdInput)
        {
            var db         = new BakeryInventoryEntities();
            var rec        = db.Recipe;
            var listOfRecs = (from r in rec where r.RecipeTypeId == RecipeTypeIdInput select r).ToList();

            return(listOfRecs);
        }
コード例 #16
0
        public RecipeType GetRecipeType(int RecipeTypeIdInput)
        {
            var db          = new BakeryInventoryEntities();
            var recType     = db.RecipeType;
            var recTypeList = (from rt in recType where rt.RecipeTypeId == RecipeTypeIdInput select rt).First();

            return(recTypeList);
        }
コード例 #17
0
        //RetrieveDataMethods
        public List <vw_IngredientDetails> RecipeIngredients(int RecipeIdInput)
        {
            var parse   = new ParseDecimalToFraction();
            var db      = new BakeryInventoryEntities();
            var ings    = db.vw_IngredientDetails;
            var ingDets = (from i in ings where i.RecipeId == RecipeIdInput orderby i.IngredientTypeName, i.Measurement select i).ToList();

            return(ingDets);
        }
コード例 #18
0
        //InsertMethods
        public ActionResult InsertRecipe(string RecipeNameInput, int YieldInput, int RecipeTypeIdInput)
        {
            var db  = new BakeryInventoryEntities();
            var rec = db.Recipe;
            var ins = new Recipe {
                Name         = RecipeNameInput,
                Yield        = YieldInput,
                RecipeTypeId = RecipeTypeIdInput
            };

            db.Recipe.Add(ins);
            db.SaveChanges();
            return(RedirectToAction("Recipe"));
        }
コード例 #19
0
        public ActionResult InsertIngredientForRecipe(int RecipeIdInputIns, string NameInput, string MeasurementValueInput, int MeasurementTypeIdInput, int IngredientTypeIdInput)
        {
            var db  = new BakeryInventoryEntities();
            var ing = db.Ingredient;

            RecipeIdInputStatic = RecipeIdInputIns;
            var ins = new Ingredient {
                Name              = NameInput,
                RecipeId          = RecipeIdInputIns,
                MeasurementValue  = System.Convert.ToDecimal(MeasurementValueInput),
                MeasurementTypeId = MeasurementTypeIdInput, //hardcoded temporarily
                IngredientTypeId  = IngredientTypeIdInput   //harcoded temporarily
            };

            db.Ingredient.Add(ins);
            db.SaveChanges();
            return(RedirectToAction("RecipeIngredients", new { RecipeIdInput = RecipeIdInputStatic }));
        }