private async Task OpenForEdit(string assessmentId) { var assessment = Assessments.First(u => u.Id == assessmentId); AssessmentItem = assessment; ModalForm.ShowModal(); }
private async Task HandleSubmit(AssessmentItem model) { AssessmentResponseModel response; if (string.IsNullOrEmpty(model.Id)) { response = await _assessmentService.CreateAssessment(model); } else { response = await _assessmentService.UpdateAssessment(model.Id, model); } if (response.isSuccessful) { var assessmentItem = response.data; if (string.IsNullOrEmpty(model.Id)) { Assessments = Assessments.Prepend(assessmentItem).ToList(); toastService.ShowSuccess("Assessment added successfully"); } else { var item = Assessments.First(u => u.Id == model.Id); item.Duration = assessmentItem.Duration; item.Instructions = assessmentItem.Instructions; item.Name = assessmentItem.Name; toastService.ShowSuccess("Assessment updated successfully"); } RefreshAssessments(SearchText); ModalForm.HideModal(); StateHasChanged(); } else { Console.WriteLine(response.message); } }
private void AddNewClass() { var currentDate = DateTime.Now; var dialog = new DateTimeDialogVM("Пожалуйста, выберите дату", currentDate); bool?result = DialogService.I.ShowDialog(dialog); if (result.HasValue) { if (result.Value) { currentDate = dialog.PickedDate; var columnName = currentDate.ToString("dd MMM"); try { Table.Columns.Add(columnName, typeof(Journal)); } catch { MessageBox.Show("Данная дата уже есть в таблице.", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Warning); // TODO: нумерация одинаковых дат в таблице return; } foreach (DataRow row in Table.Rows) { var journal = new Journal() { Date = currentDate, Student = row[0] as Student, Assessment = Assessments.First(x => x.Title == ""), ID = 0 }; row[columnName] = journal; } HasChanges = true; Table = Table.Copy(); // чтобы обновить UI. Не самое эффективное решение, но зато VM по прежнему ничего не знает о V } } }