示例#1
0
        public async Task <IActionResult> GetAllTechnologies(
            [FromServices] ITechnologyRepository technologyRepository,
            [FromServices] IEntityRepository entityRepository,
            [FromServices] ITechnologyService technologyService
            )
        {
            var result = await technologyRepository.FindAllAsync();

            if (result.Any())
            {
                var entities = await entityRepository.FindAllAsync();

                var technologiesToReturn = new List <Technology>();
                var referenceEntityId    = configuration.GetSection("ReferenceEntityId");
                foreach (var technology in result)
                {
                    var technologyToAdd = new Technology();
                    technologyToAdd.Map(technology);
                    technologyToAdd.EntitiesStatus = new List <EntityStatus>();
                    foreach (var entity in entities)
                    {
                        technologyToAdd = technologyService.SetEntityStatus(technologyToAdd, entity, referenceEntityId.Value);
                    }
                    technologiesToReturn.Add(technologyToAdd);
                }
                return(Ok(technologiesToReturn));
            }
            return(NoContent());
        }