예제 #1
0
        public IInsertResult InsertSingle(IInsertReq req, IInsertResult result, CommandType cmdType, string cmdText, string cmdParamPrefix, List <IDbDataParameter> InsertReqOutParamsList, bool ignoreConflict)
        {
            this.command = this.command ??
                           ObjectFactory.CreateCommandObject(SystemCoreManager.DbEngine, SystemCoreManager.DbConnctivity);
            this.genericDataMapper = this.SystemCoreManager.GenericDataMapper ?? this.SystemCoreManager.GenericDataMapper;

            if (this.SystemCoreManager.GenericDataMapper.MapCommandFromBusinessObject <IInsertReq>(req, ref this.command, cmdParamPrefix, ignoreConflict))
            {
                this.connection = this.connection ??
                                  ObjectFactory.CreateConnectionObject(SystemCoreManager.DbEngine, SystemCoreManager.DbConnctivity);
                this.connectionString = SystemCoreManager.ConnectionString;
                this.dbApi            = this.dbApi ?? this.SystemCoreManager.DbContextAPI;

                if (ObjectFactory.PrepareInsertReqOutParams(ref this.command, InsertReqOutParamsList,
                                                            this.SystemCoreManager.DbEngine, this.SystemCoreManager.DbConnctivity))
                {
                    this.dbApi.ExcecuteNonQuery(this.command, cmdText, cmdType, this.connection, this.connectionString);

                    this.SystemCoreManager.GenericDataMapper.MapBusinssObjectFromCommand(ref result, this.command, cmdParamPrefix, ignoreConflict);
                    return(result);
                }
                throw new GenericFrameworkException(new GenericFrameworkError()
                {
                    ErrorType    = ErrorType.SysError,
                    ErrorCode    = ErrorCode.SysError_GenericDataMapUtilityError_MapCommandFromBusinessObject,
                    ErrorMessage = "Failed to Populate OutParams"
                });
            }
            throw new GenericFrameworkException(new GenericFrameworkError()
            {
                ErrorType    = ErrorType.SysError,
                ErrorCode    = ErrorCode.SysError_GenericDataMapUtilityError_MapCommandFromBusinessObject,
                ErrorMessage = "Failed to Populate Command from Type " + req.GetType().ToString()
            });
        }
예제 #2
0
        public IInsertResult Insert(IInsertReq req, IInsertResult result, string commandText, string cmdParamPrefix, List <IDbDataParameter> InsertReqOutParamsList, System.Data.CommandType cmdType, bool ignoreConflict)
        {
            ErrorCode errorCode = ErrorCode.Other;

            if (req.ValidateRequest(req, out errorCode))
            {
                this.insertGateway = this.insertGateway ?? this.SystemCoreManager.InsertGateway;
                return(this.insertGateway.InsertSingle(req, result, cmdType, commandText, cmdParamPrefix, InsertReqOutParamsList, ignoreConflict));
            }
            result.HasError = 1;
            //result.Message = prepare error message
            return(result);
        }
예제 #3
0
 public bool ValidateRequest(IInsertReq req, out ErrorCode errorCode)
 {
     errorCode = ErrorCode.None;
     return(true);
 }
예제 #4
0
 public IInsertResult InsertItem(IInsertReq reqModel, IInsertResult resultModel, string commandText, string cmdPrefix, CommandType cmdType, List <IDbDataParameter> outParamsList, bool ignoreConflict)
 {
     return(this.insertConnector.Insert(reqModel, resultModel, commandText, cmdPrefix, outParamsList, cmdType, ignoreConflict));
 }