public JsonResult UserSetting(IList <UserSetting> data) { try { foreach (UserSetting usersetting in data) { usersetting.Username = UserName; usersetting.Statues = 1; iusersetting.Update(usersetting); } WriteLog(UserName + " 更新了自己的系统设置"); return(Json(true, JsonRequestBehavior.AllowGet)); } catch { return(Json(false, JsonRequestBehavior.AllowGet)); } }
public JsonResult Usersetting(string likerate, string recordrate, string likedrate, string commentrate) { //IList<SettingGroup> groupsettings = iusersetting.GetByUsername(UserName); try { PaginationInfo paging = new PaginationInfo(); IList <UserSetting> settings = iusersetting.Get(null, UserName, new Guid("3C309D27-C774-4E60-8706-17EA2C2B0691"), 1, 0, null, out paging); if (settings == null || settings.Count == 0) { UserSetting usersetting = new UserSetting { ID = Guid.NewGuid(), Statues = 1, Value = likedrate, Settingid = new Guid("3C309D27-C774-4E60-8706-17EA2C2B0691"), Username = UserName }; iusersetting.Create(usersetting); } else { UserSetting setting = settings[0]; setting.Value = likerate; iusersetting.Update(setting); } settings = iusersetting.Get(null, UserName, new Guid("E038EAB0-9F3D-4967-BE16-06E04633D6C8"), 1, 0, null, out paging); if (settings == null || settings.Count == 0) { UserSetting usersetting = new UserSetting { ID = Guid.NewGuid(), Statues = 1, Value = recordrate, Settingid = new Guid("E038EAB0-9F3D-4967-BE16-06E04633D6C8"), Username = UserName }; iusersetting.Create(usersetting); } else { UserSetting setting = settings[0]; setting.Value = recordrate; iusersetting.Update(setting); } settings = iusersetting.Get(null, UserName, new Guid("6C715AE2-2D77-4827-B4C1-7E5352B7D00B"), 1, 0, null, out paging); if (settings == null || settings.Count == 0) { UserSetting usersetting = new UserSetting { ID = Guid.NewGuid(), Statues = 1, Value = likedrate, Settingid = new Guid("6C715AE2-2D77-4827-B4C1-7E5352B7D00B"), Username = UserName }; iusersetting.Create(usersetting); } else { UserSetting setting = settings[0]; setting.Value = likedrate; iusersetting.Update(setting); } settings = iusersetting.Get(null, UserName, new Guid("4E8E13CA-0726-4610-8CC5-1A5A3191A7BD"), 1, 0, null, out paging); if (settings == null || settings.Count == 0) { UserSetting usersetting = new UserSetting { ID = Guid.NewGuid(), Statues = 1, Value = commentrate, Settingid = new Guid("4E8E13CA-0726-4610-8CC5-1A5A3191A7BD"), Username = UserName }; iusersetting.Create(usersetting); } else { UserSetting setting = settings[0]; setting.Value = commentrate; iusersetting.Update(setting); } return(Json(true, JsonRequestBehavior.AllowGet)); } catch { return(Json(false, JsonRequestBehavior.AllowGet)); } }