Beispiel #1
0
        public async Task <HttpResponseMessage> GetByChannel([FromHeader("session-id")] string sessionId, [FromUri] string channelId)
        {
            Operation <string> opDevice = _deviceManager.GetDeviceId(sessionId);

            if (!opDevice.IsValid)
            {
                return(Request.CreateResponse(System.Net.HttpStatusCode.BadRequest, opDevice.ErrorMessages));
            }

            Operation <List <Event> > op = await _eventsManager.GetEventsAsync(opDevice.Payload, channelId);

            return(CreateResponseFromOperation(op));
        }
        public HttpResponseMessage GetByChannel([FromHeader("session-id")] string sessionId, [FromUri] string channelId)
        {
            if (string.IsNullOrEmpty(sessionId) || string.IsNullOrEmpty(channelId))
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Invalid Input"));
            }

            var events = _eventsManager.GetEventsAsync(sessionId, channelId);

            if (!events.Result.Any())
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }
            return(Request.CreateResponse(HttpStatusCode.OK, events.Result));
        }