Exemple #1
0
 public ActionResult Edit(int id, FormCollection collection)
 {
     try
     {
         // TODO: Add update logic here
         if (ModelState.IsValid)
         {
             Sitemenu model = sitemenu.FindBy(id);
             model.name     = Request.Form["name"];
             model.position = Convert.ToInt32(Request.Form["position"]);
             model.url      = Request.Form["url"];
             model.image    = Request.Form["image"];
             model.type     = Convert.ToInt32(Request.Form["type"]);
             model.Save();
             return(RedirectToAction("Index"));
         }
         else
         {
             return(View());
         }
     }
     catch
     {
         return(View());
     }
 }
Exemple #2
0
 public ActionResult Create(FormCollection collection)
 {
     try
     {
         // TODO: Add insert logic here
         if (ModelState.IsValid)
         {
             Sitemenu new_model = new Sitemenu();
             new_model.name     = Request.Form["name"];
             new_model.position = Convert.ToInt32(Request.Form["position"]);
             new_model.url      = Request.Form["url"];
             new_model.image    = Request.Form["image"];
             new_model.type     = Convert.ToInt32(Request.Form["type"]);
             new_model.Save();
             return(RedirectToAction("Index"));
         }
         else
         {
             return(View());
         }
     }
     catch
     {
         return(View());
     }
 }