Exemplo n.º 1
0
        public SettingDto Edit(SettingDto item)
        {
            Setting setting = MapperHelper <Setting, SettingDto> .ConvertToModel(item);

            SettingDto settingDto = MapperHelper <Setting, SettingDto> .ConvertToDto(_repository.Edit(setting));

            return(settingDto);
        }
Exemplo n.º 2
0
        public ActionResult SaveSettingValue(int id = 0, string value = "")
        {
            var s = SettingRepository.GetSingle(id);

            s.SettingValue = value;
            SettingRepository.Edit(s);
            SettingRepository.Save();
            return(Content(value));
        }
Exemplo n.º 3
0
        public ActionResult SetSettings(List <Setting> settings, int storeId)
        {
            foreach (Setting v in settings)
            {
                try
                {
                    var item = new Setting();
                    if (v.Id == 0)
                    {
                        item.SettingKey   = v.SettingKey;
                        item.SettingValue = v.SettingValue;
                        item.CreatedDate  = DateTime.Now;
                        item.State        = true;
                        item.StoreId      = storeId;
                        item.UpdatedDate  = DateTime.Now;
                        item.Name         = "";
                        item.Description  = "";
                        item.Type         = "StoreSettings";
                        item.Ordering     = 1;
                        SettingRepository.Add(item);
                        SettingRepository.Save();
                    }
                    else
                    {
                        item = SettingRepository.GetSingle(v.Id);
                        item.SettingValue = v.SettingValue;
                        item.State        = true;
                        item.StoreId      = storeId;
                        item.UpdatedDate  = DateTime.Now;
                        item.Name         = "";
                        item.Description  = "";
                        item.Type         = "StoreSettings";
                        item.Ordering     = 1;
                        SettingRepository.Edit(item);
                        SettingRepository.Save();
                    }
                }
                catch (DbEntityValidationException ex)
                {
                    var message = GetDbEntityValidationExceptionDetail(ex);
                    Logger.Error(ex, "DbEntityValidationException:" + message, v);
                }
                catch (Exception ex)
                {
                    Logger.Error(ex, "Exception is occured while saving settings:", v);
                }
            }


            return(Json(true, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 4
0
 public ActionResult SaveStyles(int storeId = 0, String styleArray = "")
 {
     try
     {
         JObject results = JObject.Parse(styleArray);
         foreach (var result in results["styleArray"])
         {
             string id    = (string)result["Id"];
             string style = (string)result["Style"];
             var    s     = this.SettingRepository.GetSingle(id.ToInt());
             s.SettingValue = style;
             SettingRepository.Edit(s);
         }
         SettingRepository.Save();
     }
     catch (Exception exception)
     {
         Logger.Error(exception, "SaveStyles :" + storeId + " styleArray:" + styleArray + " " + exception.StackTrace, storeId, styleArray);
     }
     return(Json(true, JsonRequestBehavior.AllowGet));
 }
Exemplo n.º 5
0
        public ActionResult SaveOrEdit(Setting setting)
        {
            if (ModelState.IsValid)
            {
                setting.Type    = TYPE;
                setting.StoreId = GetStoreId(0);
                if (setting.Id == 0)
                {
                    setting.SettingKey = setting.SettingKey.ToLower();
                    SettingRepository.Add(setting);
                }
                else
                {
                    setting.SettingKey = setting.SettingKey.ToLower();
                    SettingRepository.Edit(setting);
                }


                SettingRepository.Save();
                return(RedirectToAction("Index"));
            }
            return(View(setting));
        }
Exemplo n.º 6
0
        public ActionResult SaveOrEditStoreSettings(Setting setting)
        {
            if (ModelState.IsValid)
            {
                setting.Type = "SuperSettings";
                if (setting.Id == 0)
                {
                    setting.CreatedDate = DateTime.Now;
                    setting.UpdatedDate = DateTime.Now;
                    SettingRepository.Add(setting);
                }
                else
                {
                    setting.UpdatedDate = DateTime.Now;
                    SettingRepository.Edit(setting);
                }


                SettingRepository.SaveSetting();
                return(RedirectToAction("Settings", new { storeId = setting.StoreId }));
            }
            return(View(setting));
        }