示例#1
0
        // POST odata/DadoSatelite
        public IHttpActionResult Post(DadoSatelite dadosatelite)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.DadoSatelites.Add(dadosatelite);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (DadoSateliteExists(dadosatelite.idDadoSatelite))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(Created(dadosatelite));
        }
示例#2
0
        // PUT odata/DadoSatelite(5)
        public IHttpActionResult Put([FromODataUri] int key, DadoSatelite dadosatelite)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (key != dadosatelite.idDadoSatelite)
            {
                return(BadRequest());
            }

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

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

            return(Updated(dadosatelite));
        }
示例#3
0
        public IHttpActionResult Patch([FromODataUri] int key, Delta <DadoSatelite> patch)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            DadoSatelite dadosatelite = db.DadoSatelites.Find(key);

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

            patch.Patch(dadosatelite);

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

            return(Updated(dadosatelite));
        }
示例#4
0
        // DELETE odata/DadoSatelite(5)
        public IHttpActionResult Delete([FromODataUri] int key)
        {
            DadoSatelite dadosatelite = db.DadoSatelites.Find(key);

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

            db.DadoSatelites.Remove(dadosatelite);
            db.SaveChanges();

            return(StatusCode(HttpStatusCode.NoContent));
        }