private void BtnGoOnClick(object sender, EventArgs e) { try { if (!Methods.CheckConnectivity()) { Toast.MakeText(this, GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show(); return; } if (BtnGo.Tag.ToString() == "false") { BtnGo.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends_pressed); BtnGo.SetTextColor(Color.ParseColor("#ffffff")); BtnGo.Text = GetText(Resource.String.Lbl_Going); BtnGo.Tag = "true"; } else { BtnGo.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends); BtnGo.SetTextColor(Color.ParseColor(AppSettings.MainColor)); BtnGo.Text = GetText(Resource.String.Lbl_Go); BtnGo.Tag = "false"; } var list = EventMainActivity.GetInstance()?.EventTab.MAdapter?.EventList; var dataEvent = list?.FirstOrDefault(a => a.Id == EventData.Id); if (dataEvent != null) { dataEvent.IsGoing = Convert.ToBoolean(BtnGo.Tag.ToString()); EventMainActivity.GetInstance()?.EventTab.MAdapter.NotifyItemChanged(list.IndexOf(dataEvent)); } PollyController.RunRetryPolicyFunction(new List <Func <Task> > { () => RequestsAsync.Event.Go_To_Event(EventData.Id) }); } catch (Exception exception) { Console.WriteLine(exception); } }
private async void TxtAddOnClick(object sender, EventArgs e) { try { if (!Methods.CheckConnectivity()) { Toast.MakeText(this, GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show(); } else { if (string.IsNullOrEmpty(TxtEventName.Text)) { Toast.MakeText(this, GetText(Resource.String.Lbl_Please_enter_name), ToastLength.Short).Show(); return; } if (string.IsNullOrEmpty(TxtStartDate.Text)) { Toast.MakeText(this, GetText(Resource.String.Lbl_Please_select_start_date), ToastLength.Short).Show(); return; } if (string.IsNullOrEmpty(TxtEndDate.Text)) { Toast.MakeText(this, GetText(Resource.String.Lbl_Please_select_end_date), ToastLength.Short).Show(); return; } if (string.IsNullOrEmpty(TxtLocation.Text)) { Toast.MakeText(this, GetText(Resource.String.Lbl_Please_select_Location), ToastLength.Short).Show(); return; } if (string.IsNullOrEmpty(TxtStartTime.Text)) { Toast.MakeText(this, GetText(Resource.String.Lbl_Please_select_start_time), ToastLength.Short).Show(); return; } if (string.IsNullOrEmpty(TxtEndTime.Text)) { Toast.MakeText(this, GetText(Resource.String.Lbl_Please_select_end_time), ToastLength.Short).Show(); return; } if (string.IsNullOrEmpty(TxtDescription.Text)) { Toast.MakeText(this, GetText(Resource.String.Lbl_Please_enter_Description), ToastLength.Short).Show(); return; } if (string.IsNullOrEmpty(EventPathImage)) { Toast.MakeText(this, GetText(Resource.String.Lbl_Please_select_Image), ToastLength.Short).Show(); } else { //Show a progress AndHUD.Shared.Show(this, GetText(Resource.String.Lbl_Loading) + "..."); var(apiStatus, respond) = await RequestsAsync.Event.Edit_Event(EventId, TxtEventName.Text, TxtLocation.Text, TxtDescription.Text, TxtStartDate.Text, TxtEndDate.Text, TxtStartTime.Text, TxtEndTime.Text, EventPathImage); if (apiStatus == 200) { if (respond is EditEventObject result) { Console.WriteLine(result.MessageData); //Add new item to my Event list var user = ListUtils.MyProfileList?.FirstOrDefault(); if (EventMainActivity.GetInstance()?.MyEventTab?.MAdapter.EventList != null) { var data = EventMainActivity.GetInstance()?.MyEventTab?.MAdapter?.EventList?.FirstOrDefault(a => a.Id == EventId); if (data != null) { data.Id = EventId; data.Description = TxtDescription.Text; data.Cover = EventPathImage; data.EndDate = TxtEndDate.Text; data.EndTime = TxtEndTime.Text; data.IsOwner = true; data.Location = TxtLocation.Text; data.Name = TxtEventName.Text; data.StartDate = TxtStartDate.Text; data.StartTime = TxtStartTime.Text; data.UserData = user; EventMainActivity.GetInstance()?.MyEventTab?.MAdapter?.NotifyItemChanged(EventMainActivity.GetInstance().MyEventTab.MAdapter.EventList.IndexOf(data)); } } if (EventMainActivity.GetInstance()?.EventTab?.MAdapter.EventList != null) { var data = EventMainActivity.GetInstance()?.EventTab?.MAdapter.EventList?.FirstOrDefault(a => a.Id == EventId); if (data != null) { data.Id = EventId; data.Description = TxtDescription.Text; data.Cover = EventPathImage; data.EndDate = TxtEndDate.Text; data.EndTime = TxtEndTime.Text; data.IsOwner = true; data.Location = TxtLocation.Text; data.Name = TxtEventName.Text; data.StartDate = TxtStartDate.Text; data.StartTime = TxtStartTime.Text; data.UserData = user; EventMainActivity.GetInstance()?.EventTab?.MAdapter?.NotifyItemChanged(EventMainActivity.GetInstance().EventTab.MAdapter.EventList.IndexOf(data)); } } AndHUD.Shared.ShowSuccess(this); Toast.MakeText(this, GetString(Resource.String.Lbl_EventSuccessfullyEdited), ToastLength.Short).Show(); Finish(); } } else { if (respond is ErrorObject error) { var errorText = error.Error.ErrorText; AndHUD.Shared.Dismiss(this); Snackbar.Make(TxtDescription, errorText, Snackbar.LengthLong).Show(); } Methods.DisplayReportResult(this, respond); } AndHUD.Shared.Dismiss(this); } } } catch (Exception exception) { Console.WriteLine(exception); AndHUD.Shared.Dismiss(this); } }