Beispiel #1
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));
        }
        public async Task <IHttpActionResult> PostDeviceAttributes(DeviceAttributes deviceAttributes)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.DeviceAttributes.Add(deviceAttributes);
            await db.SaveChangesAsync();

            deviceMethods.SaveToDeviseALog(deviceAttributes);

            return(CreatedAtRoute("DefaultApi", new { id = deviceAttributes.Id }, deviceAttributes));
        }