private APIResponse ValidatePromo(UpdatePromoInfo updatePromoInfo)
        {
            AddComboPromoInfo comboPrice = new AddComboPromoInfo();

            comboPrice.CountryCode = new List <string>();
            comboPrice.CountryCode.Add(updatePromoInfo.CountryCode);
            comboPrice.MainProductCode = updatePromoInfo.ProductCode;
            comboPrice.BV                = updatePromoInfo.CUV;
            comboPrice.StartDate         = updatePromoInfo.StartDate;
            comboPrice.EndDate           = updatePromoInfo.EndDate;
            comboPrice.PriceSchemeIds    = updatePromoInfo.PriceSchemeId;
            comboPrice.ComboPriceDetails = new List <ComboPriceDetails>();
            comboPrice.ComboPriceDetails.Add(new ComboPriceDetails
            {
                ProductCode      = updatePromoInfo.ProductCode,
                IRPrice          = updatePromoInfo.IRRegularPrice,
                IRPromoPrice     = updatePromoInfo.IRPromoPrice,
                RetailPrice      = updatePromoInfo.RetailRegularPrice,
                RetailPromoPrice = updatePromoInfo.RetailPromoPrice,
                PricePlanId      = updatePromoInfo.PricePlanId
            });

            APIResponse aPIResponse = this.ValidatePromoForCombo(comboPrice);

            return(aPIResponse);
        }
        public APIResponse ValidatePromoForCombo(AddComboPromoInfo comboPrice)
        {
            APIResponse aPIResponse = new APIResponse();

            try
            {
                foreach (string country in comboPrice.CountryCode)
                {
                    foreach (ComboPriceDetails comboPriceDetails in comboPrice.ComboPriceDetails)
                    {
                        string query = "[dbo].[usp_ValidatePromoProductForCombo]";
                        using (SqlConnection con = new SqlConnection(this.settings.Value.GQNet))
                        {
                            con.Open();
                            using (SqlCommand command = new SqlCommand(query, con))
                            {
                                command.CommandType = CommandType.StoredProcedure;
                                command.Parameters.AddWithValue("@MainProductCode", comboPrice.MainProductCode);
                                command.Parameters.AddWithValue("@MainProdPricePlanId", comboPrice.PricePlanId);
                                command.Parameters.AddWithValue("@ProdCode", comboPriceDetails.ProductCode);
                                command.Parameters.AddWithValue("@PricePlanID", comboPriceDetails.PricePlanId);
                                command.Parameters.AddWithValue("@IRPrice", comboPriceDetails.IRPromoPrice);
                                command.Parameters.AddWithValue("@ReIRPrice", comboPriceDetails.IRPrice);
                                command.Parameters.AddWithValue("@RetailPrice", comboPriceDetails.RetailPromoPrice);
                                command.Parameters.AddWithValue("@ReRetailPrice", comboPriceDetails.RetailPrice);
                                command.Parameters.AddWithValue("@CountryCode", country);
                                command.Parameters.AddWithValue("@BV", comboPrice.BV);
                                command.Parameters.AddWithValue("@EndDate", comboPrice.StartDate);
                                command.Parameters.AddWithValue("@StartDate", comboPrice.EndDate);
                                command.Parameters.AddWithValue("@PriceSchemeIds", comboPrice.PriceSchemeIds);

                                SqlDataReader reader = command.ExecuteReader();
                                if (reader.Read())
                                {
                                    aPIResponse.ErrorMessage = Convert.ToString(reader["Error"]);
                                    aPIResponse.IsSuccess    = string.IsNullOrEmpty(aPIResponse.ErrorMessage) ? true : false;
                                }
                                else
                                {
                                    aPIResponse.IsSuccess = true;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                aPIResponse.IsSuccess    = false;
                aPIResponse.ErrorMessage = ex.Message;
            }

            return(aPIResponse);
        }
 public APIResponse UpdateCombotPromo(AddComboPromoInfo addComboPromo)
 {
     return(iPromoLaunchRepository.UpdateCombotPromo(addComboPromo));
 }
 public APIResponse ValidatePromoForCombo(AddComboPromoInfo addComboPromoInfo)
 {
     return(iPromoLaunchRepository.ValidatePromoForCombo(addComboPromoInfo));
 }
 public APIResponse AddCombotPromo(AddComboPromoInfo updatePromoInfo)
 {
     return(iPromoLaunchRepository.AddCombotPromo(updatePromoInfo));
 }
 public ActionResult UpdateCombotPromo([FromBody] AddComboPromoInfo updateComboProd)
 {
     return(Json(iPromoLaunchService.UpdateCombotPromo(updateComboProd)));
 }
 public ActionResult AddCombo([FromBody] AddComboPromoInfo addComboProd)
 {
     return(Json(iPromoLaunchService.AddCombotPromo(addComboProd)));
 }
 public ActionResult ValidateComboPromo([FromBody] AddComboPromoInfo addComboProd)
 {
     return(Json(iPromoLaunchService.ValidatePromoForCombo(addComboProd)));
 }