コード例 #1
0
ファイル: HomeController.cs プロジェクト: weihangChen/demoapp
        public ActionResult GridFilter(MyViewModel vm)
        {
            var result = new JsonResult();
            if (!Request.IsAjaxRequest())
            {
                result.Data = new { statuscode = "400", error = "Invalid Request" };
                return result;
            }

            var query = GetDummy().AsQueryable();

            //generic sort
            query = SortingService.GenericSortQuery<Person>(query, vm);
            //generic sort
            if (vm.FreeText.IsNotEmpty() && vm.FreeText.ToList().Count > 4)
            {
                query = FilterService.AppendQueryWithContains<Person>("PhoneNr", vm.FreeText.ToLower(), query, vm.AsSortingFilterModel);
            }
            //generic paging
            query = FilterService.GenericPaging(query, vm.AsSortingFilterModel);

            //return data
            vm.Persons = query.ToList();

            ModelState.Clear();
            var modalViewStr = this.GetPartialViewAsStr("_Grid", vm);
            result.Data = new { statuscode = "200", data = modalViewStr };
            return result;
        }
コード例 #2
0
ファイル: HomeController.cs プロジェクト: weihangChen/demoapp
 public ActionResult GridDisplay()
 {
     var data = GetDummy().OrderByDescending(x => x.BornDate).AsQueryable();
     var vm = new MyViewModel { SortingColumnCurrent = "BornDate" };
     vm.Persons = FilterService.GenericPaging(data, vm.AsSortingFilterModel).ToList();
     return View(vm);
 }
コード例 #3
0
ファイル: HomeController.cs プロジェクト: weihangChen/demoapp
 /// <summary>
 /// no view coupled to this method, used only to demonstrate how to unit test controller method
 /// purpose is to show the mocking of ajax method and viewengine
 /// </summary>
 /// <returns></returns>
 public ActionResult UnitTestDemo2()
 {
     var result = new JsonResult();
     var vm = new MyViewModel(WorkUnit.PersonRepository.GetAsList());
     result.Data = new { statuscode = "200", data = this.GetPartialViewAsStr("_PersonGrid", vm) };
     return result;
 }
コード例 #4
0
ファイル: HomeController.cs プロジェクト: weihangChen/demoapp
 /// <summary>
 /// no view coupled to this method, used only to demonstrate how to unit test controller method
 /// purpose is to show the mocking of dbcontext, dbset, unitofwork and repository
 /// </summary>
 /// <returns></returns>
 public ActionResult UnitTestDemo1()
 {
     var vm = new MyViewModel(WorkUnit.PersonRepository.GetAsList());
     return View(vm);
 }