public async void CreateProject() { var projectFormValidator = new ProjectFormValidator(); var projectModel = new ProjectModel(_customerAccess) { Name = ProjectName, Comment = Comment, CustomerName = SelectedCustomer }; var validationResult = projectFormValidator.Validate(projectModel); if (validationResult.IsValid) { var projectEntity = await projectModel.ConvertToProjectEntity(); var addProjectResult = await _projectAccess.AddProject(projectEntity); if (addProjectResult) { _events.PublishOnUIThread(new NewProjectAddedEvent()); TryClose(); } else { MessageBox.Show("Wystąpił błąd podczas zapisu danych. Spróbuj ponownie"); } } else { MessageBox.Show("Błąd walidacji danych"); } }
public async void SaveButton() { var projectModel = new ProjectModel(_customerAccess) { Id = project.Id, Name = ProjectName, Status = SelectedProjectStatus, CustomerName = SelectedProjectCustomer, Comment = Comment }; var projectFormValidator = new ProjectFormValidator(); var validationResult = projectFormValidator.Validate(projectModel); // For tests ProjectValidationResult = validationResult.IsValid; if (validationResult.IsValid) { var projectEntity = await projectModel.ConvertToProjectEntity(); var resultTask = await _projectAccess.UpdateProject(projectEntity); // For tests UpdateProjectResult = resultTask; if (resultTask) { _events.PublishOnUIThread(new ChangedProjectCredentialsEvent(project.Id)); TryClose(); } else { MessageBox.Show("Wystąpił błąd podczas zapisu danych. Spróbuj ponownie"); } } else { MessageBox.Show("Błąd walidacji danych"); } }