async void SaveActivityClicked(object sender, EventArgs args) { if (string.IsNullOrEmpty(ActivityDescriptionEdit.Text)) { await dialogService.ShowMessage("Error", "You must enter an activity description."); ActivityDescriptionEdit.Focus(); return; } var checkConnetion = await apiService.CheckConnection(); if (!checkConnetion.IsSuccess) { await dialogService.ShowMessage("Error", checkConnetion.Message); return; } var urlAPI = Application.Current.Resources["URLAPI"].ToString(); var mainViewModel = MainViewModel.GetInstance(); var employee = mainViewModel.Employee; var activity = new Activity { Description = ActivityDescriptionEdit.Text, }; var response = await apiService.Post( urlAPI, "/api", "/Activities", employee.TokenType, employee.AccessToken, activity); if (!response.IsSuccess) { await dialogService.ShowMessage("Error", response.Message); return; } var newTimeViewModel = NewTimeViewModel.GetInstance(); newTimeViewModel.activities.Add((Activity)response.Result); newTimeViewModel.ReloadActivities(); ActivityModalEdit.IsVisible = false; }
void NewActivityClicked(object sender, EventArgs args) { ActivityDescriptionEdit.Text = string.Empty; ActivityModalEdit.IsVisible = true; ActivityDescriptionEdit.Focus(); }