public ActionResult Create(Employee employee)
        {
            if (ModelState.IsValid)
            {
                db.Employees.Add(employee);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(employee);
        }
Esempio n. 2
0
 public ActionResult Index(Employee employee)
 {
     //Server-Side Validation
       if (ModelState.IsValid)
       {
     //Model is validated
     //Save into Db
       }
       ModelState.AddModelError("Key", "Error");
       return View(employee);
 }
 public ActionResult Edit(Employee employee)
 {
     if (ModelState.IsValid)
     {
         db.Entry(employee).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(employee);
 }