Monday, 1 September 2014

using object Parameter in Entity Framework

     [HttpPost]
        public ActionResult About(Employee1 onjemp)
        {
            int k=0;
            if (ModelState.IsValid)
            {
                System.Data.Objects.ObjectParameter output = new System.Data.Objects.ObjectParameter("CustomerCount", typeof(int));
               
               
                Employee emp = new Employee();
               // emp.EmpName = onjemp.EmpName;
               // objenties.Employees.AddObject(emp);

                k = objenties.insert(onjemp.EmpName, "Railway", "Babina", "Jhansi", output);
               // k = objenties.SaveChanges();
                int j =Convert.ToInt32(output.Value);
                if (j> 0)
               {
                   ViewBag.sucess = "Inserted Successfull";
                   Employee1 onjemp1 = new Employee1();
                   return View("~/Views/Home/Index.cshtml", onjemp1);
               }
               else
               {

                   ViewBag.sucess = "Some Problem";
                  
                   return View(onjemp);

               }

               
            }
            else
            {
                return View("~/Views/Home/Index.cshtml", onjemp);
            }
        }

No comments:

Post a Comment