Advertisement
Guest User

Untitled

a guest
Apr 25th, 2017
562
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.17 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Threading.Tasks;
  5. using Microsoft.AspNetCore.Mvc;
  6.  
  7. using KendoGridBinderEx.ModelBinder.AspNetCore;
  8. using KendoGridBinderEx;
  9. using KendoGridBinderEx.AutoMapperExtensions;
  10.  
  11. namespace Stecpoint.GP.Square.Web.Controllers
  12. {
  13. public class HomeController : Controller
  14. {
  15. public IActionResult Index()
  16. {
  17. return View();
  18. }
  19.  
  20. public IActionResult Error()
  21. {
  22. return View();
  23. }
  24.  
  25. class Employee
  26. {
  27. public int EmployeeId { get; set; }
  28. public string FirstName { get; set; }
  29. public string LastName { get; set; }
  30. public string Email { get; set; }
  31. }
  32.  
  33. class EmployeeVM
  34. {
  35. public int EmployeeId { get; set; }
  36. public string FirstName { get; set; }
  37. public string LastName { get; set; }
  38. public string Email { get; set; }
  39. }
  40.  
  41.  
  42. [HttpPost]
  43. public JsonResult Grid(KendoGridMvcRequest request)
  44. {
  45. var employees = new List<Employee>
  46. {
  47. new Employee { EmployeeId = 1, FirstName = "Bill", LastName = "Jones", Email = "bill@email.com" },
  48. new Employee { EmployeeId = 2, FirstName = "Rob", LastName = "Johnson", Email = "rob@email.com" },
  49. new Employee { EmployeeId = 3, FirstName = "Jane", LastName = "Smith", Email = "jane@email.com" },
  50. };
  51.  
  52. var grid = new KendoGridEx<Employee, Employee>(request, employees.AsQueryable(), null, null, null);
  53. return Json(grid);
  54.  
  55.  
  56.  
  57. //Dictionary<string, MapExpression<Employee>> mappings =
  58. ////null;
  59. ////new Dictionary<string, MapExpression<Employee>>();
  60. //new Dictionary<string, MapExpression<Employee>>
  61. //{
  62. // { "EmployeeId", new MapExpression<Employee> { Path = "EmployeeId", Expression = m => m.EmployeeId } },
  63. // { "FirstName", new MapExpression<Employee> { Path = "FirstName", Expression = m => m.FirstName } },
  64. // { "LastName", new MapExpression<Employee> { Path = "LastName", Expression = m => m.LastName } },
  65. // { "Email", new MapExpression<Employee> { Path = "Email", Expression = m => m.Email } }
  66. //};
  67.  
  68. ////return GetKendoGridAsJson<Employee, EmployeeVM>(request, employees);
  69.  
  70. ////KendoGridBinderEx
  71.  
  72. ////new KendoGridExQueryableHelper()
  73.  
  74. ////Same Type
  75. ////var conversion = q => q.Cast<TViewModel>().ToList();
  76.  
  77. //var grid = new KendoGridEx<Employee, Employee>(request, employees.AsQueryable(), null, null, null);//mappings, null);
  78. ////grid.Data
  79. //return Json(grid);
  80. }
  81.  
  82. //protected JsonResult GetKendoGridAsJson<TEntity, TViewModel>(KendoGridMvcRequest request, IQueryable<TEntity> query, IEnumerable<string> includes = null)
  83. //{
  84. // return Json(_kendoGridExQueryableHelper.ToKendoGridEx<TEntity, TViewModel>(query, request, includes));
  85. //}
  86. }
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement