示例#1
0
        public ActionResult GridSorting(SortingViewModel model, string submitType)
        {
            //if (model.DummyID.HasValue)
            //    model.Content = new ContentViewModel().AddTitle(dummyID.Value.ToString()).AddText("you clicked " + dummyID.Value.ToString());

            if (ModelState.IsValid)
            {
                if ("Search".Equals(submitType, StringComparison.OrdinalIgnoreCase))
                {
                    // Get PageMetadata from view model.
                    SortingGridMetadata metadata = ExampleMapper.MapToSortingGridMetadata(model);//   MappingEngine.Map<SortingGridMetadata>(model);

                    // Use this page metadata to retrieve data via service.
                    IEnumerable <SortModel> results = DummyService.GetAllForSorting(metadata.Name);

                    // Map these results for paging.
                    // Populate Grid property with data and pageMetata.
                    // NOTE: Mapping contains both Source and Destination types. New Pageable instance is created with page Metadata for use with the destination object, to keep pageMetadata.
                    model.Results = results.ToGridSortingViewModelList(new Pageable <GridSortingViewModel>(metadata));// MappingEngine.Map<IEnumerable<SortModel>, IPageable<GridSortingViewModel>>(results, new Pageable<GridSortingViewModel>(metadata));
                }
                else
                {
                    var selectedValues = model.Results.FirstOrDefault(x => x.SortingID == model.SelectedKeys);
                    if (selectedValues != null)
                    {
                        model.SelectedContent = new ContentViewModel().AddTitle("Selected").AddParagraph(selectedValues.Address);
                    }
                }
            }
            return(View(model));
        }
示例#2
0
        public ActionResult Single(SingleViewModel model)
        {
            // Repopulate grid
            model.Claims = ExampleMapper.ToClaimViewModelList(UserService.Identity.Claims.AsEnumerable());

            if (model.SelectedKey != null)
            {
                // Reapply row selections based on matching [Key]
                model.Claims.ForEach(c => { if (model.SelectedKey == c.HashKey)
                                            {
                                                c.Selected = true;
                                            }
                                     });

                // Get selected row
                var claim = model.Claims.FirstOrDefault(c => c.HashKey == model.SelectedKey);

                if (claim != null)
                {
                    model.Selections = new ContentViewModel().AddParagraph("You selected claim type '{0}' which has a value of '{1}'.", claim.ClaimType, claim.Value);
                }
            }

            return(View(model));
        }
示例#3
0
        public ActionResult Multiple(MultipleViewModel model)
        {
            // Get selected rows
            var selected = model.Claims.Where(m => m.Selected);

            // Repopulate grid
            model.Claims = ExampleMapper.ToClaimViewModelList(UserService.Identity.Claims.AsEnumerable());

            // Reapply row selections based on matching [Key]
            model.Claims.ForEach(c => { if (selected.Any(s => s.HashKey == c.HashKey))
                                        {
                                            c.Selected = true;
                                        }
                                 });

            // Process selected items
            if (selected.Any())
            {
                model.Selections = new ContentViewModel();

                foreach (var claim in model.Claims.Where(m => m.Selected))
                {
                    model.Selections.AddParagraph("You selected claim type '{0}' which has a value of '{1}'.", claim.ClaimType, claim.Value);
                }
            }

            return(View(model));
        }
示例#4
0
        public ActionResult Multiple()
        {
            var model = new MultipleViewModel();

            // Populate
            model.Claims = ExampleMapper.ToClaimViewModelList(UserService.Identity.Claims.AsEnumerable());//MappingEngine.Map<IEnumerable<ClaimViewModel>>(UserService.Identity.Claims.AsEnumerable());

            return(View(model));
        }
示例#5
0
        public async Task <Example> AddExample(ExampleDto dto)
        {
            var example = ExampleMapper.ConvertDtoToEntity(dto);
            await _dbContext.AddAsync(example);

            await _dbContext.SaveChangesAsync();

            return(example);
        }
