public async Task <XResult <T> > OperationWrap <T>(Func <Task <TableResult> > func) { try { var result = await func(); if (result.HttpStatusCode != (int)HttpStatusCode.OK && result.HttpStatusCode != (int)HttpStatusCode.NoContent) { return (XResult <T> .GetBadRequest(String.Format("Table Storage not OK result: {0}", result.HttpStatusCode))); } if (result.Result == null) { return (XResult <T> .GetNotFound(String.Format("Table Storage item not found: {0}", result.HttpStatusCode))); } return(new XResult <T>((T)result.Result)); } catch (Exception ex) { _logService.TrackException(ex); return(XResult <T> .GetException("TableStorage " + ex.ToString(), ex)); } }
public async Task <XResult <IList <T> > > Query(IQueryable <T> query) { await _init(); var documents = await _queryAsync(query); if (!documents) { return(documents.Copy <IList <T> >()); } var listItems = documents.Object; if (listItems == null || listItems.Count == 0) { return(XResult <IList <T> > .GetNotFound()); } return(new XResult <IList <T> >(listItems)); }
public async Task <XResult <IList <T> > > GetListSQL(string query) { await _init(); var q = _client.CreateDocumentQuery <T>(_collection.DocumentsLink, query); var documents = await _queryAsync(q); if (!documents) { return(documents.Copy <IList <T> >()); } var listItems = documents.Object; if (listItems == null || listItems.Count == 0) { return(XResult <IList <T> > .GetNotFound()); } return(new XResult <IList <T> >(listItems)); }
public async Task <XResult <IList <T> > > GetList(params Expression <Func <T, bool> >[] queries) { if (queries.Length == 0) { return(XResult <IList <T> > .GetBadRequest("No queries passed in to GetList")); } await _init(); var q = _client.CreateDocumentQuery <T>(_collection.DocumentsLink) .Where(queries[0]); foreach (var subQuery in queries) { if (subQuery == queries[0]) { continue; } q = q.Where(subQuery); } var documents = await _queryAsync(q); if (!documents) { return(documents.Copy <IList <T> >()); } var listItems = documents.Object; if (listItems == null || listItems.Count == 0) { return(XResult <IList <T> > .GetNotFound()); } return(new XResult <IList <T> >(listItems)); }
async Task <XResult <bool> > _immediateNotFOund() { await Task.Delay(500); return(XResult <bool> .GetNotFound()); }