/// <summary> /// Used to persist object changes to the database. In Version3.0 it's just a stub for future compatibility /// </summary> public override void Save() { SaveEventArgs e = new SaveEventArgs(); FireBeforeSave(e); if (!e.Cancel) { var db = ApplicationContext.Current.DatabaseContext.Database; using (var transaction = db.GetTransaction()) { foreach (var property in GenericProperties) { var poco = new PropertyDataDto { Id = property.Id, PropertyTypeId = property.PropertyType.Id, NodeId = Id, VersionId = property.VersionId }; if (property.Value != null) { string dbType = property.PropertyType.DataTypeDefinition.DbType; if (dbType.Equals("Integer")) { if (property.Value is bool) { int val = Convert.ToInt32(property.Value); poco.Integer = val; } else { int value = 0; if (int.TryParse(property.Value.ToString(), out value)) { poco.Integer = value; } } } else if (dbType.Equals("Date")) { DateTime date; if(DateTime.TryParse(property.Value.ToString(), out date)) poco.Date = date; } else if (dbType.Equals("Nvarchar")) { poco.VarChar = property.Value.ToString(); } else { poco.Text = property.Value.ToString(); } } bool isNew = db.IsNew(poco); if (isNew) { db.Insert(poco); } else { db.Update(poco); } } transaction.Complete(); } // re-generate xml XmlDocument xd = new XmlDocument(); XmlGenerate(xd); // generate preview for blame history? if (UmbracoSettings.EnableGlobalPreviewStorage) { // Version as new guid to ensure different versions are generated as members are not versioned currently! SavePreviewXml(generateXmlWithoutSaving(xd), Guid.NewGuid()); } FireAfterSave(e); } }
protected bool Equals(PropertyDataDto other) { return(Id == other.Id); }