Пример #1
0
        /// <summary>
        /// Get save commands
        /// </summary>
        /// <returns>Return the record command</returns>
        ICommand GetSaveObjectCommand()
        {
            if (string.IsNullOrWhiteSpace(IdentityValue))
            {
                return(null);
            }
            var dataPackage = WarehouseManager.GetDataPackage <TEntity>(IdentityValue);

            if (dataPackage == null || (!ActivationOptions.ForceExecute && dataPackage.Operate != WarehouseDataOperate.Save))
            {
                return(null);
            }
            var dataAccessService = ContainerManager.Resolve <TDataAccess>();

            if (dataPackage.LifeSource == DataLifeSource.New) //new add value
            {
                return(dataAccessService.Add(dataPackage.WarehouseData));
            }
            else if (dataPackage.HasValueChanged) // update value
            {
                var data = dataPackage.WarehouseData;
                return(dataAccessService.Modify(data, dataPackage.PersistentData));
            }
            return(null);
        }
Пример #2
0
        /// <summary>
        /// get save commands
        /// </summary>
        /// <returns></returns>
        ICommand GetSaveObjectCommand()
        {
            if (IdentityValue.IsNullOrEmpty())
            {
                return(null);
            }
            var dataPackage = WarehouseManager.GetDataPackage <ET>(IdentityValue);

            if (dataPackage == null || dataPackage.Operate != WarehouseDataOperate.Save)
            {
                return(null);
            }
            var dalService = ContainerManager.Resolve <DAI>();

            if (dataPackage.LifeSource == DataLifeSource.New) //new add value
            {
                return(dalService.Add((ET)dataPackage.WarehouseData));
            }
            else if (dataPackage.HasValueChanged) // update value
            {
                var data = (ET)dataPackage.WarehouseData;
                return(dalService.Modify(data, (ET)dataPackage.PersistentData));
            }
            return(null);
        }
Пример #3
0
        /// <summary>
        /// Get remove command
        /// </summary>
        /// <returns>Return the record command</returns>
        ICommand GetRemoveObjectCommand()
        {
            if (string.IsNullOrWhiteSpace(IdentityValue))
            {
                return(null);
            }
            var dataPackage = WarehouseManager.GetDataPackage <TEntity>(IdentityValue);

            if (dataPackage == null || (!ActivationOptions.ForceExecute && (dataPackage.Operate != WarehouseDataOperate.Remove || dataPackage.IsRealRemove)))
            {
                return(null);
            }
            var dataAccessService = ContainerManager.Resolve <TDataAccess>();
            var data = dataPackage.WarehouseData;

            return(dataAccessService.Delete(data));
        }
Пример #4
0
        /// <summary>
        /// geet remove command
        /// </summary>
        /// <returns></returns>
        ICommand GetRemoveObjectCommand()
        {
            if (IdentityValue.IsNullOrEmpty())
            {
                return(null);
            }
            var dataPackage = WarehouseManager.GetDataPackage <ET>(IdentityValue);

            if (dataPackage == null || (!ActivationOption.ForceExecute && (dataPackage.Operate != WarehouseDataOperate.Remove || dataPackage.IsRealRemove)))
            {
                return(null);
            }
            var dalService = ContainerManager.Resolve <DAI>();
            var data       = dataPackage.WarehouseData;

            return(dalService.Delete(data));
        }