void ITextContentProvider.ClearCategories(Models.TextContent content) { var list = content.GetRepository().GetCategoryData(); list.RemoveAll(it => it.ContentUUID.EqualsOrNullEmpty(content.UUID, StringComparison.CurrentCultureIgnoreCase)); content.GetRepository().SaveCategoryData(list); }
void ITextContentProvider.AddCategories(Models.TextContent content, params Models.Category[] categories) { var list = content.GetRepository().GetCategoryData(); foreach (var category in categories) { list.Add(category); } content.GetRepository().SaveCategoryData(list); }
public void ClearCategories(Models.TextContent content) { var bucket = content.GetRepository().GetClient(); var view = bucket.GetView(content.GetRepository().GetDefaultViewDesign(), "CategorisData_By_ContentUUID").Stale(StaleMode.False).Reduce(false); var ret = view.Where(it => it.Info["value"].ToString().Equals(content.UUID)).Select(it => it.ItemId); ret.ForEach((key, index) => { bucket.Remove(key); }); }
void ITextContentProvider.DeleteCategories(Models.TextContent content, params Models.Category[] categories) { var list = content.GetRepository().GetCategoryData(); foreach (var category in categories) { var index = list.IndexOf(category); if (index != -1) { list.RemoveAt(index); } } content.GetRepository().SaveCategoryData(list); }
public void Delete(Models.TextContent content) { var bucket = content.GetRepository().GetClient(); bucket.ExecuteRemove(content.UUID, PersistTo.One); TextContentFileHelper.DeleteFiles(content); }
public void Add(Models.TextContent content) { try { content.StoreFiles(); ((IPersistable)content).OnSaving(); var command = dbCommands.Add(content); if (command != null) { if (SQLServerTransactionUnit.Current != null) { SQLServerTransactionUnit.Current.RegisterCommand(command); SQLServerTransactionUnit.Current.RegisterPostAction(delegate() { ((IPersistable)content).OnSaved(); }); } else { SQLServerHelper.BatchExecuteNonQuery(content.GetRepository(), command); ((IPersistable)content).OnSaved(); } } } catch (Exception e) { throw e; } }
public void DeleteCategories(Models.TextContent content, params Models.Category[] categories) { var bucket = content.GetRepository().GetClient(); categories.ForEach((it, index) => { bucket.ExecuteRemove(it.GetDocumentKey(), PersistTo.One); }); }
public void Add(Models.TextContent content) { content.StoreFiles(); ((IPersistable)content).OnSaving(); var bucket = content.GetRepository().GetClient(); //bucket.Store(StoreMode.Set, "Schema." + content.UUID, content.ToJson()); bucket.ExecuteStore(StoreMode.Set, content.UUID, content.ToJson(), PersistTo.One); ((IPersistable)content).OnSaved(); }
public void DeleteCategories(Models.TextContent content, params Models.Category[] categories) { //((IPersistable)content).OnSaving(); if (categories != null && categories.Length > 0) { MongoCollection <BsonDocument> collection = content.GetRepository().GetCategoriesCollection(); var query = MongoDBQuery.Query.Or(categories.Select(it => it.ToQuery()).ToArray()); collection.Remove(query); } //((IPersistable)content).OnSaved(); }
public void ClearCategories(Models.TextContent content) { //((IPersistable)content).OnSaving(); MongoCollection <BsonDocument> collection = content.GetRepository().GetCategoriesCollection(); var query = new QueryDocument { { "ContentUUID", content.UUID } }; collection.Remove(query); //((IPersistable)content).OnSaved(); }
public void AddCategories(Models.TextContent content, params Models.Category[] categories) { //((IPersistable)content).OnSaving(); if (categories != null && categories.Length > 0) { MongoCollection <BsonDocument> collection = content.GetRepository().GetCategoriesCollection(); collection.InsertBatch(categories.Select(it => it.ToBsonDocument()).ToArray()); } //((IPersistable)content).OnSaved(); }
public void Delete(Models.TextContent content) { var database = content.GetRepository().GetDatabase(); MongoCollection <BsonDocument> collection = database.GetCollection(content.GetSchema().GetSchemaCollectionName()); var query = new QueryDocument { { "UUID", content.UUID } }; collection.Remove(query); TextContentFileHelper.DeleteFiles(content); }
public void AddCategories(Models.TextContent content, params Models.Category[] categories) { if (categories != null && categories.Length > 0) { var bucket = content.GetRepository().GetClient(); categories.ForEach((it, index) => { bucket.ExecuteStore(StoreMode.Set, it.GetDocumentKey(), it.ToJson(), PersistTo.One); }); } }
public void Add(Models.TextContent content) { try { content.StoreFiles(); ((IPersistable)content).OnSaving(); var folder = content.GetFolder().GetActualFolder(); var schema = content.GetSchema().GetActualSchema(); if (folder != null && folder.StoreInAPI) { var proxy = new BackendProxy(); var additionalData = new Dictionary <string, object>() { { "CreatedBy", AuthHelper.GetCurrentUserName() }, { "ModifiedBy", AuthHelper.GetCurrentUserName() }, { "OwnerId", AuthHelper.GetCurrentUserName() } }; //Get payload // var payload = JsonConvert.SerializeObject(content, new CustomJsonDictionaryConverter(schema.GetJsonSerializationIgnoreProperties(), additionalData)); //Send data to API // proxy.Execute("POST", schema.Name, payload); } else { var command = dbCommands.Add(content); if (command != null) { if (SQLServerTransactionUnit.Current != null) { SQLServerTransactionUnit.Current.RegisterCommand(command); SQLServerTransactionUnit.Current.RegisterPostAction(delegate() { ((IPersistable)content).OnSaved(); }); } else { SQLServerHelper.BatchExecuteNonQuery(content.GetRepository(), command); ((IPersistable)content).OnSaved(); } } } } catch (Exception e) { throw e; } }
public void Add(Models.TextContent content) { content.Remove("_id"); content.StoreFiles(); ((IPersistable)content).OnSaving(); var database = content.GetRepository().GetDatabase(); MongoCollection <BsonDocument> collection = database.GetCollection(content.GetSchema().GetSchemaCollectionName()); collection.Insert(content.ToBsonDocument()); ((IPersistable)content).OnSaved(); }
public void Delete(Models.TextContent content) { var command = dbCommands.Delete(content); if (MySQLTransactionUnit.Current != null) { MySQLTransactionUnit.Current.RegisterCommand(command); MySQLTransactionUnit.Current.RegisterPostAction(delegate() { ((IPersistable)content).OnSaved(); }); } else { MysqlHelper.BatchExecuteNonQuery(content.GetRepository(), command); } }
public void Update(Models.TextContent @new, Models.TextContent old) { //if (@new["_id"] == null && old["_id"] != null) //{ // @new["_id"] = old["_id"]; //} @new.StoreFiles(); ((IPersistable)@new).OnSaving(); var bucket = old.GetRepository().GetClient(); bucket.ExecuteStore(StoreMode.Replace, old.UUID, @new.ToJson(), PersistTo.One); ((IPersistable)@new).OnSaved(); }
public void Delete(Models.TextContent content) { var command = dbCommands.Delete(content); if (SQLCeTransactionUnit.Current != null) { SQLCeTransactionUnit.Current.RegisterCommand(command); SQLCeTransactionUnit.Current.RegisterPostAction(delegate() { TextContentFileHelper.DeleteFiles(content); }); } else { SQLCeHelper.ExecuteNonQuery(content.GetRepository().GetConnectionString(), command); TextContentFileHelper.DeleteFiles(content); } }
public void Update(Models.TextContent @new, Models.TextContent old) { if (@new["_id"] == null && old["_id"] != null) { @new["_id"] = old["_id"]; } @new.StoreFiles(); ((IPersistable)@new).OnSaving(); var database = old.GetRepository().GetDatabase(); MongoCollection <BsonDocument> collection = database.GetCollection(old.GetSchema().GetSchemaCollectionName()); var query = new QueryDocument { { "UUID", old.UUID } }; collection.Update(query, @new.ToUpdateDocument()); ((IPersistable)@new).OnSaved(); }
public void Update(Models.TextContent @new, Models.TextContent old) { @new.StoreFiles(); ((IPersistable)@new).OnSaving(); var command = dbCommands.Update(@new); if (SQLCeTransactionUnit.Current != null) { SQLCeTransactionUnit.Current.RegisterCommand(command); SQLCeTransactionUnit.Current.RegisterPostAction(delegate() { ((IPersistable)@new).OnSaved(); }); } else { SQLCeHelper.ExecuteNonQuery(@new.GetRepository().GetConnectionString(), command); ((IPersistable)@new).OnSaved(); } }
public void Update(Models.TextContent @new, Models.TextContent old) { @new.StoreFiles(); ((IPersistable)@new).OnSaving(); var folder = @new.GetFolder().GetActualFolder(); var schema = @new.GetSchema().GetActualSchema(); if (folder != null && folder.StoreInAPI) { var proxyBackend = new BackendProxy(); //Add additional data // var additionalData = new Dictionary <string, object> { { "ModifiedBy", AuthHelper.GetCurrentUserName() } }; //Get payload // var payload = JsonConvert.SerializeObject(@new, new CustomJsonDictionaryConverter(schema.GetJsonSerializationIgnoreProperties(), additionalData)); //Send data to API // proxyBackend.Execute("PUT", string.Format("{0}({1})", schema.Name, @new.Id), payload); } else { var command = dbCommands.Update(@new); if (SQLServerTransactionUnit.Current != null) { SQLServerTransactionUnit.Current.RegisterCommand(command); SQLServerTransactionUnit.Current.RegisterPostAction(delegate() { ((IPersistable)@new).OnSaved(); }); } else { SQLServerHelper.BatchExecuteNonQuery(@new.GetRepository(), command); ((IPersistable)@new).OnSaved(); } } }
public void Add(Models.TextContent content) { content.StoreFiles(); ((IPersistable)content).OnSaving(); var command = dbCommands.Add(content); if (command != null) { if (SQLCeTransactionUnit.Current != null) { SQLCeTransactionUnit.Current.RegisterCommand(command); SQLCeTransactionUnit.Current.RegisterPostAction(delegate() { ((IPersistable)content).OnSaved(); }); } else { SQLCeHelper.ExecuteNonQuery(content.GetRepository().GetConnectionString(), command); ((IPersistable)content).OnSaved(); } } }
public void DeleteCategories(Models.TextContent content, params Models.Category[] categories) { SQLServerHelper.BatchExecuteNonQuery(content.GetRepository(), categories.Select(it => dbCommands.DeleteCategory(content.GetRepository(), it)).ToArray()); }
public void DeleteCategories(Models.TextContent content, params Models.Category[] categories) { SQLCeHelper.ExecuteNonQuery(content.GetRepository().GetConnectionString(), categories.Select(it => dbCommands.DeleteCategory(content.GetRepository(), it)).ToArray()); }
public IEnumerable <Models.Category> QueryCategories(Models.TextContent content) { return(content.GetRepository().QueryCategoriesBy(content.UUID).Select(it => it.ToCategory()).Where(it => it.ContentUUID.Equals(content.UUID))); }