public IActionResult OnGet(int id) { Task = _taskManager.GeTask(id); if (Task == null) { return(NotFound()); } TaskInterval interval = Task.Interval; DefaultInterval = interval.ToDisplayString(); Input = new InputModel { Id = Task.Id, Interval = Task.TaskArgument.Interval ?? Task.Interval }; return(Page()); }
public async Task <IActionResult> OnPost() { TaskInterval interval = null; if (!string.IsNullOrEmpty(Input.Interval)) { try { interval = Input.Interval; } catch (Exception) { ModelState.AddModelError("Input.Interval", "时间间隔格式错误,请输入正确的格式!"); return(Error()); } } Task = _taskManager.GeTask(Input.Id); if (await _taskManager.SaveArgumentIntervalAsync(Input.Id, interval?.ToString())) { interval = Task.Interval; await LogAsync("将后台服务 {2} 的时间间隔由 {0} 修改为 {1}。", Task.ToIntervalDisplayString(), interval.ToDisplayString(), Task.Name); return(Success("你已经成功更改了时间间隔!")); } return(Error()); }