示例#1
0
        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));
        }
        /// <summary>
        /// Ajax method for <see cref="AjaxSelectionAttribute" /> property.
        /// </summary>
        public JsonResult GetDummyID(string text, int page)
        {
            var result = DummyService.FindAll(string.Empty).ToSelectList(m => m.DummyID.ToString(), m => string.Format("{0} - {1}", m.DummyID.ToString(), m.Name));

            return(AjaxSelectionView(text, page, result));
        }
示例#3
0
 public IActionResult Index()
 {
     return(Ok(_dummyService.FindAll()));
 }