Example #1
0
 public static ModelDetailsViewModel FromModel(Model model)
 {
     if (model == null)
     {
         return new ModelDetailsViewModel {
                    Images = new List <ModelImageViewModel>()
         }
     }
     ;
     return(new ModelDetailsViewModel {
         Id = model.Id,
         MakeId = model.MakeId,
         Name = model.Name,
         Year = model.Year,
         BasePrice = model.BasePrice,
         EngineType = model.EngineType,
         ZeroToSixty = model.ZeroToSixty,
         BreakHorsepower = model.BreakHorsepower,
         TopSpeed = model.TopSpeed,
         Description = model.Description,
         Images = model.Images.Select(x => ModelImageViewModel.FromModel(x)).ToList(),
         MakeName = model.Make.Name,
         MakeImageUrl = model.Make.ImageUrl
     });
 }
Example #2
0
 public static ModelImage ToModel(ModelImageViewModel viewModel)
 {
     return(new ModelImage {
         Id = viewModel.Id,
         HighResolutionUrl = viewModel.HighResolutionUrl,
         LowResolutionUrl = viewModel.LowResolutionUrl,
         Order = viewModel.Order,
         ShortDescription = viewModel.ShortDescription,
         LongDescription = viewModel.ShortDescription,
         ModelId = viewModel.ModelId
     });
 }
 public static ModelImage ToModel(ModelImageViewModel viewModel)
 {
     return new ModelImage {
         Id = viewModel.Id,
         HighResolutionUrl = viewModel.HighResolutionUrl,
         LowResolutionUrl = viewModel.LowResolutionUrl,
         Order = viewModel.Order,
         ShortDescription = viewModel.ShortDescription,
         LongDescription = viewModel.ShortDescription,
         ModelId = viewModel.ModelId
     };
 }