public UpdateIllnessEventPage(IllnessEvent illnessEvent) { InitializeComponent(); var viewModel = new UpdateIllnessEventViewModel(); viewModel.IllnessEvent = illnessEvent; BindingContext = viewModel; }
public async void EditIllnessEvent() { HasError = true; var connection = await apiService.CheckConnection(); if (!connection.IsSuccess) { await Application.Current.MainPage.DisplayAlert( Languages.Warning, Languages.CheckConnection, Languages.Ok); return; } if (string.IsNullOrEmpty(IllnessEvent.code) || string.IsNullOrEmpty(IllnessEvent.description)) { HasError = true; return; } else { HasError = false; } var icdo = new IllnessEvent { id = IllnessEvent.id, code = IllnessEvent.code, description = IllnessEvent.description }; var cookie = Settings.Cookie; //.Split(11, 33) var res = cookie.Substring(11, 32); var response = await apiService.Put <IllnessEvent>( "https://portalesp.smart-path.it", "/Portalesp", "/illnessEvent/update", res, icdo); Debug.WriteLine("********responseIn ViewModel*************"); Debug.WriteLine(response); if (!response.IsSuccess) { await Application.Current.MainPage.DisplayAlert("Error", response.Message, "ok"); return; } HasError = false; IllnessEventViewModel.GetInstance().Update(icdo); DependencyService.Get <INotification>().CreateNotification("PortalSP", "Illness Event Updated"); await App.Current.MainPage.Navigation.PopPopupAsync(true); }
private async void Update_IllnessEvent(object sender, EventArgs e) { TappedEventArgs tappedEventArgs = (TappedEventArgs)e; IllnessEvent illnessEvent = ((IllnessEventViewModel)BindingContext).IllnessEvents.Where(ser => ser.id == (int)tappedEventArgs.Parameter).FirstOrDefault(); await PopupNavigation.Instance.PushAsync(new UpdateIllnessEventPage(illnessEvent)); }