Exemplo n.º 1
0
        public ActionResult <IEnumerable <PlantDto> > GetPlants(
            //[FromQuery] string genus, [FromQuery] string searchQuery
            [FromQuery] PlantResourceParameters plantResourceParameters)   //IActionResult
        {
            var plantsFromRep = _experimentRepository.GetPlants(plantResourceParameters);

            var plantsDto = _mapper.Map <IEnumerable <PlantDto> >(plantsFromRep);

            //foreach (var plant in plantsFromRep)
            //{
            //    plantsDto.Add(new PlantDto
            //    {
            //        Id = plant.Id,
            //        Name = plant.Name,
            //        Classification = $"{plant.Genus},{plant.Family}",
            //        DaysFromPlanting = plant.PlantingDate.GetGapDays(),
            //        Multiplication = (int)plant.Multiplication
            //    }) ;
            //}

            return(Ok(plantsDto));//new JsonResult(plants);
        }