示例#6
0
        public ActionResult Combination()
        {
            var model = new CombinationViewModel();

            // Populate
            model.MultipleClaims = ExampleMapper.ToClaimViewModelList(UserService.Identity.Claims.AsEnumerable()); //  MappingEngine.Map<IEnumerable<ClaimViewModel>>(UserService.Identity.Claims.AsEnumerable());
            model.SingleClaims1  = ExampleMapper.ToClaimViewModelList(UserService.Identity.Claims.AsEnumerable()); //MappingEngine.Map<IEnumerable<ClaimViewModel>>(UserService.Identity.Claims.AsEnumerable());
            model.SingleClaims2  = ExampleMapper.ToClaimViewModelList(UserService.Identity.Claims.AsEnumerable()); // MappingEngine.Map<IEnumerable<ClaimViewModel>>(UserService.Identity.Claims.AsEnumerable());
            model.DisplayClaims  = ExampleMapper.ToClaimViewModelList(UserService.Identity.Claims.AsEnumerable()); // MappingEngine.Map<IEnumerable<ClaimViewModel>>(UserService.Identity.Claims.AsEnumerable());

            return(View(model));
        }
示例#7
0
        public ActionResult DummiesAllNextPage(DummiesAllPageMetadata metadata)
        {
            // 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)
            var data = ExampleMapper.ToPageableDummyViewModel(domainModel, new Pageable <DummyViewModel>(metadata)); // MappingEngine.Map<IEnumerable<DummyModel>, IPageable<DummyViewModel>>(domainModel, new Pageable<DummyViewModel>(metadata));

            // Note that we are returning PagedView instead of View
            return(PagedView(data));
        }
示例#8
0
        public ActionResult DummiesMainframeNextPage(DummiesMainframePageMetadata metadata)
        {
            // Use page metadata to retrieve data via service
            var domainModel = DummyService.Find(metadata.StartsWith, metadata.NextSequenceID);

            // Note when mainframe is paging, we need to update the page metadata that is specifically used by mainframe for paging
            //metadata = ExampleMapper.MapToDummiesMainframePageMetadata(domainModel, metadata);// MappingEngine.Map<DummiesModel, DummiesMainframePageMetadata>(domainModel, metadata);
            ExampleMapper.Map(domainModel, metadata);

            // 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)
            var data = ExampleMapper.ToPageableDummyViewModel(domainModel.Dummies, new Pageable <DummyViewModel>(metadata));// MappingEngine.Map<IEnumerable<DummyModel>, IPageable<DummyViewModel>>(domainModel.Dummies, new Pageable<DummyViewModel>(metadata));

            // Note that we are returning PagedView instead of View
            return(PagedView(data));
        }
        public ActionResult JobSeekerSearch(JobSeekerSearchExampleViewModel model)
        {
            if (model != null && model.JobseekerSearch != null)
            {
                var list = JobseekerSearchService.SearchJobSeeker(ExampleMapper.MapToJobSeekerSearchModel(model.JobseekerSearch));
                if (list != null && list.Any())
                {
                    model.JobSeekerResults = new List <JobSeekerModelList>();

                    foreach (var record in list)
                    {
                        model.JobSeekerResults.Add(ExampleMapper.MapToJobSeekerModelList(record));
                    }
                }
                else
                {
                    AddInformationMessage("No records found.");
                }
            }
            return(View(model));
        }
示例#10
0
        public ActionResult DummiesMainframe(DummiesMainframeViewModel 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.MapToDummiesMainframePageMetadata(model); // MappingEngine.Map<DummiesMainframePageMetadata>(model);

                    // Use page metadata to retrieve data via service
                    var domainModel = DummyService.Find(metadata.StartsWith, metadata.NextSequenceID);

                    // Note when mainframe is paging, we need to update the page metadata that is specifically used by mainframe for paging
                    ExampleMapper.Map(domainModel, metadata);
                    //metadata = //   MappingEngine.Map<DummiesModel, DummiesMainframePageMetadata>(domainModel, metadata);

                    // 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.Dummies, new Pageable <DummyViewModel>(metadata));//  MappingEngine.Map<IEnumerable<DummyModel>, IPageable<DummyViewModel>>(domainModel.Dummies, 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));
        }
示例#11
0
        /// <summary>
        /// Button action demonstrating inline button selection in a Grid.
        /// </summary>
        public ActionResult ButtonEdit(ButtonEditViewModel model)
        {
            if (model == null)
            {
                model         = new ButtonEditViewModel();
                model.Message = new ContentViewModel().AddTitle("You haven't selected a claim to edit.");
            }
            else
            {
                var message = new ContentViewModel().AddTitle("You selected to edit hash key {0}.", model.HashKey);

                //ClaimWithButtonsViewModel claim = MappingEngine.Map<IEnumerable<ClaimWithButtonsViewModel>>(UserService.Identity.Claims.AsEnumerable()).FirstOrDefault(m => m.HashKey == model.HashKey);
                ClaimWithButtonsViewModel claim = (ExampleMapper.ToClaimWithButtonsViewModelList(UserService.Identity.Claims.AsEnumerable())).FirstOrDefault(m => m.HashKey == model.HashKey);

                if (claim != null)
                {
                    model = ExampleMapper.ToButtonEditViewModel(claim); //MappingEngine.Map<ButtonEditViewModel>(claim);
                }

                model.Message = message;
            }

            return(View(model));
        }
