Пример #1
0
 public Seed(Tuple <char, int, int> position, FlowerType flower, StemType stem)
 {
     ValidatePosition(position);
     this.Position = position;
     this.Flower   = flower;
     this.Stem     = stem;
 }
Пример #2
0
 public void SetSeed(Tuple <char, int, int> position, FlowerType flower, StemType stem)
 {
     using (var dbContext = new PlantTycoonContext())
     {
         //var seed = dbContext.Seeds.FirstOrDefault(x => x.Position == position);
         var seed = new Seed(position, flower, stem);
         dbContext.Seeds.Add(seed);
         dbContext.SaveChanges();
     }
 }
Пример #3
0
 public List <StemFormula> ReportForStemType(StemType stemType)
 {
     using (var dbContext = new PlantTycoonContext())
     {
         var stemFormulas = dbContext.StemFormulas
                            .Where(x => x.StemA == stemType || x.StemB == stemType)
                            .OrderBy(x => x.StemA.ToString())
                            .ThenBy(x => x.StemB.ToString());
         return(stemFormulas.ToList());
     }
 }
Пример #4
0
        private void SetStemFormula(StemType stemA, StemType stemB, StemType?result, bool inProgress)
        {
            using (var dbContext = new PlantTycoonContext())
            {
                var stemFormulas = dbContext.StemFormulas.Where(x => x.StemA == stemA && x.StemB == stemB ||
                                                                x.StemA == stemB && x.StemB == stemA);

                if (stemFormulas.Count() != 1)
                {
                    throw new InvalidOperationException($"There should be one and only one formula for those two stems, but we found {stemFormulas.Count()}");
                }

                stemFormulas.First().SetResultAndInProgress(result, inProgress);
                dbContext.SaveChanges();
            }
        }
Пример #5
0
 public void SetStemFormula(StemType stemA, StemType stemB, bool inProgress)
 {
     this.SetStemFormula(stemA, stemB, null, inProgress);
 }
Пример #6
0
 public void SetStemFormula(StemType stemA, StemType stemB, StemType result)
 {
     this.SetStemFormula(stemA, stemB, result, false);
 }
Пример #7
0
        }                             //For EF

        public StemFormula(StemType stemA, StemType stemB, StemType?result = null)
        {
            this.StemA  = stemA;
            this.StemB  = stemB;
            this.Result = result;
        }
Пример #8
0
 public Plant(FlowerType flower, StemType stem, bool inProgress = false)
 {
     this.Flower     = flower;
     this.Stem       = stem;
     this.InProgress = InProgress;
 }