public IActionResult GetByBrandId(int brandId) { if (_brandRepository.GetById(brandId) == null) { return(NotFound($"Merk met id {brandId} niet gevonden")); } var models = _modelRepository.Find(model => model.Brand.Id == brandId); return(Ok(models.Select(_mapper.Map <ModelReturnModel>).ToList())); }
public IEnumerable <DtoModel> GetBrandModelsList(int brandId) { var models = _modelRepository.Find(m => m.BrandId == brandId) .Select(m => new DtoModel { Id = m.Id, Name = m.Name, BrandId = m.BrandId }); return(models); }
public IActionResult GetEngineTypePartsInManufacturer() { IEnumerable <EngineDto> engines = _engines.GetAll(); IEnumerable <EngineTypeDto> engineTypes = _engineTypes.GetAll(); var result = _manufacturers.GetAll() .Select(m => { var manufacturerModels = _models.Find(mm => mm.ManufacturerId == m.Id); return(new { ManufacturerId = m.Id, ManufacturerName = m.Name, EngineTypeParts = engineTypes .Join(engines, et => et.Id, e => e.EngineTypeId, (et, e) => new { typesId = et.Id, enginesId = e.Id }) .Join(manufacturerModels, at => at.enginesId, model => model.EngineId, (at, model) => new { model.Name, at.typesId }) .GroupBy(v => v.typesId) .Select(s => new { EngineTypeId = s.Key, Part = SafePartValue(s, manufacturerModels) }) .OrderBy(o => o.EngineTypeId) .ToDictionary(at => at.EngineTypeId, at => at.Part) }); }); var resultWithHeader = new { EngineTypes = engineTypes .Select(et => new { et.Id, et.Name }) .OrderBy(o => o.Id), Table = result }; return(Ok(resultWithHeader)); }
public List <Model> QueryByCC(int cc) { var model = modelRepository.Find(x => x.cc == cc).ToList(); return(model); }