public ActionResult ProductList() { List <ViewProductList> productList = new List <ViewProductList>(); foreach (Product item in productRepo.GetAll()) { Seller seller = sellerRepo.Get(item.SellerId); ViewProductList listItem = new ViewProductList(); listItem.Id = item.ProductId; listItem.Name = item.Name; listItem.Price = item.Price; listItem.Catagory = catagoryRepo.Get(item.CatagoryId).Name; listItem.SellerName = seller.FirstName; listItem.ShopName = sellerAddressRepo.Get(seller.AddressId).ShopName; productList.Add(listItem); } return(View(productList)); }
public ActionResult Index() { List <ViewProductList> myProducts = new List <ViewProductList>(); foreach (Product item in productRepo.GetAll()) { if (item.SellerId == (int)Session["SID"]) { ViewProductList product = new ViewProductList(); product.Id = item.ProductId; product.Name = item.Name; product.Catagory = catagoryRepo.Get(item.CatagoryId).Name; product.Price = item.Price; myProducts.Add(product); } } return(View(myProducts)); }