Exemplo n.º 1
0
        public IHttpActionResult PutHorari(int id, Horari horari)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 2
0
        public IHttpActionResult GetHorari(int id)
        {
            Horari horari = db.Horari.Find(id);

            if (horari == null)
            {
                return(NotFound());
            }

            return(Ok(horari));
        }
Exemplo n.º 3
0
        public IHttpActionResult PostHorari(Horari horari)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Horari.Add(horari);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = horari.id }, horari));
        }
Exemplo n.º 4
0
        public IHttpActionResult DeleteHorari(int id)
        {
            Horari horari = db.Horari.Find(id);

            if (horari == null)
            {
                return(NotFound());
            }

            db.Horari.Remove(horari);
            db.SaveChanges();

            return(Ok(horari));
        }