Ejemplo n.º 1
0
        public IHttpActionResult Putemployee(int id, employee employee)
        {
            try
            {
                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));
            }
            catch (Exception e)
            {
                throw e;
            }
        }