public async Task <IActionResult> Post([FromQuery(Name = "prvt")] bool isPrivate)
        {
            // setup
            var pluginSpecs = (await Request.ReadAsync().ConfigureAwait(false))
                              .Split(SpecSection.Separator)
                              .Select(i => i.Trim());

            // create plugins
            var(statusCode, data) = repository.Post(Request.GetAuthentication(), pluginSpecs, isPrivate);

            // response
            if (statusCode == HttpStatusCode.Created)
            {
                var responseData = repository.Get(Request.GetAuthentication()).data.Count();
                Response.Headers[CountHeader] = $"{responseData}";
            }

            var responseBody = new
            {
                Message = "Some plugins were not created.",
                Data    = data
            };

            return(this.ContentResult(responseBody, HttpStatusCode.Created));
        }
示例#2
0
        public async Task <IActionResult> Post([FromQuery(Name = "prvt")] bool isPrivate)
        {
            // setup
            var pluginSpecs = (await Request.ReadAsync().ConfigureAwait(false)).Split(Seperator);

            // create plugins
            var(statusCode, data) = rhinoPlugin.Post(Request.GetAuthentication(), pluginSpecs, isPrivate);

            // response
            if (statusCode == HttpStatusCode.Created)
            {
                var responseData = rhinoPlugin.Get(Request.GetAuthentication()).data.Count();
                Response.Headers[CountHeader] = $"{responseData}";
                return(new ContentResult
                {
                    Content = string.Join(Seperator, responseData),
                    ContentType = MediaTypeNames.Text.Plain,
                    StatusCode = HttpStatusCode.Created.ToInt32()
                });
            }

            var responseBody = new
            {
                Message = "Some plugins were not created.",
                Data    = data
            };

            return(new ContentResult
            {
                Content = JsonConvert.SerializeObject(responseBody, jsonSettings),
                ContentType = MediaTypeNames.Application.Json,
                StatusCode = HttpStatusCode.OK.ToInt32()
            });
        }