Пример #1
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));
        }