我尝试使用数据库上下文更新数据库中的2个字段
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult ChangeDefaultUserLockingSetting(int PasswordAttempts, int DefaultLockingTime)
{
var defaultAccountSettings = new DefaultAccountSettingsDataContext();
var defaultLockoutTimeSpam = defaultAccountSettings.DefaultAccountSettings.Where(u=>u.id==1).Select(u=>u.DefaultAccountLockoutTimeSpan).First();
var maxFailedAccessAttemptsBeforeLockout = defaultAccountSettings.DefaultAccountSettings.Where(u => u.id == 1).Select(u=>u.MaxFailedAccessAttemptsBeforeLockout).First();
//foreach (int item in defaultLockoutTimeSpam)
{
defaultLockoutTimeSpam = DefaultLockingTime;
}
maxFailedAccessAttemptsBeforeLockout = DefaultLockingTime;
defaultAccountSettings.SubmitChanges();
return View("Index", loadAdministrationViewModel());
}
我做错了什么?
答案 0 :(得分:1)
您需要尝试此代码。
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult ChangeDefaultUserLockingSetting(int PasswordAttempts, int DefaultLockingTime)
{
var defaultAccountSettings = new DefaultAccountSettingsDataContext();
var defaultLockoutTimeSpam = defaultAccountSettings.DefaultAccountSettings.Where(u => u.id == 1).FirstOrDefault();
var maxFailedAccessAttemptsBeforeLockout = defaultAccountSettings.DefaultAccountSettings.Where(u => u.id == 1).FirstOrDefault();
//foreach (int item in defaultLockoutTimeSpam)
{
defaultLockoutTimeSpam.DefaultAccountLockoutTimeSpan = DefaultLockingTime;
}
maxFailedAccessAttemptsBeforeLockout.MaxFailedAccessAttemptsBeforeLockout = DefaultLockingTime;
defaultAccountSettings.SubmitChanges();
return View("Index", loadAdministrationViewModel());
}
答案 1 :(得分:1)
我正在修改值但不对象
这是正确的方法:
S_TIME_FORMAT
If this variable exists and its value is ISO then the current locale will be ignored when printing the date in the report header.
The mpstat command will use the ISO 8601 format (YYYY-MM-DD) instead.