//Author: Erin Agobert //Purpose: Shows the list of products based on category name // GET: ProductTypes/Name/ProductListByCategory public async Task <IActionResult> ProductListByCategory([FromRoute] int?id) { if (id == null) { return(NotFound()); } //Create an instance of the view model being used ProductTypeListModel model = new ProductTypeListModel(); var productType = await _context.ProductType .Where(t => t.Id == id) .SingleOrDefaultAsync(); if (productType == null) { return(NotFound()); } model.Products = await(from t in _context.Product where t.ProductType.Id == id select t).ToListAsync(); return(View(model)); }
public IActionResult ListProductType() { ProductTypeListModel producttypeListModel = new ProductTypeListModel(); var producttype = _producttypeService.GetAllProductType(); foreach (var item in producttype) { producttypeListModel.ListProductTypeModel.Add(new ProductTypeViewModel { Id = item.Id, ProductTypeName = item.ProductTypeName, PunchLine = item.PunchLine, Description = item.Description, ProductTypeImage = item.ProductTypeImage, Status = item.Status, }); } return(View(producttypeListModel)); }