public async Task <IActionResult> GetSoftwareModuleResearchByTypeEntity(string typeEntity)
        {
            IEnumerable <SoftwareData> _ieSoftwares = await _softwareGateway.GetAllSoftware();

            if (_ieSoftwares == null)
            {
                return(BadRequest("Software not found"));
            }

            List <SoftwareData>            _softwares            = _ieSoftwares.AsList();
            List <SoftwareAndResearchData> _softwaresAndResearch = new List <SoftwareAndResearchData>();

            for (int i = 0; i < _softwares.Count; i++)
            {
                IEnumerable <ResearchModuleData> researchModules = await _researchModuleGateway.GetResearchModuleBySoftwareId(_softwares[i].Id);

                _softwaresAndResearch.Add(new SoftwareAndResearchData(_softwares[i], researchModules.AsList()));
            }

            for (int i = 0; i < _softwaresAndResearch.Count; i++)
            {
                SoftwareAndResearchData softwareResearchModule = _softwaresAndResearch[i];
                for (int y = 0; y < softwareResearchModule.ResearchModule.Count; y++)
                {
                    ResearchModuleData researchModules = softwareResearchModule.ResearchModule[y];
                    if (researchModules.TypeEntity != typeEntity)
                    {
                        softwareResearchModule.ResearchModule.RemoveAt(y);
                        y--;
                    }
                }
                if (softwareResearchModule.ResearchModule.Count <= 0)
                {
                    _softwaresAndResearch.RemoveAt(i);
                    i--;
                }
            }
            if (_softwaresAndResearch == null)
            {
                return(BadRequest("Research module with this type entity not found"));
            }

            return(Ok(_softwaresAndResearch));
        }
Example #2
0
        public async Task <IActionResult> GetAllSoftwareAndResearch()
        {
            IEnumerable <SoftwareData> _ieSoftwares = await _softwareGateway.GetAllSoftware();

            if (_ieSoftwares == null)
            {
                return(BadRequest("Software not found"));
            }

            List <SoftwareData>            _softwares            = _ieSoftwares.AsList();
            List <SoftwareAndResearchData> _softwaresAndResearch = new List <SoftwareAndResearchData>();

            for (int i = 0; i < _softwares.Count; i++)
            {
                IEnumerable <ResearchModuleData> researchModules = await _researchModuleGateway.GetResearchModuleBySoftwareId(_softwares[i].Id);

                _softwaresAndResearch.Add(new SoftwareAndResearchData(_softwares[i], researchModules.AsList()));
            }

            return(Ok(_softwaresAndResearch));
        }