Exemplo n.º 1
0
        public IHttpActionResult Putsensor(int id, Sensor sensor)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 2
0
        public IHttpActionResult Put(int id, Location location)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

            db.Entry(location).State = EntityState.Modified;
            db.SaveChanges();

            return(StatusCode(HttpStatusCode.OK));
        }
        public IHttpActionResult Put(int id, SensorType sensorType)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

            db.Entry(sensorType).State = EntityState.Modified;
            db.SaveChanges();

            return(StatusCode(HttpStatusCode.OK));
        }