public IActionResult UpdateItemMerge(string collectionId, [FromRoute][DynamicBinder] dynamic id, [FromBody] JToken patchData)
        {
            dynamic sourceData = JsonConvert.DeserializeObject <ExpandoObject>(patchData.ToString());

            if (!((IDictionary <string, object>)sourceData).Any())
            {
                return(BadRequest());
            }

            var item = _ds.GetCollection(collectionId).Find(e => ObjectHelper.CompareFieldValueWithId(e, _dsSettings.IdField, id)).FirstOrDefault();

            if (item == null)
            {
                return(NotFound());
            }

            var action = new Func <dynamic>(() =>
            {
                _ds.GetCollection(collectionId).UpdateOne(id, sourceData);
                return(id);
            });

            var queueUrl = _jobs.StartNewJob(collectionId, "PATCH", action);

            return(new AcceptedResult($"{Request.Scheme}://{Request.Host.Value}/{queueUrl}", null));
        }
        public IActionResult GetItem(string collectionId, [FromRoute][DynamicBinder] dynamic id)
        {
            if (_ds.IsItem(collectionId))
            {
                return(BadRequest());
            }

            var result = _ds.GetCollection(collectionId).Find(e => ObjectHelper.CompareFieldValueWithId(e, _dsSettings.IdField, id)).FirstOrDefault();

            if (result == null)
            {
                return(NotFound());
            }

            return(Ok(result));
        }
        public IActionResult GetNested(string collectionId, [FromRoute][DynamicBinder] dynamic id, string path)
        {
            if (_ds.IsItem(collectionId))
            {
                return(BadRequest());
            }

            var item = _ds.GetCollection(collectionId).AsQueryable().FirstOrDefault(e => ObjectHelper.CompareFieldValueWithId(e, _dsSettings.IdField, id));

            if (item == null)
            {
                return(BadRequest());
            }

            var nested = ObjectHelper.GetNestedProperty(item, path, _dsSettings.IdField);

            if (nested == null)
            {
                return(NotFound());
            }

            return(Ok(nested));
        }
        public IActionResult UpdateItemJsonPatch(string collectionId, dynamic itemId, [FromBody] JsonPatchDocument patchDoc)
        {
            if (_ds.IsItem(collectionId))
            {
                return(BadRequest());
            }

            var item = _ds.GetCollection(collectionId).AsQueryable().FirstOrDefault(e => ObjectHelper.CompareFieldValueWithId(e, _dsSettings.IdField, itemId));

            if (item == null)
            {
                return(NotFound());
            }

            var action = new Func <dynamic>(() =>
            {
                patchDoc.ApplyTo(item);
                _ds.GetCollection(collectionId).UpdateOne(itemId, item);
                return(itemId);
            });

            var queueUrl = _jobs.StartNewJob(collectionId, "PATCH", action);

            return(new AcceptedResult($"{Request.Scheme}://{Request.Host.Value}/{queueUrl}", null));
        }