예제 #1
0
        /**
         * Select prep info from database
         **/
        public List <Preperation> selectPrep(List <Preperation> recipeprep, Recipe recipe)
        {
            SqlCommand selectPreperation = new SqlCommand("SELECT PrepRecipe.Preperationid, Preperation.instruction, Preperation.instructionNum, Preperation.uniqueid, Preperation.progress, PrepRecipe.recipeId FROM PrepRecipe INNER JOIN Preperation ON PrepRecipe.PreperationId=Preperation.id WHERE PrepRecipe.updateTime > @lastUpdated", connection1);

            selectPreperation.Parameters.AddWithValue("@lastUpdated", lastUpdated);
            var selectPreperationReader = selectPreperation.ExecuteReader();

            while (selectPreperationReader.Read())
            {
                Preperation preps = new Preperation();
                preps.prep         = new List <string>();
                preps.uniqueid     = new List <string>();
                preps.prepNums     = new List <Int32>();
                preps.prepprogress = new List <string>();
                preps.preprecipe   = new List <string>();
                //builds prep json
                preps.prep.Add((string)selectPreperationReader["instruction"]);
                preps.uniqueid.Add((string)selectPreperationReader["uniqueid"]);
                preps.prepNums.Add((Int32)selectPreperationReader["instructionNum"]);
                preps.prepprogress.Add((string)selectPreperationReader["progress"]);
                preps.preprecipe.Add(selectRecipe((Int32)selectPreperationReader["recipeId"]));
                recipeprep.Add(preps);
            }
            return(recipeprep);
        }
예제 #2
0
        /**
         * Select prep info from database
         *
         * recipeprep - List of prep info for recipe
         * recipe - info about recipe
         *
         * return - recipeprep - Update list of prep info for recipe
         **/
        public List <Preperation> selectPrep(List <Preperation> recipeprep, Recipe recipe)
        {
            SqlCommand selectPreperation = new SqlCommand("SELECT PrepRecipe.Preperationid, Preperation.instruction, Preperation.instructionNum, Preperation.uniqueid, Preperation.progress FROM PrepRecipe INNER JOIN Preperation ON PrepRecipe.PreperationId=Preperation.id WHERE PrepRecipe.recipeId = @recipe;", connection1);

            selectPreperation.Parameters.AddWithValue("@recipe", recipe.id);
            var selectPreperationReader = selectPreperation.ExecuteReader();

            while (selectPreperationReader.Read())
            {
                //Builds preperation details for JSON based on reader
                Preperation preps = new Preperation();
                preps.prep         = new List <string>();
                preps.uniqueid     = new List <string>();
                preps.prepNums     = new List <Int32>();
                preps.prepprogress = new List <string>();
                preps.prep.Add((string)selectPreperationReader["instruction"]);
                preps.uniqueid.Add((string)selectPreperationReader["uniqueid"]);
                preps.prepNums.Add((Int32)selectPreperationReader["instructionNum"]);
                preps.prepprogress.Add((string)selectPreperationReader["progress"]);
                recipeprep.Add(preps);
            }
            return(recipeprep);
        }
예제 #3
0
 public PreperationState(Preperation model, PreperationView view)
 {
     _model = model;
     _view  = view;
 }
예제 #4
0
        public PreperationState CreateController(Preperation model, PreperationView view)
        {
            var controller = new PreperationState(model, view);

            return(controller);
        }