Example #1
0
        private IActionResult DoGet(string id)
        {
            // setup
            var(statusCode, data) = string.IsNullOrEmpty(id)
                ? rhinoPlugin.Get(Request.GetAuthentication())
                : rhinoPlugin.Get(Request.GetAuthentication(), id);

            // exit conditions
            if (statusCode == HttpStatusCode.NotFound)
            {
                var message = string.IsNullOrEmpty(id) ? "No Plugins found." : $"Plugin [{id}] was not found.";
                return(NotFound(new { Message = message }));
            }

            // add count header
            Response.Headers.Add(CountHeader, $"{data.Count()}");

            // response
            return(new ContentResult
            {
                Content = string.Join(Seperator, data),
                ContentType = MediaTypeNames.Text.Plain,
                StatusCode = HttpStatusCode.OK.ToInt32()
            });
        }
        private async Task <IActionResult> DoGet(string id)
        {
            // setup
            var(statusCode, data) = string.IsNullOrEmpty(id)
                ? repository.Get(Request.GetAuthentication())
                : repository.Get(Request.GetAuthentication(), id);

            // exit conditions
            if (statusCode == HttpStatusCode.NotFound)
            {
                var message = string.IsNullOrEmpty(id) ? "No Plugins found." : $"Plugin [{id}] was not found.";
                return(await this.ErrorResultAsync(message, HttpStatusCode.NotFound).ConfigureAwait(false));
            }

            // add count header
            Response.Headers.Add(CountHeader, $"{data.Count()}");

            // response
            return(this.ContentTextResult(string.Join(SpecSection.Separator, data), HttpStatusCode.OK));
        }