コード例 #1
0
        public IHttpActionResult PutProduct(int id, Product product)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #2
0
        public IHttpActionResult PutMember(int id, Member member)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #3
0
        public IHttpActionResult PutEmployee(int id, Employee employee)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #4
0
        public IHttpActionResult PutVehicle(int id, Vehicle vehicle)
        {
            if (id != vehicle.Id)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #5
0
 //update customer
 public HttpResponseMessage Put(int id, Customer customer)
 {
     if (!ModelState.IsValid)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
     }
     if (id != customer.Id)
     {
         return(Request.CreateResponse(HttpStatusCode.BadRequest));
     }
     db.Entry(customer).State = EntityState.Modified;
     try
     {
         db.SaveChanges();
     }
     catch (DbUpdateConcurrencyException ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.NotFound, ex));
     }
     return(Request.CreateResponse(HttpStatusCode.OK));
 }
コード例 #6
0
        public ActionResult Edit(Tabla tabla)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var oTabla = db.Tabla.Find(tabla.id);
                    oTabla.nombre           = tabla.nombre;
                    oTabla.correo           = tabla.correo;
                    oTabla.fecha_nacimiento = tabla.fecha_nacimiento;

                    db.Entry(oTabla).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();

                    return(RedirectToAction("Index"));
                }
                return(View(tabla));
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }