예제 #1
0
        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;
        }
예제 #2
0
        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;
        }