/// <summary> /// Retrieves device by provided id /// </summary> /// <returns><see cref="DeviceDomain"/></returns> public IHttpActionResult Get(int id) { if (id <= 0) { return(Content(System.Net.HttpStatusCode.BadRequest, DeviceMessages.DeviceInvalidArgument)); } UserDomain user = (UserDomain)ActionContext.Request.Properties["UserDetails"]; var result = _deviceManipulation.GetDeviceById(id); if (result == null) { return(Content(System.Net.HttpStatusCode.NotFound, DeviceMessages.DeviceNotFound)); } if (result.TenantId != user.TenantId) { return(Content(System.Net.HttpStatusCode.Unauthorized, DeviceMessages.NotAuthorizedAction)); } return(Ok(_deviceManipulation.GetDeviceById(id))); }
public IHttpActionResult Post(List <DevicePropertyValue> devicePropertyValues) { try { if (devicePropertyValues != null && devicePropertyValues.Count > 0) { var device = _deviceManipulation.GetDeviceById(devicePropertyValues[0].DeviceId); _devicePingManipulation.Add(device.TenantId, devicePropertyValues); return(Ok()); } return(BadRequest()); } catch (Exception e) { return(InternalServerError(e)); } }