mirror of
https://github.com/stokebob/bnhtrade.git
synced 2026-03-19 14:37:16 +00:00
63 lines
4.0 KiB
C#
63 lines
4.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace bnhtrade.Core.Data.Database.Amazon
|
|
{
|
|
public class FeeEstimate : Connection
|
|
{
|
|
/// <summary>
|
|
/// Update the tblAmazonFeeEstimate table (a new record will be created if it does not already exist to update)
|
|
/// </summary>
|
|
/// <param name="feeEstimate">Record to be updated/inserted into database</param>
|
|
public void UpdateProductFeeEstimate(Model.Amazon.ProductFeeEstimate feeEstimate)
|
|
{
|
|
using (SqlConnection sqlConn = new SqlConnection(SqlConnectionString))
|
|
{
|
|
sqlConn.Open();
|
|
|
|
using (SqlCommand sqlCommand = new SqlCommand(@"
|
|
UPDATE tblAmazonFeeEstimate SET
|
|
ProductIdentifier=@productIdentifier, IsAmazonFulfilled=@isAmazonFulfilled, TimeOfFeeEstimation=@timeOfFeeEstimation,
|
|
TotalFeeEstimate=@totalFeeEstimate, PriceToEstimateFeeListingPrice=@priceToEstimateFeeListingPrice,
|
|
PriceToEstimateFeeShipping=@priceToEstimateFeeShipping, PriceToEstimateFeePoints=@priceToEstimateFeePoints,
|
|
ReferralFee=@referralFee, VariableClosingFee=@variableClosingFee, PerItemFee=@perItemFee, FBAFee=@fbaFee,
|
|
OtherFee_Exception=@otherFee_Exception, currencyCode=CurrencyCode
|
|
WHERE AmazonASIN=@asin
|
|
IF @@ROWCOUNT = 0
|
|
INSERT INTO tblAmazonFeeEstimate ( AmazonASIN,
|
|
ProductIdentifier, IsAmazonFulfilled, TimeOfFeeEstimation, TotalFeeEstimate, PriceToEstimateFeeListingPrice,
|
|
PriceToEstimateFeeShipping, PriceToEstimateFeePoints, ReferralFee, VariableClosingFee, PerItemFee, FBAFee,
|
|
OtherFee_Exception, CurrencyCode
|
|
) VALUES ( @asin,
|
|
@productIdentifier, @isAmazonFulfilled, @timeOfFeeEstimation, @totalFeeEstimate, @priceToEstimateFeeListingPrice,
|
|
@priceToEstimateFeeShipping, @priceToEstimateFeePoints, @referralFee, @variableClosingFee, @perItemFee, @fbaFee,
|
|
@otherFee_Exception, @currencyCode
|
|
)
|
|
", sqlConn))
|
|
{
|
|
sqlCommand.Parameters.AddWithValue("@asin", feeEstimate.Asin);
|
|
sqlCommand.Parameters.AddWithValue("@productIdentifier", feeEstimate.ProductId);
|
|
sqlCommand.Parameters.AddWithValue("@isAmazonFulfilled", feeEstimate.IsAmazonFulfilled);
|
|
sqlCommand.Parameters.AddWithValue("@timeOfFeeEstimation", feeEstimate.TimeOfFeeEstimation);
|
|
sqlCommand.Parameters.AddWithValue("@totalFeeEstimate", feeEstimate.TotalFeeEstimate);
|
|
sqlCommand.Parameters.AddWithValue("@priceToEstimateFeeListingPrice", feeEstimate.PriceToEstimateFeeListingPrice);
|
|
sqlCommand.Parameters.AddWithValue("@priceToEstimateFeeShipping", feeEstimate.PriceToEstimateFeeShipping);
|
|
sqlCommand.Parameters.AddWithValue("@priceToEstimateFeePoints", feeEstimate.PriceToEstimateFeePoints);
|
|
sqlCommand.Parameters.AddWithValue("@referralFee", feeEstimate.ReferralFee);
|
|
sqlCommand.Parameters.AddWithValue("@variableClosingFee", feeEstimate.VariableClosingFee);
|
|
sqlCommand.Parameters.AddWithValue("@perItemFee", feeEstimate.PerItemFee);
|
|
sqlCommand.Parameters.AddWithValue("@fbaFee", feeEstimate.FulfillmentFees);
|
|
sqlCommand.Parameters.AddWithValue("@otherFee_Exception", feeEstimate.OtherFee_Exception);
|
|
sqlCommand.Parameters.AddWithValue("@currencyCode", feeEstimate.CurrencyCode);
|
|
|
|
sqlCommand.ExecuteNonQuery();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|