private void PreparingEntity(OperateArgs <T> e) { { IOperatingEntity entity2 = e.Entity as IOperatingEntity; if (entity2 != null) { entity2.PreparingOperate(e); } } if (e.OperateType == OperateType.Delete) { IDeletableEntity entity2 = e.Entity as IDeletableEntity; if (entity2 != null && !entity2.CanBeDelete(e)) { throw new InvalidUserOperationException(entity2.ToString() + "不能删除!"); } } else if (e.OperateType == OperateType.Update) { IUpdatableEntity entity2 = e.Entity as IUpdatableEntity; if (entity2 != null && !entity2.CanBeUpdate(e)) { throw new InvalidUserOperationException(entity2.ToString() + "不能更新!"); } } else if (e.OperateType == OperateType.Save) { ISavableEntity entity2 = e.Entity as ISavableEntity; if (entity2 != null && !entity2.CanBeSave(e)) { throw new InvalidUserOperationException(entity2.ToString() + "不能添加!"); } } }
private void SetModoficationTimestamps(IUpdatableEntity entity, UpdateOperations operation) { switch (operation) { case UpdateOperations.Add: entity.CreatedDate = DateTime.Now; entity.ModifiedDate = DateTime.Now; break; case UpdateOperations.Change: entity.ModifiedDate = DateTime.Now; break; } }
public void UpdateFromSource(IUpdatableEntity sourceEntity) { var entity = sourceEntity as GeoCoordinate; if (entity == null) { return; //todo exception } OwnerId = entity.OwnerId; //OriginDbId = entity.OriginDbId; //OriginDbRecordId = entity.OriginDbRecordId; //OriginDbId = entity.OriginDbId; RecordState = entity.RecordState; }
public void UpdateFromSource(IUpdatableEntity sourceEntity) { var owner = sourceEntity as Owner; if (owner == null) { return; //todo exception } //OriginDbId = owner.OriginDbId; // OriginDbRecordId = owner.OriginDbRecordId; //OriginDbId = owner.OriginDbId; // OriginDbRecordId = owner.OriginDbRecordId; Name = owner.Name; Note = owner.Note; IsSync = owner.IsSync; DefaultLanguage = owner.DefaultLanguage; RecordState = owner.RecordState; }
protected void SetUpdatedDateTime(IUpdatableEntity entity) { entity.UpdatedDateTime = DateTime.UtcNow; }