public void SetImportant(SetImportantReq req) { var entity = Context.Task.FirstOrDefault(x => x.TaskId == req.TaskId); entity.IsImportant = req.IsImportant; Context.SaveChanges(); }
//4、 修改重要程度 private async void OnStar(TaskDto task) { var req = new SetImportantReq() { TaskId = task.TaskId, IsImportant = !task.IsImportant, }; var result = await Http.PostAsJsonAsync <SetImportantReq>("api/Task/SetImportant", req); if (result.IsSuccessStatusCode) { task.IsImportant = req.IsImportant; StateHasChanged(); } }