public IHttpActionResult PutRol(int id, Rol rol)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#2
0
 public IHttpActionResult Post([FromBody] Usuario value)
 {
     if (ModelState.IsValid)
     {
         db.Usuarios.Add(value);
         db.SaveChanges();
         return(Ok(value));
     }
     else
     {
         return(BadRequest());
     }
 }