public async Task <IHttpActionResult> PutDeviceAttributesLog(int id, DeviceAttributesLog deviceAttributesLog) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != deviceAttributesLog.Id) { return(BadRequest()); } db.Entry(deviceAttributesLog).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DeviceAttributesLogExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> GetDeviceAttributesLog(int id) { DeviceAttributesLog deviceAttributesLog = await db.DeviceAttributesLogs.FindAsync(id); if (deviceAttributesLog == null) { return(NotFound()); } return(Ok(deviceAttributesLog)); }
public async Task <IHttpActionResult> PostDeviceAttributesLog(DeviceAttributesLog deviceAttributesLog) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.DeviceAttributesLogs.Add(deviceAttributesLog); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = deviceAttributesLog.Id }, deviceAttributesLog)); }
public async Task <IHttpActionResult> DeleteDeviceAttributesLog(int id) { DeviceAttributesLog deviceAttributesLog = await db.DeviceAttributesLogs.FindAsync(id); if (deviceAttributesLog == null) { return(NotFound()); } db.DeviceAttributesLogs.Remove(deviceAttributesLog); await db.SaveChangesAsync(); return(Ok(deviceAttributesLog)); }
public IHttpActionResult SaveToDeviseALog(DeviceAttributes deviceAttributes) { DeviceAttributesLog deviceAttributesLog = new DeviceAttributesLog() { BatteryLowLevel = deviceAttributes.BatteryLowLevel, BatteryShutdownLevel = deviceAttributes.BatteryShutdownLevel, BatteryTopLevel = deviceAttributes.BatteryTopLevel, CellNumber = deviceAttributes.CellNumber, CurrentAssignedCustomerName = deviceAttributes.CurrentAssignedCustomerName, CurrentLocationLatitude = deviceAttributes.CurrentLocationLatitude, CurrentLocationLongitude = deviceAttributes.CurrentLocationLongitude, CurrentLocationTimeZone = deviceAttributes.CurrentLocationTimeZone, CustomerPhoneNumber = deviceAttributes.CustomerPhoneNumber, DeviceAttributesId = deviceAttributes.Id, EnergyMode = deviceAttributes.EnergyMode, FirmwareBranch = deviceAttributes.FirmwareBranch, FirmwareCommit = deviceAttributes.FirmwareCommit, FirmwareName = deviceAttributes.FirmwareName, GatewayPhoneNumber = deviceAttributes.GatewayPhoneNumber, HardwareVersion = deviceAttributes.HardwareVersion, IMEI = deviceAttributes.IMEI, Name = deviceAttributes.Name, NotesAboutTheDevice = deviceAttributes.NotesAboutTheDevice, NumberOfSleepPeriods = deviceAttributes.NumberOfSleepPeriods, OperationMode = deviceAttributes.OperationMode, Operator = deviceAttributes.Operator, SignalQuality = deviceAttributes.SignalQuality, SIMnumber = deviceAttributes.SIMnumber, SIMtype = deviceAttributes.SIMtype, SleepPeriod = deviceAttributes.SleepPeriod, Status = deviceAttributes.Status, TimeOfAlert = deviceAttributes.TimeOfAlert, VoltageFeedback = deviceAttributes.VoltageFeedback, WaterHighLevel = deviceAttributes.WaterHighLevel, WaterLowLevel = deviceAttributes.WaterLowLevel, SMSId = deviceAttributes.SMSId }; db.DeviceAttributesLogs.Add(deviceAttributesLog); db.SaveChanges(); return(Ok(deviceAttributesLog)); }