Beispiel #1
0
        // PUT api/profesor_horario/5
        public HttpResponseMessage Putprofesor_horario(int id, profesor_horario profesor_horario)
        {
            if (ModelState.IsValid && id == profesor_horario.id)
            {
                db.Entry(profesor_horario).State = EntityState.Modified;

                try
                {
                    db.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    return(Request.CreateResponse(HttpStatusCode.NotFound));
                }

                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }
Beispiel #2
0
        // DELETE api/profesor_horario/5
        public HttpResponseMessage Deleteprofesor_horario(int id)
        {
            profesor_horario profesor_horario = db.profesor_horario.Find(id);

            if (profesor_horario == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            db.profesor_horario.Remove(profesor_horario);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, profesor_horario));
        }
Beispiel #3
0
 // POST api/profesor_horario
 public HttpResponseMessage Postprofesor_horario(profesor_horario profesor_horario)
 {
     if (ModelState.IsValid)
     {
         if (Existe(profesor_horario.id))
         {
             db.Entry(profesor_horario).State = EntityState.Modified;
             db.SaveChanges();
         }
         else
         {
             db.profesor_horario.Add(profesor_horario);
             db.SaveChanges();
         }
         HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, profesor_horario);
         response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = profesor_horario.id }));
         return(response);
     }
     else
     {
         return(Request.CreateResponse(HttpStatusCode.BadRequest));
     }
 }