public ActionResult CallprotocalSetting(CallProtocalSettingsViewModel model)
        {
            try
            {

                _agrimanagrSettingsViewModelBuilder.SaveCallProtocalSettings(model);
                ValidationSummary.DomainValidationErrors("Call Protocal Settings Saved Successfully ", ModelState);
                return View(model);
            }
            catch (DomainValidationException ve)
            {
                ValidationSummary.DomainValidationErrors(ve, ModelState);
                TempData["msg"] = "Validation Errors, Unable to save settings\n" + ve.Message;
            }
            return View(model);
        }
        public void SaveCallProtocalSettings(CallProtocalSettingsViewModel sn)
        {
            var allproduct = _settingsRepository.GetByKey(SettingsKeys.CallProtocalAllProduct);
            if (allproduct == null) allproduct = new AppSettings(Guid.NewGuid());
            allproduct.Key = SettingsKeys.CallProtocalAllProduct;
            allproduct.Value = sn.AllProduct.ToString();
            _settingsRepository.Save(allproduct);

            var mandatory = _settingsRepository.GetByKey(SettingsKeys.CallProtocalMandatory);
            if (mandatory == null) mandatory = new AppSettings(Guid.NewGuid());
            mandatory.Key = SettingsKeys.CallProtocalMandatory;
            mandatory.Value = sn.Mandatory.ToString();
            _settingsRepository.Save(mandatory);


            var outofstock = _settingsRepository.GetByKey(SettingsKeys.CallProtocalOutOfStock);
            if (outofstock == null) outofstock = new AppSettings(Guid.NewGuid());
            outofstock.Key = SettingsKeys.CallProtocalOutOfStock;
            outofstock.Value = sn.OutOfStock.ToString();
            _settingsRepository.Save(outofstock);


            var previous = _settingsRepository.GetByKey(SettingsKeys.CallProtocalPrevious);
            if (previous == null) previous = new AppSettings(Guid.NewGuid());
            previous.Key = SettingsKeys.CallProtocalPrevious;
            previous.Value = sn.Previous.ToString();
            _settingsRepository.Save(previous);

            var promo = _settingsRepository.GetByKey(SettingsKeys.CallProtocalPromotion);
            if (promo == null) promo = new AppSettings(Guid.NewGuid());
            promo.Key = SettingsKeys.CallProtocalPromotion;
            promo.Value = sn.Promotion.ToString();
            _settingsRepository.Save(promo);

            var foc = _settingsRepository.GetByKey(SettingsKeys.CallProtocalFreeOfCharge);
            if (foc == null) foc = new AppSettings(Guid.NewGuid());
            foc.Key = SettingsKeys.CallProtocalFreeOfCharge;
            foc.Value = sn.FOC.ToString();
            _settingsRepository.Save(foc);

            var otherproducts = _settingsRepository.GetByKey(SettingsKeys.CallProtocalOthersProducts);
            if (otherproducts == null) otherproducts = new AppSettings(Guid.NewGuid());
            otherproducts.Key = SettingsKeys.CallProtocalOthersProducts;
            otherproducts.Value = sn.Other.ToString();
            _settingsRepository.Save(otherproducts);



        }
        public ActionResult CallprotocalSetting()
        {
            var model = new CallProtocalSettingsViewModel();


            var all = _settingsRepository.GetByKey(SettingsKeys.CallProtocalAllProduct);
            if (all != null)
            {
                bool allow = false;
                bool.TryParse(all.Value, out allow);
                model.AllProduct = allow;
            }
            var mandatory = _settingsRepository.GetByKey(SettingsKeys.CallProtocalMandatory);
            if (mandatory != null)
            {
                bool allow = false;
                bool.TryParse(mandatory.Value, out allow);
                model.Mandatory = allow;
            }
            var outofstock = _settingsRepository.GetByKey(SettingsKeys.CallProtocalOutOfStock);
            if (outofstock != null)
            {
                bool allow = false;
                bool.TryParse(outofstock.Value, out allow);
                model.OutOfStock = allow;
            }
            var previouse = _settingsRepository.GetByKey(SettingsKeys.CallProtocalPrevious);
            if (previouse != null)
            {
                bool allow = false;
                bool.TryParse(previouse.Value, out allow);
                model.Previous = allow;
            }
            var promo = _settingsRepository.GetByKey(SettingsKeys.CallProtocalPromotion);
            if (promo != null)
            {
                bool allow = false;
                bool.TryParse(promo.Value, out allow);
                model.Promotion = allow;
            }
            var other = _settingsRepository.GetByKey(SettingsKeys.CallProtocalOthersProducts);
            if (other != null)
            {
                bool allow = false;
                bool.TryParse(other.Value, out allow);
                model.Other = allow;
            }
            var foc = _settingsRepository.GetByKey(SettingsKeys.CallProtocalFreeOfCharge);
            if (foc != null)
            {
                bool allow = false;
                bool.TryParse(foc.Value, out allow);
                model.FOC = allow;
            }

            return View(model);
        }