Beispiel #1
0
 public ActionResult Edit([Bind(Include = "child_id,child_name,list_parent")] ChildrenClass child)
 {
     ViewBag.isExist = "NO";
     if (modelClass.isExist(child))
     {
         ViewBag.isExist = "Same child Name is exist already.";
     }
     else
     {
         if (ModelState.IsValid)
         {
             modelClass.Edit(child);
             return(RedirectToAction("Index"));
         }
     }
     return(View(modelClass.DetailWithParent((int)child.child_id)));
 }
Beispiel #2
0
        public ActionResult Create([Bind(Include = "child_id,child_name, f_parent_id")] ChildrenClass child)
        {
            ViewBag.isExist = "NO";
            if (modelClass.isExist(child))
            {
                //when isExist child_name
                ViewBag.isExist = "Same child Name is exist already.";
            }

            else
            {
                if (ModelState.IsValid)
                {
                    modelClass.Add(child);
                    return(RedirectToAction("Index"));
                }
            }
            parentClass p = new parentClass();

            ViewData["list_parent"] = new SelectList(p.Read(), "parent_id", "parent_name");

            return(View());
        }