示例#12
0
        public ActionResult <ExampleViewData> Get(int id)
        {
            var output = _exampleModel.GetExample(id);

            return(ExampleMapper.map(output));
        }
示例#13
0
 public AutoMapperProfile()
 {
     ExampleMapper.Map(this);
 }
示例#14
0
        public ActionResult Combination(CombinationViewModel model)
        {
            // Process selected items
            model.Selections = new ContentViewModel();

            model.Selections.AddTitle("Selections from grid allowing multiple selection.");

            // Get selected rows
            var selectedMultipleClaims = model.MultipleClaims.Where(m => m.Selected);

            // Repopulate grid
            model.MultipleClaims = ExampleMapper.ToClaimViewModelList(UserService.Identity.Claims.AsEnumerable());

            // Reapply row selections based on matching [Key]
            model.MultipleClaims.ForEach(c => { if (selectedMultipleClaims.Any(s => s.HashKey == c.HashKey))
                                                {
                                                    c.Selected = true;
                                                }
                                         });

            if (model.MultipleClaims.Any(m => m.Selected))
            {
                foreach (var claim in model.MultipleClaims.Where(m => m.Selected))
                {
                    model.Selections.AddParagraph("You selected claim type '{0}' which has a value of '{1}'.", claim.ClaimType, claim.Value);
                }
            }
            else
            {
                model.Selections.AddParagraph("None.");
            }

            model.Selections.AddTitle("Selections from first grid allowing single selection.");

            // Repopulate grid
            model.SingleClaims1 = ExampleMapper.ToClaimViewModelList(UserService.Identity.Claims.AsEnumerable());

            if (model.SelectedSingleClaims1Key != null)
            {
                // Reapply row selections based on matching [Key]
                model.SingleClaims1.ForEach(c => { if (model.SelectedSingleClaims1Key == c.HashKey)
                                                   {
                                                       c.Selected = true;
                                                   }
                                            });

                // Get selected row
                var singleClaim1 = model.SingleClaims1.SingleOrDefault(m => m.HashKey == model.SelectedSingleClaims1Key);

                if (singleClaim1 != null)
                {
                    model.Selections.AddParagraph("You selected claim type '{0}' which has a value of '{1}'.", singleClaim1.ClaimType, singleClaim1.Value);
                }
            }
            else
            {
                model.Selections.AddParagraph("None.");
            }

            model.Selections.AddTitle("Selections from second grid allowing single selection.");

            // Repopulate grid
            model.SingleClaims2 = ExampleMapper.ToClaimViewModelList(UserService.Identity.Claims.AsEnumerable());

            if (model.SelectedSingleClaims2Key != null)
            {
                // Reapply row selections based on matching [Key]
                model.SingleClaims2.ForEach(c => { if (model.SelectedSingleClaims2Key == c.HashKey)
                                                   {
                                                       c.Selected = true;
                                                   }
                                            });

                // Get selected row
                var singleClaim2 = model.SingleClaims2.SingleOrDefault(m => m.HashKey == model.SelectedSingleClaims2Key);

                if (singleClaim2 != null)
                {
                    model.Selections.AddParagraph("You selected claim type '{0}' which has a value of '{1}'.", singleClaim2.ClaimType, singleClaim2.Value);
                }
            }
            else
            {
                model.Selections.AddParagraph("None.");
            }

            return(View(model));
        }
示例#15
0
        public ActionResult <IEnumerable <ExampleViewData> > GetAll()
        {
            var output = _exampleModel.GetAllExample();

            return(output.Select(ex => ExampleMapper.map(ex)).ToList());// maps each Example in the list to exampleVeiwData
        }
示例#16
0
        public void Update(int id, [FromBody] ExampleViewData example)
        {
            var input = ExampleMapper.map(example);

            _exampleModel.UpdateExample(id, input);
        }
示例#17
0
        public void Create([FromBody] ExampleViewData example)
        {
            var input = ExampleMapper.map(example);

            _exampleModel.CreateExample(input);
        }
示例#18
0
 public IAsyncEnumerable <ExampleDto> GetAll()
 {
     return(this._dbContext.Examples.Select(example => ExampleMapper.ConvertEntityToDto(example)).AsAsyncEnumerable());
 }