// PUT api/EmployeeAPI/5
        public IHttpActionResult PutEmployee(int id, Employee employee)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != employee.EmpNo)
            {
                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 IHttpActionResult Delete(int id)
        {
            var emdel = em.Newempregs.Where(x => x.Empid == id).FirstOrDefault();

            em.Entry(emdel).State = System.Data.Entity.EntityState.Deleted;
            em.SaveChanges();
            return(Ok());
        }
示例#3
0
 public ActionResult Edit([Bind(Include = "ID,First,Last,email,position")] emp emp)
 {
     if (ModelState.IsValid)
     {
         db.Entry(emp).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(emp));
 }