LocomotiveDetailsViewModel ITrainsPlanesCars.CreateLocomotiveDetailsViewModel(int identifier) { var vm = new LocomotiveDetailsViewModel(); var dto = LocomotiveService.ReadDetails(identifier); /* mapper */ vm.LocoId = dto.LocoId; vm.Name = dto.Name; vm.ClassificationDetails = dto.ClassificationDetails; vm.DCCValue = dto.DCCValue; vm.DecoderDetails = dto.DecoderDetails; vm.Description = dto.Description; vm.Manufacturer = dto.Manufacturer; vm.YearPurchased = dto.YearPurchased; vm.Power = dto.Power; return(vm); }
public ActionResult Index() { LocomotivesDetailsViewModel vm = new LocomotivesDetailsViewModel(); var dto = service.ReadDetails(); /* map dto to view model */ if (dto.HasLocomotives) { vm.HasLocomotives = true; foreach (var loco in dto.listOfLocomotives) { vm.Locomotives.Add(new LocomotiveDetailsViewModel() { LocoId = loco.LocoId, Name = loco.Name, MadeBy = loco.MadeBy, Manufacturer = loco.Manufacturer, DCCValue = loco.DCCValue, Decoder = loco.Decoder, DecoderDetails = loco.DecoderDetails, Description = loco.Description, YearPurchased = loco.YearPurchased, Classification = loco.Classification, ClassificationDetails = loco.ClassificationDetails }); } } else { vm.HasLocomotives = false; } return(View(vm)); }