public async Task <IActionResult> Get() { var fuels = await _fuelDataAccess.GetFuels(); if (fuels is null) { return(NotFound()); } return(Ok(fuels)); }
public async Task <IActionResult> Get(int id) { if (id == 0) { return(BadRequest()); } var ad = await _adDataAccess.GetAdById(id); if (ad != null) { var clients = await _clientDataAccess.GetClients(); var brands = await _brandDataAccess.GetBrands(); var bodies = await _carBodyTypeDataAccess.GetBodyTypes(); var colors = await _colorDataAccess.GetColors(); var fuels = await _fuelDataAccess.GetFuels(); var years = await _productionYearDataAccess.GetYears(); var conditions = await _carConditionDataAccess.GetCarConditions(); var output = new { Ad = ad, ClientNamee = clients.Where(c => c.Id == ad.ClientId).FirstOrDefault()?.ClientName, Addresss = clients.Where(c => c.Id == ad.ClientId).FirstOrDefault()?.Address, Cityy = clients.Where(c => c.Id == ad.ClientId).FirstOrDefault()?.City, ZIPP = clients.Where(c => c.Id == ad.ClientId).FirstOrDefault()?.ZIP, Countryy = clients.Where(c => c.Id == ad.ClientId).FirstOrDefault()?.Country, Phonee = clients.Where(c => c.Id == ad.ClientId).FirstOrDefault()?.Phone, Brand = brands.Where(b => b.Id == ad.BrandId).FirstOrDefault()?.BrandName, Body = bodies.Where(b => b.Id == ad.CarBodyTypeId).FirstOrDefault()?.BodyType, Color = colors.Where(c => c.Id == ad.ColorId).FirstOrDefault()?.ColorName, Fuel = fuels.Where(f => f.Id == ad.FuelId).FirstOrDefault()?.FuelType, Year = years.Where(y => y.Id == ad.ProductionYearId).FirstOrDefault()?.YearName, FirstOwnerr = conditions.Where(c => c.Id == ad.CarConditionId).FirstOrDefault()?.FirstOwner, Warrantyy = conditions.Where(c => c.Id == ad.CarConditionId).FirstOrDefault()?.Warranty, Garagedd = conditions.Where(c => c.Id == ad.CarConditionId).FirstOrDefault()?.Garaged, ServiceBookk = conditions.Where(c => c.Id == ad.CarConditionId).FirstOrDefault()?.ServiceBook, SpareKeyy = conditions.Where(c => c.Id == ad.CarConditionId).FirstOrDefault()?.SpareKey, Restauratedd = conditions.Where(c => c.Id == ad.CarConditionId).FirstOrDefault()?.Restaurated, Oldtimerr = conditions.Where(c => c.Id == ad.CarConditionId).FirstOrDefault()?.Oldtimer, AdaptedForTheDisabledd = conditions.Where(c => c.Id == ad.CarConditionId).FirstOrDefault()?.AdaptedForTheDisabled, TaxiCarr = conditions.Where(c => c.Id == ad.CarConditionId).FirstOrDefault()?.TaxiCar, TestCarr = conditions.Where(c => c.Id == ad.CarConditionId).FirstOrDefault()?.TestCar, Tuningg = conditions.Where(c => c.Id == ad.CarConditionId).FirstOrDefault()?.Tuning }; return(Ok(output)); } else { return(NotFound()); } }