public Seed(Tuple <char, int, int> position, FlowerType flower, StemType stem) { ValidatePosition(position); this.Position = position; this.Flower = flower; this.Stem = stem; }
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(); } }
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()); } }
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(); } }
public void SetStemFormula(StemType stemA, StemType stemB, bool inProgress) { this.SetStemFormula(stemA, stemB, null, inProgress); }
public void SetStemFormula(StemType stemA, StemType stemB, StemType result) { this.SetStemFormula(stemA, stemB, result, false); }
} //For EF public StemFormula(StemType stemA, StemType stemB, StemType?result = null) { this.StemA = stemA; this.StemB = stemB; this.Result = result; }
public Plant(FlowerType flower, StemType stem, bool inProgress = false) { this.Flower = flower; this.Stem = stem; this.InProgress = InProgress; }