public static bool Update(Model model) { var response = CosmosDBClient.Instance().ReplaceDocumentAsync( UriFactory.CreateDocumentUri(DataBaseName, Collection, model.Id), model ).Result; return(response.StatusCode == System.Net.HttpStatusCode.OK); }
public static IOrderedQueryable <T> Query <T>(bool limitOne = false, bool crossPartition = false) { if (limitOne) { return(CosmosDBClient.Instance().CreateDocumentQuery <T>(docUri, new FeedOptions() { MaxItemCount = 1, EnableCrossPartitionQuery = crossPartition })); } return(CosmosDBClient.Instance().CreateDocumentQuery <T>(docUri, new FeedOptions() { EnableCrossPartitionQuery = crossPartition })); }
public static bool Delete(string id, string userId) { try { ResourceResponse <Document> response = CosmosDBClient.Instance().DeleteDocumentAsync( UriFactory.CreateDocumentUri(DataBaseName, Collection, id), new RequestOptions { PartitionKey = new PartitionKey(userId) } ).Result; return(response.StatusCode == System.Net.HttpStatusCode.NoContent); } catch (Exception e) { Console.Write(e.Message); return(false); } }