// Basic

        public async Task <int> AddAsync(PaymentEntity paymentEntity)
        {
            int indicator = -1;

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

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

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

            return(indicator);
        }
        public async Task <PaymentEntity> GetByIdAsync(int paymentId)
        {
            var rs = new PaymentEntity();

            try
            {
                using (var connection = new SqlConnection(_connectionString))
                {
                    rs = await connection.QueryFirstOrDefaultAsync <PaymentEntity>(
                        _paymentCommandText.GetPaymentById,
                        new { PaymentId = paymentId },
                        commandType : CommandType.StoredProcedure
                        );
                }
            }
            catch (Exception exception)
            {
            }

            return(rs);
        }
        public async Task <int> UpdateAsync(PaymentEntity paymentEntity)
        {
            int indicator = -1;

            try
            {
                var dynamicParameters = new DynamicParameters(paymentEntity);

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

            return(indicator);
        }
Ejemplo n.º 4
0
 public async Task <int> UpdateAsync(PaymentEntity paymentEntity)
 {
     return(await _paymentRepository.UpdateAsync(paymentEntity));
 }