public ActionResult Edit(EmpModels model)
 {
     if (ModelState.IsValid)
     {
         emp.UpdateEmploye(model.Id, model);
         return(RedirectToAction("GetAllRecords"));
     }
     return(View());
 }
 public ActionResult Create(EmpModels model)
 {
     if (ModelState.IsValid)
     {
         int id = emp.AddEmploye(model);
         if (id > 0)
         {
             ModelState.Clear();
             ViewBag.Issuccess = "Data Added";
         }
     }
     return(View());
 }
Exemple #3
0
 public bool UpdateEmploye(int id, EmpModels model)
 {
     using (var context = new DXCEntities())
     {
         var empl = context.Db_approach.FirstOrDefault(x => x.Id == id);
         if (empl != null)
         {
             empl.FirstName = model.FirstName;
             empl.LastName  = model.LastName;
             empl.Email     = model.Email;
             empl.Code      = model.Code;
         }
         context.SaveChanges();
         return(true);
     }
 }
Exemple #4
0
        public int AddEmploye(EmpModels model)
        {
            using (var context = new DXCEntities())
            {
                Db_approach ee = new Db_approach()
                {
                    FirstName = model.FirstName,
                    LastName  = model.LastName,
                    Email     = model.Email,
                    Code      = model.Code
                };
                context.Db_approach.Add(ee);

                context.SaveChanges();

                return(ee.Id);
            }
        }
Exemple #5
0
        public EmpModels GetCon()
        {
            OracleConnection con = new OracleConnection(connectString);

            con.Open();
            string           sql = "select id from test";
            OracleCommand    cmd = new OracleCommand(sql, con);
            OracleDataReader dta = cmd.ExecuteReader();

            if (dta.Read())
            {
                EmpModels emp = new EmpModels()
                {
                    EmpNO = dta["id"].ToString()
                };
                return(emp);
            }
            else
            {
                return(null);
            }
        }