public LotsViewModel BuildPagingModel(List <BLLLot> lots, LotsRequestModel lotsRequest, string currentUserEmail) { if (lotsRequest.LotsCountOnPage == 0) { lotsRequest.LotsCountOnPage = 5; } var maxPageNumber = 1; if (lots.Count % lotsRequest.LotsCountOnPage != 0) { maxPageNumber = lots.Count / lotsRequest.LotsCountOnPage + 1; } else { maxPageNumber = lots.Count / lotsRequest.LotsCountOnPage; } var lotsAfterSkip = lots.Skip(lotsRequest.LotsCountOnPage * (lotsRequest.PageNumber - 1)).Take(lotsRequest.LotsCountOnPage); var userId = _crudUserService.GetUserByEmail(currentUserEmail).Id; var model = new LotsViewModel { Lots = lotsAfterSkip.ToList(), PageNumber = lotsRequest.PageNumber, MaxPageNumber = maxPageNumber, Tab = lotsRequest.Tab, CurrentUserId = userId }; return(model); }
public ActionResult BannedUserInfo() { var user = _crudUserService.GetUserByEmail(User.Identity.Name); var ratedLots = _crudLotService.GetAllLots() .Where(l => l.UsersLotsRates.Any(ulr => ulr.UserId == user.Id)).ToList(); var viewModel = new LotsViewModel { Lots = ratedLots, CurrentUserId = user.Id }; return View(viewModel); }
public IActionResult Lots(int?category, string title, int page = 1, bool?active = null) { int pageSize = 4; var criteria = new LotsFilterCriteria() { Page = page, Category = category, Title = title, PageSize = pageSize, Active = active, UserId = UserId }; var lots = _lotsService.GetAllLots(criteria).ToVm(); var model = new LotsViewModel() { Lots = lots, Pagination = new PageViewModel(_lotsService.GetLotsCount(criteria), page, pageSize), Filter = new FilterViewModel(GetCategories(), title, category, active) }; return(View(model)); }