public CarViewModel GetSingleCar() { CarViewModel carViewModel = new CarViewModel(); var car = Manager.GetDataItems(CarsType) .Where(d => d.Id == CarId) .SingleOrDefault(); if (car != null) carViewModel = GetViewModel(car); return carViewModel; }
private CarViewModel GetViewModel(DynamicContent dContent) { CarViewModel viewModel = new CarViewModel(); viewModel.Id = dContent.Id; viewModel.Title = dContent.GetString("Title").Value; viewModel.Info = dContent.GetString("CarInfo").Value; if (dContent.GetRelatedItemsCountByField("CarImages") > 0) { viewModel.Image = dContent.GetRelatedItems<Image>("CarImages").FirstOrDefault(); } return viewModel; }