Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public ActionResult Index(string searchTargetContact = null, int page = 1)
- {
- var model =
- from r in db.Outreach
- orderby r.TargetContact descending
- where (r.TargetContact.StartsWith(searchTargetContact) || searchTargetContact == null)
- select new Models.OutreachSetListViewModel
- {
- TargetContact = r.TargetContact,
- NextOutreachStep = r.NextOutreachStep,
- GoalOfOutreach = r.GoalOfOutreach,
- };
- model.ToPagedList(page, 10);
- return View(model);
- namespace WebApplication11.Models
- {
- public class OutreachSetListViewModel
- {
- public string NextOutreachStep { get; set; }
- public string TargetContact { get; set; }
- public string GoalOfOutreach { get; set; }
- }
- }
- @model IPagedList<OutreachSetListViewModel>
- <table class="table" id="networkingList">
- <tr>
- <th>@Html.DisplayNameFor(model => model.TargetContact)</th>
- <th>@Html.DisplayNameFor(model => model.NextOutreachStep)</th>
- <th>@Html.DisplayNameFor(model => model.GoalOfOutreach)</th>
- <th></th>
- </tr>
- @foreach (var item in Model)
- {
- <tr>
- <td>@Html.DisplayFor(modelItem => item.TargetContact)</td>
- <td>@Html.DisplayFor(modelItem => item.NextOutreachStep)</td>
- <td>@Html.DisplayFor(modelItem => item.GoalOfOutreach)</td>
- </tr>
- }
- @if(Model.Any())
- {
- <tr>
- <th>@Html.DisplayNameFor(model => model[0].TargetContact)</th>
- <th>@Html.DisplayNameFor(model => model[0].NextOutreachStep)</th>
- <th>@Html.DisplayNameFor(model => model[0].GoalOfOutreach)</th>
- <th></th>
- </tr>
- }
- var vm = model.ToPagedList(page, 10);
- return View(vm);
- public static string DisplayNameFor<TModelItem, TResult>(this IHtmlHelper<IEnumerable<TModelItem>> htmlHelper, Expression<Func<TModelItem, TResult>> expression)
- {
- if (htmlHelper == null)
- throw new ArgumentNullException(nameof(htmlHelper));
- if (expression == null)
- throw new ArgumentNullException(nameof(expression));
- return htmlHelper.DisplayNameForInnerType(expression);
- }
- public static string DisplayNameFor<TModelItem, TResult>(this IHtmlHelper<IPagedList<TModelItem>> htmlHelper, Expression<Func<TModelItem, TResult>> expression)
- {
- if (htmlHelper == null)
- throw new ArgumentNullException(nameof(htmlHelper));
- if (expression == null)
- throw new ArgumentNullException(nameof(expression));
- return htmlHelper.DisplayNameForInnerType(expression);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement