public async Task <PlantResponse> GetAllPlants() { var result = await _plantsRepository.GetAll(); PlantResponse plantResponse = new PlantResponse(); plantResponse.plants = new List <PlantRow>(); foreach (var item in result) { PlantRow plantRow = new PlantRow(); item.CopyPropertiesTo(plantRow); TimeSpan timeSpan = DateTime.Now - item.LastWateringDate; if (timeSpan.TotalHours >= 6) { plantRow.plantsStatus = PlantsStatus.ReadyToWattering; plantRow.statusName = PlantsStatus.ReadyToWattering.ToString(); } else { plantRow.plantsStatus = PlantsStatus.Watered; plantRow.statusName = PlantsStatus.Watered.ToString(); } plantResponse.plants.Add(plantRow); } plantResponse.ResultCount = plantResponse.plants.Count; plantResponse.ToSuccess <PlantResponse>(); return(plantResponse); }
// setup rules with: //..#.. => . //##.## => . //.##.# => # // setup row of plants as: // ..#..##.##.##.# in order to have the rules available with different offsets in the row public PlantRowTests(ITestOutputHelper logger) { _logger = logger; _plantRow = new PlantRow(); var rules = new List <RuleDescription> { new RuleDescription { Result = '.', Specifier = "..#.." }, new RuleDescription { Result = '.', Specifier = "##.##" }, new RuleDescription { Result = '#', Specifier = ".##.#" } }; _plantRow.Rules.AddRange(rules); _plantRow.Plants = "..#..##.##.##.#"; }