Esempio n. 1
0
        // Basic

        public async Task <int> AddAsync(IdentityDocumentTypeEntity identityDocumentTypeEntity)
        {
            int indicator = -1;

            try
            {
                var dynamicParameters = new DynamicParameters(identityDocumentTypeEntity);
                dynamicParameters.Add("IdentityDocumentTypeId", DbType.Int32, direction: ParameterDirection.Output);

                using (var connection = new SqlConnection(_connectionString))
                {
                    indicator = await connection.ExecuteAsync(
                        _mainCommandText.AddIdentityDocumentType,
                        dynamicParameters,
                        commandType : CommandType.StoredProcedure
                        );

                    identityDocumentTypeEntity.IdentityDocumentTypeId = dynamicParameters.Get <int>("IdentityDocumentTypeId");
                }
            }
            catch (Exception exception)
            {
            }

            return(indicator);
        }
Esempio n. 2
0
        public async Task <IdentityDocumentTypeEntity> GetByIdAsync(int identityDocumentTypeId)
        {
            var rs = new IdentityDocumentTypeEntity();

            try
            {
                using (var connection = new SqlConnection(_connectionString))
                {
                    rs = await connection.QueryFirstOrDefaultAsync <IdentityDocumentTypeEntity>(
                        _mainCommandText.GetIdentityDocumentTypeById,
                        new { IdentityDocumentTypeId = identityDocumentTypeId },
                        commandType : CommandType.StoredProcedure
                        );
                }
            }
            catch (Exception exception)
            {
            }

            return(rs);
        }
Esempio n. 3
0
        public async Task <int> UpdateAsync(IdentityDocumentTypeEntity identityDocumentTypeEntity)
        {
            int indicator = -1;

            try
            {
                var dynamicParameters = new DynamicParameters(identityDocumentTypeEntity);

                using (var connection = new SqlConnection(_connectionString))
                {
                    indicator = await connection.ExecuteAsync(
                        _mainCommandText.UpdateIdentityDocumentType,
                        dynamicParameters,
                        commandType : CommandType.StoredProcedure
                        );
                }
            }
            catch (Exception exception)
            {
            }

            return(indicator);
        }