예제 #1
0
        public static async Task <IActionResult> GetAll(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "inr/")] HttpRequest req,
            ILogger log)
        {
            var res = new INRDeviceDataSource().GetAll();

            return(new OkObjectResult(res));
        }
예제 #2
0
        public static async Task <IActionResult> GetByID(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "inr/{id}/")] HttpRequest req,
            string id,
            ILogger log)
        {
            var guid = GuidHelper.GetFromString(id);

            if (guid == null)
            {
                return(new BadRequestObjectResult("Invalid GUID"));
            }
            var res = new INRDeviceDataSource().GetByID(guid.Value);

            return(res != null ? (IActionResult) new OkObjectResult(res) : (IActionResult) new NotFoundObjectResult("No INR device found with ID"));
        }
예제 #3
0
        public static async Task <IActionResult> GetMeasurementsByDeviceID(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "inr/{deviceID}/measurements/")] HttpRequest req,
            string deviceID,
            ILogger log)
        {
            var deviceIDGuid = GuidHelper.GetFromString(deviceID);

            if (deviceIDGuid == null)
            {
                return(new BadRequestObjectResult("Invalid device GUID"));
            }
            var device = new INRDeviceDataSource().GetByID(deviceIDGuid.Value);

            if (device == null)
            {
                return(new NotFoundObjectResult("Unknown INR device"));
            }

            var res = new INRMeasurementDataSource().GetFiltered(m => m.DeviceID == deviceIDGuid);

            return(new OkObjectResult(res));
        }