public static DummiesAllPageMetadata MapToDummiesAllPageMetadata(DummiesAllViewModel source) { var target = new DummiesAllPageMetadata(); Map(source, target); return(target); }
public ActionResult DummiesAll(long?DummyID) { // Create view model with search form var model = new DummiesAllViewModel(); if (DummyID != null) { AddSuccessMessage("id{0} successful.", DummyID.ToString()); } else { AddWarningMessage(" Warning."); AddWarningMessage(" Warning."); AddErrorMessage(" Error."); AddErrorMessage(" Warning."); AddInformationMessage(" Warning."); AddSuccessMessage(" Warning."); } return(View(model)); }
public ActionResult DummiesAll(DummiesAllViewModel model, string submitType) { if (ModelState.IsValid) { // Execute search only when that action is selected if (String.Compare(submitType, "Search", StringComparison.OrdinalIgnoreCase) == 0) { // Get page metadata from view model var metadata = ExampleMapper.MapToDummiesAllPageMetadata(model);// MappingEngine.Map<DummiesAllPageMetadata>(model); // Use page metadata to retrieve data via service var domainModel = DummyService.FindAll(metadata.StartsWith); // Populate grid property with data and page metadata // Note that in the mapping, both the source and destination types are specified, // and a new Pageable instance (with page metadata) is created for use as the destination object (so page metadata is kept) model.Dummies = ExampleMapper.ToPageableDummyViewModel(domainModel, new Pageable <DummyViewModel>(metadata));// MappingEngine.Map<IEnumerable<DummyModel>, IPageable<DummyViewModel>>(domainModel, new Pageable<DummyViewModel>(metadata)); } else { // Get the selected item var selected = model.Dummies.FirstOrDefault(m => m.DummyID == model.SelectedKey); if (selected != null) { // Display its information model.Content = new ContentViewModel() .AddTitle(selected.Name) .AddParagraph(selected.Description); } } } return(View(model)); }
public static void Map(DummiesAllViewModel source, DummiesAllPageMetadata target) { target.StartsWith = source.StartsWith; }