Пример #1
0
        //----------------------------------------------------------------------------------------------------
        //----------------------------------------------------------------------------------------------------
        //----------------------------------------------------------------------------------------------------
        //          Recipe

        //----------------------------------------------------------------------------------------------------
        //----------------------------------------------------------------------------------------------------


        public MasterRecipe CreateMasterRecipe(string Name)
        {
            BrewDBContext cont = new BrewDBContext();

            MasterRecipe _recipe = new MasterRecipe();
            MasterRecipe recip   = cont.MasterRecipes.FirstOrDefault(g => g.BrandName == Name);

            if (recip == null)
            {
                _recipe = cont.MasterRecipes.Create();


                _recipe.BrandDescription = "default";
                _recipe.BrandName        = Name;
                _recipe.Ingredients      = new List <Ingredient>();
                _recipe.RecOperations    = new List <RecUnitOperation>();
                _recipe.QaulityTargets   = "default";

                _recipe.Plants = new List <Plant>();

                cont.MasterRecipes.Add(_recipe);
                cont.SaveChanges();
                recip = cont.MasterRecipes.FirstOrDefault(g => g.MasterRecipeID == _recipe.MasterRecipeID);
            }
            return(recip);
        }
Пример #2
0
        public IFluentRecipe AddRecipe(string s)
        {
            //FluentRecipe recactions = new FluentRecipe();

            _recipe = contx.CreateMasterRecipe(s);

//            _recipe = contx.MasterRecipes.FirstOrDefault(g => g.BrandName == s);
            //_isnew = false;

            //if (_recipe == null)
            //{
            //    _isnew = true;
            //    _recipe = new MasterRecipe();

            //    _recipe.BrandDescription = "default";
            //    _recipe.BrandName = s;
            //    _recipe.Ingredients = new List<Ingredient>();
            //    _recipe.RecOperations = new List<RecUnitOperation>();
            //    _recipe.QaulityTargets = "default";

            //    _recipe.Plants = new List<Plant>();

            //    contx.MasterRecipes.Add(_recipe);
            //    contx.SaveChanges();

            //}

            return(this);
        }
Пример #3
0
        public List <MasterRecipe> AddMasterRecipeToPlant(int plantID, int masterRecipeID)
        {
            BrewDBContext cont = new BrewDBContext();

            MasterRecipe rec = cont.MasterRecipes.SingleOrDefault(g => g.MasterRecipeID == masterRecipeID);

            cont.Plants.SingleOrDefault(g => g.PlantID == plantID).ThisPlantsBrands.Add(rec);
            cont.SaveChanges();

            List <MasterRecipe> recList = cont.Plants.SelectMany(g => g.ThisPlantsBrands).ToList();



            return(recList);
        }
Пример #4
0
        public FluentRecipeOperations(MasterRecipe parent, string s)
        {
            //MasterRecipe rec = parent;
            _recipe = parent;
//            _operation =_parent.GetRecipe().RecOperations.FirstOrDefault(g=>g.OperationName==s);
            //_operation = contx.MasterRecipes.FirstOrDefault(g => g.BrandName == rec.BrandName).RecOperations.FirstOrDefault(e => e.OperationName == s);
            _operation = _recipe.RecOperations.FirstOrDefault(g => g.OperationName == s);

            //if (_operation == null)
            //{
            //    //_operation = new RecUnitOperation();

            //    AddOperation(s);

            //}
        }
Пример #5
0
        public RecUnitOperation AddRecUnitOperation(MasterRecipe recx, string Name)
        {
            BrewDBContext    cont      = new BrewDBContext();
            MasterRecipe     rec       = cont.MasterRecipes.FirstOrDefault(g => g.MasterRecipeID == recx.MasterRecipeID);
            RecUnitOperation operation = cont.RecUnitOperations.Create();


            operation = rec.RecOperations.FirstOrDefault(g => g.OperationName == Name);



            if (operation == null)
            {
                operation = cont.RecUnitOperations.Create();

                operation.OperationName = Name;
                operation.SetPoint      = 0;
                operation.Transitions   = new List <Transition>();
                operation.AllowedUnits  = new List <Unit>();

                cont.MasterRecipes.FirstOrDefault(g => g.MasterRecipeID == recx.MasterRecipeID).RecOperations.Add(operation);

                //cont.RecUnitOperations.Add(operation);
                cont.SaveChanges();

                //cont.MasterRecipes.FirstOrDefault(f => f.BrandName == rec.BrandName).RecOperations.Add(_operation);

                //cont.SaveChanges();
            }
            //else
            //{


            //}


            return(operation);
        }
Пример #6
0
 public FluentRecipeOperations(MasterRecipe parent)
 {
     _recipe = parent;
 }
Пример #7
0
 public IFluentRecipe ForRecipe(string s)
 {
     _recipe = contx.MasterRecipes.FirstOrDefault(g => g.BrandName == s);
     return(this);
 }