public ActionResult GetBids(int?id, int?page) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var user = _userService.GetUserEntity(id.Value); if (user == null) { return(new HttpStatusCodeResult(HttpStatusCode.NotFound)); } var bids = _bidService.GetAllBidsByUserId(id.Value); bool isAdminOrModerator = false; if (UserViewModel != null) { if (_customAuthentication.CheckUserInRoles(UserViewModel.ToUserEntity(), "Admin,Moderator")) { isAdminOrModerator = true; } } ViewBag.AdminOrModerator = isAdminOrModerator; int actualPage = page ?? 1; var pager = PagerViewModelCreator <BidViewModel> .GetPagerViewModel( bids.OrderByDescending(x => x.Placed).Select(x => x.ToBidViewModel()), actualPage, ItemsPerPage); ViewBag.Id = id.Value; return(PartialView(pager)); }
public ActionResult LotList(int?page, LotSearchViewModel search) { int actualPage = page ?? 1; ViewBag.IsAdminOrModerator = false; IEnumerable <LotEntity> lots; if ((UserViewModel != null)) { ViewBag.IsAdminOrModerator = _customAuthentication.CheckUserInRoles(UserViewModel.ToUserEntity(), "Admin,Moderator"); } if (string.IsNullOrEmpty(search?.SearchString)) { lots = _lotService.GetAllLots(); } else { if (search.SearchInName) { lots = _lotService.GetLotsContainingStringInName(search.SearchString); } else { lots = _lotService.GetLotsContainingStringInDescription(search.SearchString); } } var pager = PagerViewModelCreator <LotViewModel> .GetPagerViewModel(lots.Select(x => x.ToLotViewModel()), actualPage, ItemsPerPage); ViewBag.SearchString = search?.SearchString; ViewBag.SearchInName = search?.SearchInName ?? true; return(PartialView(pager)); }
public ActionResult GetLots(int?id, int?page) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var user = _userService.GetUserEntity(id.Value); if (user == null) { return(new HttpStatusCodeResult(HttpStatusCode.NotFound)); } var lots = _lotService.GetAllLotsCreatedByUserId(id.Value); int actualPage = page ?? 1; var pager = PagerViewModelCreator <LotViewModel> .GetPagerViewModel(lots.Select(x => x.ToLotViewModel()), actualPage, ItemsPerPage); ViewBag.Id = id.Value; return(PartialView(pager)); }