예제 #1
0
        public IHttpActionResult PutEmployee(int id, Employee employee)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != employee.id)
            {
                return(BadRequest());
            }

            db.Entry(employee).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EmployeeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #2
0
 public void Put(int id, Employee e)
 {
     try
     {
         Employee GetEmployee = dbcontext.Employees.Where(s => s.id == id).FirstOrDefault();
         GetEmployee.age       = e.age;
         GetEmployee.firstName = e.firstName;
         GetEmployee.gender    = e.gender;
         GetEmployee.lastName  = e.lastName;
         dbcontext.Entry(GetEmployee).State = EntityState.Modified;
         dbcontext.SaveChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #3
0
 public ActionResult Edit([Bind(Include = "id,firstName,lastName,age,gender")] Employee employee)
 {
     if (ModelState.IsValid)
     {
         db.Entry(employee).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(employee));
 }
예제 #4
0
 public ActionResult Edit(Employee E)
 {
     if (ModelState.IsValid)
     {
         _pPECBdbModel.Entry(E).State = EntityState.Modified;
         _pPECBdbModel.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(E));
 }