//here now Tier public List <dynamic> SaveTierData(ProductCustomrTierRateUI ProductCustomrTierRateI) { List <dynamic> objDynamic = new List <dynamic>(); ProductCustomrTierRate productCustomrTierRate = new ProductCustomrTierRate(); ProductCustomrTierRateUI productCustomrTierI = new ProductCustomrTierRateUI(); //int orddetid = 0; string strOrderID = securityHelper.Decrypt(ProductCustomrTierRateI.StrProductId, false); if (!string.IsNullOrEmpty(ProductCustomrTierRateI.TierDetails)) { var Data = JsonConvert.DeserializeObject <List <ProductCustomrTierRateUI> >(ProductCustomrTierRateI.TierDetails); for (int i = 0; i < Data.Count; i++) { productCustomrTierI = Data[i]; if (productCustomrTierI.PCTRId != 0) { productCustomrTierRate.PCTRId = productCustomrTierI.PCTRId; } if (productCustomrTierI.Qty != 0) { productCustomrTierRate.Qty = productCustomrTierI.Qty; } if (productCustomrTierI.Price != 0) { productCustomrTierRate.Price = productCustomrTierI.Price; } if (productCustomrTierI.IsActive) { productCustomrTierRate.IsActive = productCustomrTierI.IsActive; } if (productCustomrTierI.EffectiveFrom != null) { productCustomrTierRate.EffectiveFrom = DateTime.Parse(productCustomrTierI.EffectiveFrom); } productCustomrTierRate.CustId = ProductCustomrTierRateI.CustId; productCustomrTierRate.ProductId = Convert.ToInt64(strOrderID); productCustomrTierRate.Type = ProductCustomrTierRateI.Type; AddUpdateProductCustomerTierRate(productCustomrTierRate); } objDynamic.Add(productCustomrTierRate); } return(objDynamic); }
private int AddUpdateProductCustomerTierRate(ProductCustomrTierRate prodcust) { int PCTRId = 0; string insertProcedure = "[CreateProductCustomerTierRate]"; SqlCommand insertCommand = new SqlCommand(insertProcedure, connection); insertCommand.CommandType = CommandType.StoredProcedure; if (prodcust.PCTRId != 0) { insertCommand.Parameters.AddWithValue("@PCTRId", prodcust.PCTRId); } else { insertCommand.Parameters.AddWithValue("@PCTRId", 0); } if (prodcust.CustId != 0) { insertCommand.Parameters.AddWithValue("@CustId", prodcust.CustId); } else { insertCommand.Parameters.AddWithValue("@CustId", 0); } if (prodcust.ProductId != 0) { insertCommand.Parameters.AddWithValue("@ProductId", prodcust.ProductId); } else { insertCommand.Parameters.AddWithValue("@ProductId", 0); } if (prodcust.Serial != 0) { insertCommand.Parameters.AddWithValue("@Serial", prodcust.Serial); } else { insertCommand.Parameters.AddWithValue("@Serial", 0); } if (prodcust.Qty != 0) { insertCommand.Parameters.AddWithValue("@Qty", prodcust.Qty); } else { insertCommand.Parameters.AddWithValue("@Qty", 0); } if (prodcust.UserId != 0) { insertCommand.Parameters.AddWithValue("@UserId", prodcust.UserId); } else { insertCommand.Parameters.AddWithValue("@UserId", 0); } if (prodcust.Price != 0) { insertCommand.Parameters.AddWithValue("@Price", prodcust.Price); } else { insertCommand.Parameters.AddWithValue("@Price", 0); } if (prodcust.IsActive) { insertCommand.Parameters.AddWithValue("@IsActive", prodcust.IsActive); } else { insertCommand.Parameters.AddWithValue("@IsActive", 0); } if (prodcust.EffectiveFrom != null) { insertCommand.Parameters.AddWithValue("@EffectiveFrom", prodcust.EffectiveFrom); } else { insertCommand.Parameters.AddWithValue("@EffectiveFrom", DBNull.Value); } if (!string.IsNullOrEmpty(prodcust.EffectiveUpto)) { insertCommand.Parameters.AddWithValue("@EffectiveUpto", prodcust.EffectiveUpto); } else { insertCommand.Parameters.AddWithValue("@EffectiveUpto", DBNull.Value); } if (prodcust.Type != 0) { insertCommand.Parameters.AddWithValue("@Type", prodcust.Type); } else { insertCommand.Parameters.AddWithValue("@Type", 0); } insertCommand.Parameters.Add("@PCTRIdOut", System.Data.SqlDbType.Int); insertCommand.Parameters["@PCTRIdOut"].Direction = ParameterDirection.Output; insertCommand.Parameters.Add("@ReturnValue", System.Data.SqlDbType.Int); insertCommand.Parameters["@ReturnValue"].Direction = ParameterDirection.Output; try { int count = 0; connection.Open(); insertCommand.ExecuteNonQuery(); if (insertCommand.Parameters["@ReturnValue"].Value != DBNull.Value) { count = System.Convert.ToInt32(insertCommand.Parameters["@ReturnValue"].Value); } if (count != 0) { if (insertCommand.Parameters["@PCTRIdOut"].Value != DBNull.Value) { PCTRId = System.Convert.ToInt32(insertCommand.Parameters["@PCTRIdOut"].Value); } } return(PCTRId); } catch (Exception ex) { log.logErrorMessage(""); log.logErrorMessage(ex.StackTrace); return(PCTRId); } finally { connection.Close(); } }