コード例 #1
0
 public ActionResult AddEmployee(Employee model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             model.UserID    = (int)Session["UserID"];
             model.CreatedBy = (int)Session["UserID"];
             model.CreatedOn = DateTime.Now;
             if (model.EmployeeID == 0)
             {
                 dbobj.Employees.Add(model);
                 dbobj.SaveChanges();
                 ModelState.Clear();
             }
             else
             {
                 dbobj.Entry(model).State = EntityState.Modified;
                 dbobj.SaveChanges();
             }
         }
         //ViewBag.SuccessMessage = "Registration Successful.";
         return(View("Employee"));
     }
     catch
     {
         ModelState.AddModelError(" ", "Invalid Operation");
         return(View());
     }
 }
コード例 #2
0
 public ActionResult EditAddOrganisation(tbl_Organisation organisation)
 {
     try
     {
         var superID = (long)Session["SuperID"];
         organisation.SuperID            = superID;
         organisation.CreatedBy          = superID;
         organisation.CreatedOn          = DateTime.Now;
         dbobj.Entry(organisation).State = EntityState.Modified;
         dbobj.SaveChanges();
         return(View("EditOrganisation"));
     }
     catch
     {
         ModelState.AddModelError(" ", "Invalid Operation");
         return(View());
     }
 }