Exemple #1
0
 public override bool IsValid(object value)
 {
     var val = value as string;
     if (val == null)
         return true;
     CategoryRepo cr = new CategoryRepo();
     if (cr.GetAllCategories().Any(c => c.Name.Equals(val)))
         return false;
     return true;
 }
Exemple #2
0
 //
 // GET: /Product/Create
 public ActionResult Create(int id)
 {
     CategoryRepo cr = new CategoryRepo();
     if (cr.ValidateID(id))
     {
         ProductModel p = new ProductModel();
         p.Category = id;
         return View(p);
     }
     return RedirectToAction("Index", "Category");
 }
Exemple #3
0
 //
 // GET: /Product/
 public ActionResult Index(int? id)
 {
     if (id == null)
         return null;
     CategoryRepo cr = new CategoryRepo();
     if(cr.ValidateID(id.Value))
     {
         ViewData["category"] = id;
         return View(products.GetProductsFromCategory(id.Value));
     }
     return RedirectToAction("Index", "Category");
 }