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 void GetAllLotsTest_GetAllLots_AllLotsReturned() { //arrange _mockUnitOfWork.Setup(x => x.Lots.GetAll()).Returns(_lots); //act var result = _service.GetAllLots(); //assert Assert.That(result, Is.Not.Null); Assert.That(result.Count(), Is.EqualTo(_lots.Count())); }
public ActionResult <IEnumerable <LotDTO> > GetAllLots() { var lots = _lotService.GetAllLots(); return(Ok(lots)); }
public IHttpActionResult Get() { return(Ok(Mapper.Map <IEnumerable <LotDTO>, List <LotModel> >(lotService.GetAllLots()))); }