Beispiel #1
0
 public static async Task <QueryResponse <TModel> > QueryContent <TModel>(this ISquidexContentClient that, string app, string schema, int top = 20, int skip = 0, string orderBy = null, string search = null, string filter = null)
 {
     return(await that.QueryContent <TModel>(app, schema, new QueryRequest()
     {
         Top = top, Skip = skip, OrderBy = orderBy, Search = search, Filter = filter
     }));
 }
Beispiel #2
0
        public static async Task <TModel> UpdateContent <TModel>(this ISquidexContentClient that, string app, string schema, string id, TModel content)
        {
            var raw = await that.PatchContent(app, schema, id, content);

            var deserialized = JsonConvert.DeserializeObject <TModel>(raw);

            return(deserialized);
        }
Beispiel #3
0
        public static async Task <ItemContent <TModel> > GetContent <TModel>(this ISquidexContentClient that, string app, string schema, string id)
        {
            var raw = await that.GetContent(app, schema, id);

            var deserialized = JsonConvert.DeserializeObject <ItemContent <TModel> >(raw);

            return(deserialized);
        }
Beispiel #4
0
        public static async Task <QueryResponse <TModel> > QueryContent <TModel>(this ISquidexContentClient that, string app, string schema, QueryRequest request)
        {
            dynamic raw = await that.QueryContent(app, schema, request.Top, request.Skip, request.OrderBy, request.Search, request.Filter);

            var deserialized = JsonConvert.DeserializeObject <QueryResponse <TModel> >(raw.ToString());

            return(deserialized);
        }
Beispiel #5
0
        public static async Task AssertContentProperty(this ISquidexContentClient that, string application, string schema,
                                                       string id, Func <dynamic, bool> assert, TimeSpan?delay = null)
        {
            // because of eventual consistency
            if (delay.HasValue)
            {
                await Task.Delay(delay.Value);
            }

            var item = await that.GetContent(application, schema, id);

            var isValid = assert(item);

            isValid.Should().BeTrue();
        }
Beispiel #6
0
        public static async Task AssertContentMustNotExists(this ISquidexContentClient that, string application, string schema, string id, TimeSpan?delay = null)
        {
            // because of eventual consistency
            if (delay.HasValue)
            {
                await Task.Delay(delay.Value);
            }

            var exists = false;

            try
            {
                await that.GetContent(application, schema, id);

                exists = true;
            }
            catch
            {
                exists = false;
            }

            exists.Should().BeFalse();
        }