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

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

            return(settingDto);
        }
Ejemplo n.º 2
0
 public SettingService()
 {
     this._repository = new SettingRepository();
     if (_repository.GetCount() == 0)
     {
         _repository.Add(new Setting()
         {
             CV = "", Profile = "", ProfilePhotoPath = "", About = ""
         });
     }
 }
Ejemplo 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));
        }
Ejemplo n.º 4
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));
        }
Ejemplo n.º 5
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));
        }
Ejemplo n.º 6
0
        private int CopyStoreAndPageDesingAndSettings(int copyStoreId, string name, string domain, int newStoreId)
        {
            var store     = StoreRepository.GetStore(copyStoreId);
            var storeCopy = GeneralHelper.DataContractSerialization(store);

            storeCopy.Id                = 0;
            storeCopy.Name              = name;
            storeCopy.Domain            = domain;
            storeCopy.GoogleDriveFolder = domain;
            StoreRepository.Add(storeCopy);
            StoreRepository.Save();

            newStoreId = storeCopy.Id;


            try
            {
                var settingsStore = SettingRepository.GetStoreSettings(copyStoreId);
                foreach (var settingStore in settingsStore)
                {
                    var s = GeneralHelper.DataContractSerialization(settingStore);
                    s.Id      = 0;
                    s.StoreId = newStoreId;
                    SettingRepository.Add(s);
                }
                SettingRepository.Save();
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "CopyStore", newStoreId);
            }



            return(newStoreId);
        }