diff options
Diffstat (limited to 'Software/Visual_Studio/Tango.DAL.Observables/ObservableEntity.cs')
| -rw-r--r-- | Software/Visual_Studio/Tango.DAL.Observables/ObservableEntity.cs | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/Software/Visual_Studio/Tango.DAL.Observables/ObservableEntity.cs b/Software/Visual_Studio/Tango.DAL.Observables/ObservableEntity.cs index e5e49ac38..56455246f 100644 --- a/Software/Visual_Studio/Tango.DAL.Observables/ObservableEntity.cs +++ b/Software/Visual_Studio/Tango.DAL.Observables/ObservableEntity.cs @@ -70,7 +70,7 @@ namespace Tango.DAL.Observables } } } - else if (prop.PropertyType.IsClass && prop.PropertyType != typeof(String) && prop.PropertyType != typeof(DateTime)) + else if (prop.PropertyType.IsClass && prop.PropertyType != typeof(String) && prop.PropertyType != typeof(DateTime) && prop.PropertyType != typeof(byte[])) { Type propType = observable.GetType().GetProperty(name).PropertyType; @@ -138,6 +138,8 @@ namespace Tango.DAL.Observables public abstract void Delete(); public abstract Task SaveAsync(); + public abstract void SoftDelete(); + public abstract Task SoftDeleteAsync(); } public abstract class ObservableEntity<T> : ObservableEntity where T : class @@ -183,7 +185,7 @@ namespace Tango.DAL.Observables { Entity = Activator.CreateInstance<T>(); Guid = System.Guid.NewGuid().ToString(); - LastUpdated = DateTime.Now; + LastUpdated = DateTime.UtcNow; _isNew = true; } @@ -219,13 +221,30 @@ namespace Tango.DAL.Observables ObservablesEntitiesAdapter.Instance.SaveChanges(); } + public override void SoftDelete() + { + this.Deleted = true; + Save(); + } + + public override Task SoftDeleteAsync() + { + return Task.Factory.StartNew(() => + { + SoftDelete(); + }); + } + internal override void Save(List<IObservableEntity> savedEntities) { savedEntities.Add(this); + //Update last updated... + this.LastUpdated = DateTime.UtcNow; + //Match guids.. - foreach (var prop in this.GetType().GetProperties().Where(x => !x.PropertyType.IsGenericType && x.PropertyType.IsClass && x.PropertyType != typeof(String) && x.PropertyType != typeof(DateTime))) + foreach (var prop in this.GetType().GetProperties().Where(x => !x.PropertyType.IsGenericType && x.PropertyType.IsClass && x.PropertyType != typeof(String) && x.PropertyType != typeof(DateTime) && x.PropertyType != typeof(byte[]))) { IObservableEntity propObservable = prop.GetValue(this) as IObservableEntity; @@ -267,7 +286,7 @@ namespace Tango.DAL.Observables } } } - else if (prop.PropertyType.IsClass && prop.PropertyType != typeof(String) && prop.PropertyType != typeof(DateTime)) + else if (prop.PropertyType.IsClass && prop.PropertyType != typeof(String) && prop.PropertyType != typeof(DateTime) && prop.PropertyType != typeof(byte[])) { var item = (prop.GetValue(this) as ObservableEntity); if (!savedEntities.Contains(item)) |
