예제 #1
0
        private ActionResult IndexCategorySubcategoryProba(ProductAndCategorySubcategory product, HttpPostedFileBase image)
        {
            var dir = product.SelectedCategory;
            var subcat = product.SelectedSubcategory;

            if (ModelState.IsValid)
            {
                if (image != null)
                {
                    //product.Categories.ImageMimeType = image.ContentType;
                    //product.ImageData = new byte[image.ContentLength];
                    //image.InputStream.Read(product.ImageData, 0, image.ContentLength);
                }

                // save the product
                //_repository.SaveProduct(product);
                // add a message to the viewbag
                //TempData["message"] = string.Format("{0} has been saved", product.Name);
                // return the user to the list
                return RedirectToAction("Index");
            }
            else
            {
                // there is something wrong with the data values
                return View(product);
            }
        }
예제 #2
0
 /*****************ДОПОЛНИТЕЛЬНЫЕ МЕТОДЫ************************/
 //Отладочный метод выподающих списков категория/подкатегория
 public ActionResult IndexCategorySubcategoryProba()
 {
     var categSubcat = new ProductAndCategorySubcategory();
     //Заполняем категории
     var cat = from p in _repository.Categories
               select p;
     foreach (var op in cat)
     {
         categSubcat.Categories.Add(new SelectListItem(){Text = op.CategoryName, Value = op.CategoryId.ToString()});
     }
     //Заполняем подкатегории
     //var subcat = (from p in _repository.Categories
     //             where p.CategoryId == 1
     //             select p.Subcatigories).Single();
     //foreach (var pp in subcat)
     //{
     //    categSubcat.Subcategories.Add(new SelectListItem(){Text = pp.SubcategoryName, Value = pp.SubcategoryId.ToString()});
     //}
    return View(categSubcat);
 }