public HttpResponseMessage GetCarList() { try { ApplicationMessage appmessage = new ApplicationMessage(); CarProducResponse carResponse = new CarProducResponse(); CarProductMsg carresults = new CarProductMsg(); List <CarsProductDto> carlst = new List <CarsProductDto>(); carresults.appCarProduct = CarsRepository.GetProductList(); carResponse.results = carresults; carResponse.status = true; if (carresults.appCarProduct.Count > 0) { carresults.apiMessage = appmessage.carproductSuccessfully; } else { carresults.apiMessage = appmessage.carproductFails; } carResponse.message = appmessage.executedSuccessfully; if (carresults.appCarProduct != null) { string imgPath = ConfigurationManager.AppSettings["imgPath"]; foreach (var item in carresults.appCarProduct) { CarsProductDto carsProduct = new CarsProductDto(); carsProduct.CarsProductId = item.CarsProductId; carsProduct.CarsProductName1 = item.CarsProductName1; carsProduct.CarsProductDescription = item.CarsProductDescription; carsProduct.CarsPrice = item.CarsPrice; carsProduct.CarsColor = item.CarsColor; carsProduct.CarsKilometers = item.CarsKilometers; carsProduct.CarsDoors = item.CarsDoors; carsProduct.CarsImages = imgPath + item.CarsImages; carlst.Add(carsProduct); } carresults.appCarProduct = carlst; //carresponse.results = carlst; var response = this.Request.CreateResponse(HttpStatusCode.OK); response.Content = new StringContent(JsonConvert.SerializeObject(carResponse, Formatting.None), Encoding.UTF8, "application/json"); return(response); } else { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Not found")); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }