コード例 #1
0
        public ActionResult EditValue(string key)
        {
            SystemSetting systemSetting = _systemSettingService.GetForUpdate(key);

            if (systemSetting == null)
            {
                ErrorNotification("Không tìm thấy trang tĩnh nào thỏa mãn");
                return(RedirectToAction("Index"));
            }
            Title = "Chỉnh sửa SystemSetting";
            ViewData["ToolbarTitle"] = Title;

            SystemSettingModel model = systemSetting.ToCreateModel();

            if (model.Type != 1 && model.Type != 2)
            {
                if (model.Options != null)
                {
                    List <object> myObj   = new List <object>();
                    string[]      options = model.Options.Trim().Split('|');
                    foreach (var s in options)
                    {
                        string[] strOption = s.Trim().Split('=');
                        myObj.Add(new { Id = strOption[0], Name = strOption[1] });
                    }
                    model.ListOptions = new SelectList(myObj, "Id", "Name", model.Value);
                }
            }
            if (model.Type == 3)
            {
                string[]      arrValue = systemSetting.Value.Split(',');
                List <string> list     = new List <string>();
                for (int i = 0; i < arrValue.Length; i++)
                {
                    list.Add(arrValue[i]);
                }
                model.ListSelected = list;
            }
            return(View(model));
        }