/// <summary> </summary> public static Boolean restorePost(posting post, int version, int revision) { posting copy = null; String dest = ""; if (copy.loads_file) { String[] fileparts = copy.static_file.Split('.'); dest = fileparts[0] + "." + version + "." + revision + "." + fileparts[0]; } try { copy = make_revision <posting>(post.baseid, version, revision); if (copy != null) { if (copy.loads_file) { file_handler.copyfile(copy.static_file, dest); } } return(true); } catch { ActiveRecordMediator <dynamic> .Delete(copy); if (!String.IsNullOrWhiteSpace(dest)) { file_handler.deletefile(dest); } return(false); } }
/// <summary> /// Registers all entities for deletion that match the supplied /// criteria condition when the unit of work is completed. /// </summary> /// <param name="where">criteria condition to select the rows to be deleted</param> public void DeleteAll(DetachedCriteria where) { foreach (T entity in ActiveRecordMediator.FindAll(ConcreteType, where)) { ActiveRecordMediator.Delete(entity); } }
/// <summary> </summary> public static Boolean clearTmps <t>() { t[] items = ActiveRecordBase <t> .FindAll(); bool result = false; foreach (dynamic item in items) { if (item.tmp == true && item.baseid > 0) { if (userService.isActive(item.editing) && item.editing == userService.getUser()) { //NOTE THIS IS NEEDING TO BE CORRECTED>> item.editing is null //For some resaon when we try to access it it's like we have one layer deep //and this item uses the :publish_base:_base model inheritence //LogService.writelog("Releasing editor from item ", item.editing.nid, item.baseid); logger.writelog("Deleting tmp item ", item.baseid); ActiveRecordMediator <dynamic> .Delete(item); result = true; } } } return(result); }
/// <summary> </summary> internal static _base remove_item_ties(_base item) { if (item.children != null && item.children.Count > 0) //setup recursion { foreach (dynamic child in item.children) // find revisions and published versions { delete_item_forever(child); } } //get rid of any meta_data meta_data[] target_item_meta_data = ActiveRecordBase <meta_data> .FindAll().Where(x => x.post == item).ToArray(); if (target_item_meta_data != null && target_item_meta_data.Count() > 0) { foreach (dynamic meta_data in target_item_meta_data) { ActiveRecordMediator <dynamic> .Delete(meta_data); } } meta_data_date[] target_item_meta_data_date = ActiveRecordBase <meta_data_date> .FindAll().Where(x => x.post == item).ToArray(); if (target_item_meta_data_date != null && target_item_meta_data.Count() > 0) { foreach (dynamic meta_data_date in target_item_meta_data_date) { ActiveRecordMediator <dynamic> .Delete(meta_data_date); } } meta_data_geo[] target_item_meta_data_geo = ActiveRecordBase <meta_data_geo> .FindAll().Where(x => x.post == item).ToArray(); if (target_item_meta_data_geo != null && target_item_meta_data_geo.Count() > 0) { foreach (dynamic meta_data_geo in target_item_meta_data_geo) { ActiveRecordMediator <dynamic> .Delete(meta_data_geo); } } //get rid of any menu_options for the item menu_option[] target_item_menu_ops = ActiveRecordBase <menu_option> .FindAll().Where(x => x.post == item).ToArray(); if (target_item_menu_ops != null && target_item_menu_ops.Count() > 0) { foreach (dynamic menu_op in target_item_menu_ops) { ActiveRecordMediator <dynamic> .Delete(menu_op); } } ActiveRecordMediator <dynamic> .SaveAndFlush(item); //maybe update? return(item); }
public void delete(int id) { users auth = ActiveRecordBase <users> .Find(id); ActiveRecordMediator <users> .Delete(auth); RedirectToReferrer(); }
public void delete_usertags(int id) { usertags tag = ActiveRecordBase <usertags> .Find(id); ActiveRecordMediator <usertags> .Delete(tag); RedirectToReferrer(); }
/// <summary> </summary> internal static void delete_item_forever(dynamic item) { if (item.owner == null || (item.owner.baseid == userService.getUser().baseid)) { item = postingService.remove_item_ties(item); ActiveRecordMediator <dynamic> .Delete(item); } }
/// <summary> </summary> public void delete_user(int id) { appuser auth = ActiveRecordBase <appuser> .Find(id); ActiveRecordMediator <appuser> .Delete(auth); RedirectToReferrer(); }
/// <summary> </summary> public void delete(int id) { taxonomy tag = ActiveRecordBase <taxonomy> .Find(id); ActiveRecordMediator <taxonomy> .Delete(tag); RedirectToReferrer(); }
public void delete(int id) { person person = ActiveRecordBase <person> .Find(id); ActiveRecordMediator <person> .Delete(person); RedirectToAction("list"); }
public void Delete(T entity) { if (entity == null) { throw new ArgumentNullException("entity"); } ActiveRecordMediator <T> .Delete(entity); }
/// <summary> </summary> public void mass_delete_taxonomy(int[] ids) { foreach (int id in ids) { taxonomy tag = ActiveRecordBase <taxonomy> .Find(id); ActiveRecordMediator <taxonomy> .Delete(tag); } RedirectToAction("taxonomy"); }
/// <summary> </summary> public void delete_taxonomy(int id) { taxonomy taxonomy = ActiveRecordBase <taxonomy> .Find(id); Flash["message"] = "A taxonomy, <strong>" + taxonomy.name + "</strong>, has been <strong>deleted</strong>."; ActiveRecordMediator <taxonomy> .Delete(taxonomy); CancelLayout(); RedirectToAction("taxonomy"); }
/// <summary> </summary> public void massDeleteTags(int[] ids) { foreach (int id in ids) { taxonomy tag = ActiveRecordBase <taxonomy> .Find(id); ActiveRecordMediator <taxonomy> .Delete(tag); } RedirectToReferrer(); }
public void massDeleteUserTags(int[] ids) { foreach (int id in ids) { usertags tag = ActiveRecordBase <usertags> .Find(id); ActiveRecordMediator <usertags> .Delete(tag); } RedirectToReferrer(); }
public void delete(int id) { advertisement advertisement = ActiveRecordBase <advertisement> .Find(id); ActiveRecordMediator <advertisement> .Delete(advertisement); RedirectToReferrer(); CancelLayout(); RedirectToAction("list"); }
/// <summary> </summary> public void delete_field(int id) { field_types place_fields = ActiveRecordBase <field_types> .Find(id); Flash["message"] = "A field for places, <strong>" + place_fields.name + "</strong>, has been <strong>deleted</strong>."; ActiveRecordMediator <field_types> .Delete(place_fields); CancelLayout(); RedirectToAction("list"); }
public void delete(int id) { comments comment = ActiveRecordBase <comments> .Find(id); /*if(comment.Place != null) * comment.Place.Comments.Remove(comment);*/ ActiveRecordMediator <comments> .Delete(comment); RedirectToAction("list"); }
/// <summary> </summary> public void merge_taxonomy(int[] ids, string newname) { CancelLayout(); CancelView(); log.Info("starting merge proccess"); if (!String.IsNullOrEmpty(Request.Params["deleteTags"])) { mass_delete_taxonomy(ids); return; } dynamic items = new List <_base>(); string name = ""; taxonomy_type oldtype = null; foreach (int id in ids) { taxonomy tax = ActiveRecordBase <taxonomy> .Find(id); oldtype = tax.taxonomy_type; name = tax.name; log.Info("found taxonomy" + name); items.AddRange(tax.get_taxonomy_items(oldtype.alias, tax.alias)); foreach (dynamic p in tax.items) { log.Info("removing taxonomy from item " + p.alias); p.taxonomies.Remove(tax); ActiveRecordMediator <_base> .Save(p); } ActiveRecordMediator <taxonomy> .Delete(tax); } taxonomy t = new taxonomy(); name = String.IsNullOrEmpty(newname) ? name : newname; t.name = name; String alias = name.Replace(' ', '_').ToLower(); t.alias = alias; t.taxonomy_type = oldtype; ActiveRecordMediator <taxonomy> .Save(t); log.Info("created taxonomy with new name"); foreach (_base p in items) { log.Info("appling taxonomy " + oldtype.alias); PropertyInfo propInfo = p.GetType().GetProperty(oldtype.alias); propInfo.SetValue(p, alias, new object[] { }); //postingService.get_taxonomy(p.innovator_company).name p.taxonomies.Add(t); log.Info("adding new taxonomy back to items"); ActiveRecordMediator <_base> .Save(p); } RedirectToAction("taxonomy"); }
public virtual void Delete() { Payer.Users.Remove(this); if (Client != null) { Client.Users.Remove(this); } AuditRecord.DeleteAuditRecords(this); PayerAuditRecord.DeleteAuditRecords(Accounting); ActiveRecordMediator.Delete(this); }
public void delete(int id) { HelperService.writelog("Deleting view ", id); map_views view = ActiveRecordBase <map_views> .Find(id); Flash["message"] = "Article, <strong>Note:" + view.name + "</strong>, has been <strong>deleted</strong>."; ActiveRecordMediator <map_views> .Delete(view); CancelLayout(); RedirectToAction("list"); }
public void delete_nav(int id) { HelperService.writelog("Deleting nav categoy", id); categories nav = ActiveRecordBase <categories> .Find(id); Flash["message"] = "A Place type, <strong>" + nav.name + "</strong>, has been <strong>deleted</strong>."; ActiveRecordMediator <categories> .Delete(nav); CancelLayout(); RedirectToAction("list"); }
/// <summary> </summary> public void delete_privilege(int id) { privilege privilege = ActiveRecordBase <privilege> .Find(id); try { logger.writelog("Deleting privilege", getView(), getAction(), privilege.baseid); ActiveRecordMediator <privilege> .Delete(privilege); } catch (Exception ex) { logger.writelog("Failed to delete privilege", getView(), getAction(), privilege.baseid); Flash["error"] = ex.Message; } RedirectToAction("list"); }
public void _delete_privilege(int id) { privileges privilege = ActiveRecordBase <privileges> .Find(id); try { ActiveRecordMediator <privileges> .Delete(privilege); } catch (Exception ex) { Flash["error"] = ex.Message; } RedirectToAction("list"); }
protected override int ExecuteDelete(IDictionary keys, IDictionary oldValues) { ActiveRecordDataSourceDeleteEventArgs args = new ActiveRecordDataSourceDeleteEventArgs(); args.ModelType = BuildManager.GetType(Source.TypeName, false, true); IClassMetadata meta = ActiveRecordMediator.GetSessionFactoryHolder().GetSessionFactory(args.ModelType).GetClassMetadata(args.ModelType); if (!meta.HasIdentifierProperty) { throw new ApplicationException("ActiveRecordDataSourceView requires a primary key for the delete method."); } args.KeyProperty = meta.IdentifierPropertyName; args.KeyValue = keys[meta.IdentifierPropertyName]; try { args.Entity = ActiveRecordMediator.FindByPrimaryKey(args.ModelType, args.KeyValue); Source.OnBeforeDelete(args); if (args.Cancel) { return(0); } ActiveRecordMediator.Delete(args.Entity); } catch (Exception e) { args.Exception = e; args.WasError = true; Source.OnDeleteError(args); if (Source.ThrowOnError && !args.DoNotThrow) { throw; } return(0); } Source.OnDelete(args); return(1); }
/// <summary> </summary> public void delete_group(int id) { user_group group = ActiveRecordBase <user_group> .Find(id); //Flash["error"] = "At the moment no one has rights to delete a group but the system."; try { Flash["message"] = "A group, <strong>" + group.name + "</strong>, has been <strong>deleted</strong>."; logger.writelog("Deleted group", getView(), getAction(), group.baseid); ActiveRecordMediator <user_group> .Delete(group); } catch (Exception ex) { Flash["message"] = ""; logger.writelog("failed to Deleted", getView(), getAction(), group.baseid); Flash["error"] = ex.Message; } RedirectToAction("list_groups"); }
public void _delete_accesslevel(int id) { user_groups level = ActiveRecordBase <user_groups> .Find(id); Flash["error"] = "At the moment no one has rights to delete a group but the system."; if (id == 999999) { try { ActiveRecordMediator <user_groups> .Delete(level); } catch (Exception ex) { Flash["error"] = ex.Message; } } RedirectToAction("list"); }
/// <summary> </summary> public static dynamic _copy_slow <t>(int id, String name) where t : new() { dynamic org; org = ActiveRecordBase <t> .TryFind(id); if (org == null) { return(org); } if (String.IsNullOrWhiteSpace(name)) { name = org.name + "_copy"; } dynamic copy = new t(); copy.name = name; ActiveRecordMediator <dynamic> .Save(copy); copy = (t)copy; int copy_id = copy.baseid; IValueInjecter injecter = new ValueInjecter(); injecter.Inject <CloneInjection>(copy, org); copy.name = name; copy.baseid = copy_id; //copy.owner.baseid = userService.getUserFull().baseid; copy.users.Clear(); copy.users.Add(userService.getUserFull()); copy.updated_date = DateTime.Now; //copy.status.id = 1; //copy = (dynamic)copy; try { ActiveRecordMediator <dynamic> .Save(copy); } catch { ActiveRecordMediator <dynamic> .Delete(copy); } return(copy); }
public override bool DeleteUser(string username, bool deleteAllRelatedData) { try { BTTUser user = GetUser(username); if (user != null) { ActiveRecordMediator <BTTUser> .Delete(user); return(true); } return(false); } catch { throw; } }
public void RemoveVote(int voterId, int postId) { var key = new VoteKey(voterId, postId); var voteOnQuestion = new TVoteOnPost { Key = key }; try { int votesDelta = -GetExistingVoteValue(key); ActiveRecordMediator <TVoteOnPost> .Delete(voteOnQuestion); UpdateVotesOnAnswer(postId, votesDelta); } catch (ObjectNotFoundException) { // swallow it, the deleted object is really not there } }