Esempio n. 1
0
        public static void Map(SettingModel src, Setting dest)
        {
            if (src == null || dest == null)
            {
                return;
            }

            dest.CopyPropertyValues(src, new List <string>()
            {
                src.nameof(x => x.CreatedAt), src.nameof(x => x.EnglishName), src.nameof(x => x.ArabicName)
            });

            foreach (SettingFileModel settingFileModel in src.SettingsFilesModel)
            {
                dest.SettingsFiles.Add(new SettingsFile()
                {
                    ID = Guid.NewGuid().ToString(), SettingID = src.Id, FileShortPath = settingFileModel.FileShortPath, FileName = settingFileModel.FileName
                });
            }
        }
Esempio n. 2
0
        public ActionResult Edit(SettingModel SettingModel)
        {
            //   List<SettingFileModel> lstOldSettingFileModel = new List<SettingFileModel>();
            // string oldImagePath = null;

            if (SettingModel.Type == LookUps.SettingsTypes.String)
            {
                ModelState.Remove(SettingModel.nameof(x => x.IntValue));
                ModelState.Remove(SettingModel.nameof(x => x.imageValue));
                ModelState.Remove(SettingModel.nameof(x => x.BoolValue));
            }
            else if (SettingModel.Type == LookUps.SettingsTypes.Bool)
            {
                ModelState.Remove(SettingModel.nameof(x => x.IntValue));
                ModelState.Remove(SettingModel.nameof(x => x.Value));
                ModelState.Remove(SettingModel.nameof(x => x.imageValue));
            }
            else if (SettingModel.Type == LookUps.SettingsTypes.Int)
            {
                ModelState.Remove(SettingModel.nameof(x => x.Value));
                ModelState.Remove(SettingModel.nameof(x => x.imageValue));
                ModelState.Remove(SettingModel.nameof(x => x.BoolValue));
            }
            else if (SettingModel.Type == LookUps.SettingsTypes.image)
            {
                ModelState.Remove(SettingModel.nameof(x => x.Value));
                ModelState.Remove(SettingModel.nameof(x => x.IntValue));
                ModelState.Remove(SettingModel.nameof(x => x.BoolValue));
            }

            using (SettingBAL settingBAL = new SettingBAL(ContextInfo))
            {
                if (ModelState.IsValid)
                {
                    settingBAL.Edit(SettingModel);
                }

                if (SettingModel.HasErrorByType(LMYFrameWorkMVC.Common.LookUps.ErrorType.Critical) || SettingModel.HasSuccess(LMYFrameWorkMVC.Common.LookUps.SuccessType.Full))
                {
                    return(base.RedirectToActionWithData(new Dictionary <string, object> {
                        { "baseModel", SettingModel }
                    }, "Edit"));
                }

                settingBAL.GetSettingModel(SettingModel);
            }

            return(View(SettingModel));
        }