Advertisement
Guest User

Untitled

a guest
Sep 15th, 2017
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.65 KB | None | 0 0
  1. public ActionResult Index(string searchTargetContact = null, int page = 1)
  2. {
  3. var model =
  4. from r in db.Outreach
  5. orderby r.TargetContact descending
  6. where (r.TargetContact.StartsWith(searchTargetContact) || searchTargetContact == null)
  7. select new Models.OutreachSetListViewModel
  8. {
  9. TargetContact = r.TargetContact,
  10. NextOutreachStep = r.NextOutreachStep,
  11. GoalOfOutreach = r.GoalOfOutreach,
  12. };
  13. model.ToPagedList(page, 10);
  14.  
  15. return View(model);
  16.  
  17. namespace WebApplication11.Models
  18. {
  19. public class OutreachSetListViewModel
  20. {
  21. public string NextOutreachStep { get; set; }
  22. public string TargetContact { get; set; }
  23. public string GoalOfOutreach { get; set; }
  24. }
  25. }
  26.  
  27. @model IPagedList<OutreachSetListViewModel>
  28. <table class="table" id="networkingList">
  29. <tr>
  30.  
  31. <th>@Html.DisplayNameFor(model => model.TargetContact)</th>
  32. <th>@Html.DisplayNameFor(model => model.NextOutreachStep)</th>
  33. <th>@Html.DisplayNameFor(model => model.GoalOfOutreach)</th>
  34. <th></th>
  35. </tr>
  36.  
  37. @foreach (var item in Model)
  38. {
  39. <tr>
  40. <td>@Html.DisplayFor(modelItem => item.TargetContact)</td>
  41. <td>@Html.DisplayFor(modelItem => item.NextOutreachStep)</td>
  42. <td>@Html.DisplayFor(modelItem => item.GoalOfOutreach)</td>
  43. </tr>
  44. }
  45.  
  46. @if(Model.Any())
  47. {
  48. <tr>
  49.  
  50. <th>@Html.DisplayNameFor(model => model[0].TargetContact)</th>
  51. <th>@Html.DisplayNameFor(model => model[0].NextOutreachStep)</th>
  52. <th>@Html.DisplayNameFor(model => model[0].GoalOfOutreach)</th>
  53. <th></th>
  54. </tr>
  55. }
  56.  
  57. var vm = model.ToPagedList(page, 10);
  58. return View(vm);
  59.  
  60. public static string DisplayNameFor<TModelItem, TResult>(this IHtmlHelper<IEnumerable<TModelItem>> htmlHelper, Expression<Func<TModelItem, TResult>> expression)
  61. {
  62. if (htmlHelper == null)
  63. throw new ArgumentNullException(nameof(htmlHelper));
  64. if (expression == null)
  65. throw new ArgumentNullException(nameof(expression));
  66. return htmlHelper.DisplayNameForInnerType(expression);
  67. }
  68.  
  69. public static string DisplayNameFor<TModelItem, TResult>(this IHtmlHelper<IPagedList<TModelItem>> htmlHelper, Expression<Func<TModelItem, TResult>> expression)
  70. {
  71. if (htmlHelper == null)
  72. throw new ArgumentNullException(nameof(htmlHelper));
  73. if (expression == null)
  74. throw new ArgumentNullException(nameof(expression));
  75. return htmlHelper.DisplayNameForInnerType(expression);
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement