Пример #1
0
 public static void AddUpdateLastPrice(LastPrice lastPrice)
 {
     if (IsLastPriceExists(lastPrice))
         UpdateLastPrice(lastPrice);
     else
         AddLastPrice(lastPrice);
 }
Пример #2
0
 private static bool IsLastPriceExists(LastPrice lastPrice)
 {
     return SQLDataAccess.ExecuteScalar<int>(
         "SELECT COUNT(*) FROM [Customers].[LastPrice] WHERE [ProductId] = @ProductId AND [CustomerId] = @CustomerId",
         CommandType.Text,
         new SqlParameter("@ProductId", lastPrice.ProductId),
         new SqlParameter("@CustomerId", lastPrice.CustomerId)) > 0;
 }
Пример #3
0
 private static void UpdateLastPrice(LastPrice lastPrice)
 {
     SQLDataAccess.ExecuteNonQuery(
         "UPDATE [Customers].[LastPrice] SET [ProductArtNo] = @ProductArtNo, [ProductPrice] = @ProductPrice, [PriceType] = @PriceType WHERE [ProductId] = @ProductId AND [CustomerId] = @CustomerId",
         CommandType.Text,
         new SqlParameter("@ProductPrice", lastPrice.ProductPrice),
         new SqlParameter("@PriceType", lastPrice.PriceType.HasValue ? lastPrice.PriceType.ToString() : (object)DBNull.Value),
         new SqlParameter("@ProductArtNo", lastPrice.ProductArtNo),
         new SqlParameter("@ProductId", lastPrice.ProductId),
         new SqlParameter("@CustomerId", lastPrice.CustomerId)
         );
 }
Пример #4
0
 private static void AddLastPrice(LastPrice lastPrice)
 {
     SQLDataAccess.ExecuteNonQuery(
         "INSERT INTO [Customers].[LastPrice] ([ProductId], [CustomerId], [ProductArtNo], [ProductPrice], [PriceType]) VALUES (@ProductId, @CustomerId, @ProductArtNo, @ProductPrice, @PriceType)",
         CommandType.Text,
         new SqlParameter("@ProductPrice", lastPrice.ProductPrice),
         new SqlParameter("@PriceType", lastPrice.PriceType.HasValue ? lastPrice.PriceType.ToString() : (object)DBNull.Value),
         new SqlParameter("@ProductArtNo", lastPrice.ProductArtNo),
         new SqlParameter("@ProductId", lastPrice.ProductId),
         new SqlParameter("@CustomerId", lastPrice.CustomerId)
         );
 }