public void BuyHoldViewModelShouldConvertACollectionOfItems() { // Arrange var itemToMap = new Item { Buyer = null, BuyerId = null, CreateDateTime = new DateTime(2012, 12, 12, 1, 0, 0), Descrption = "good one", HoldLongDay = 3, HoldLongLessThanDay = new TimeSpan(0, 1, 0, 0), ImageUrl = "http://www.123.com", HoldTime = null, ItemId = 3, Name = "coffee machine" }; var items = new List <Item> { itemToMap, itemToMap, itemToMap }; // Act var viewModels = BuyHoldViewModel.MapItemsForIndexView(items); Assert.Equal(3, viewModels.Count); Assert.Equal("coffee machine", viewModels[0].Name); }
public List <BuyHoldViewModel> GetAllItems(string id) { var items = _repository.FindItemsByUserId(id); var buyHoldViewModels = BuyHoldViewModel.MapItemsForIndexView(items); return(buyHoldViewModels); }
// GET: Buy/Index/e3d42666-b875-41f6-8bf7-213d18e923fc public ActionResult Index(string id) { if (id == null) { return(HttpNotFound()); } var items = _repository.FindItemsByUserId(id); var buyHoldViewModels = BuyHoldViewModel.MapItemsForIndexView(items); ViewBag.userId = id; return(View(buyHoldViewModels)); }