public ActionResult Create(SystemSettingModel model) { if (ModelState.IsValid) { try { SystemSetting systemSetting = model.ToEntity(); systemSetting.SettingKey = model.SettingKey; systemSetting.Title = model.Title; systemSetting.Description = model.Description; systemSetting.Type = model.Type; systemSetting.Value = model.Value; if (model.Type == 1 || model.Type == 2) { systemSetting.Options = ""; } else { //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], text = strOption[1] }); //} //JavaScriptSerializer serializer = new JavaScriptSerializer(); //systemSetting.Options = serializer.Serialize(myObj); systemSetting.Options = model.Options; } systemSetting.IsRequired = model.IsRequired; _systemSettingService.AddSystemSetting(systemSetting); return(RedirectToAction("Index")); } catch (Exception e) { ErrorNotification(e); } } else { AddModelStateErrors(); } Title = "Thêm mới SystemSetting"; ViewData["ToolbarTitle"] = Title; var statuses = from SystemSettingcsEnum s in Enum.GetValues(typeof(SystemSettingcsEnum)) select new { ID = (int)s, Name = s.ToString() }; model.SystemSettingType = new SelectList(statuses, "Id", "Name", 1); return(View(model)); }