Пример #1
0
        public ActionResult <Query> JsonPost()
        {
            var queryString = Request.QueryString.Value;

            if (queryString == "")
            {
                return(BadRequest());
            }

            var parsedQueryString = HttpUtility.ParseQueryString(queryString);

            List <QuerySpec> specsList = new List <QuerySpec>();

            for (int i = 0; i < parsedQueryString.Count; i++)
            {
                specsList.Add(new QuerySpec(parsedQueryString.GetKey(i), parsedQueryString.GetValues(i)[0]));
            }

            Query theQuery = new Query(
                Utilities.sha256_hash(queryString),
                specsList
                );

            Query savedQuery = _queryService.Create(theQuery);

            return(Ok(savedQuery.oid));
        }
Пример #2
0
        public HttpResponseMessage Create(Query data)
        {
            return(WrapInTryCatch(() =>
            {
                if (!_modelValidationService.IsValidModel(data))
                {
                    throw new ArgumentNullException();
                }

                _queryService.Create(_modelConversionService.ConvertToRepositoryModel(data));
                return new HttpResponseMessage(HttpStatusCode.Created);
            }));
        }