コード例 #1
0
        public IHttpActionResult PutDeviceAttributes(int id, DeviceAttributes deviceAttributes)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DeviceAttributesExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            deviceMethods.SaveToDeviseALog(deviceAttributes);

            return(Ok(deviceAttributes));
        }
コード例 #2
0
        public async Task <IHttpActionResult> PutDiagnostics(int id, Diagnostics diagnostics)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DiagnosticsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }