예제 #1
0
        public ActionResult Create(int productId)
        {
            ViewBag.ProductID = productId;
            int subcatId = _productService.GetById(productId).SubcategoryID;

            ViewBag.SubcategoryID = new SelectList(_subcategoryService.GetAll().Where(s => s.SubcategoryID == subcatId), "SubcategoryID", "Name");

            var curSubcatProperties = _subcatPropService.GetAll().Where(p => p.SubcategoryID == subcatId);
            var properties          = _propertyService.GetAll();
            var curProdProperties   = from Subcategory_property in curSubcatProperties
                                      join property in properties on Subcategory_property.PropertyID equals property.PropertyID
                                      select new { PropertyID = Subcategory_property.PropertyID, Name = property.Name };

            ViewBag.PropertyID = new SelectList(curProdProperties.AsEnumerable(), "PropertyID", "Name");
            return(View());
        }
 /// <summary>
 /// Index returns subcategory properties for subcategory with ID = id
 /// </summary>
 /// <param name="id">Subcategory ID</param>
 /// <returns></returns>
 // GET: SubcategoryProperty
 public ActionResult Index(int id)
 {
     ViewBag.SubcategoryId = id;
     return(View(_subcatPropService.GetAll().Where(s => s.SubcategoryID == id)));
 }