private void BtnGoOnClick(object sender, EventArgs e) { try { if (!Methods.CheckConnectivity()) { Toast.MakeText(this, GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short)?.Show(); return; } switch (BtnGo?.Tag?.ToString()) { case "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"; break; default: BtnGo.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends); BtnGo.SetTextColor(Color.ParseColor(AppSettings.MainColor)); BtnGo.Text = GetText(Resource.String.Lbl_Go); BtnGo.Tag = "false"; break; } 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.GoToEventAsync(EventData.Id) }); } catch (Exception exception) { Methods.DisplayReportResultTrack(exception); } }
private void BtnInterestedOnClick(object sender, EventArgs e) { try { if (!Methods.CheckConnectivity()) { Toast.MakeText(this, GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show(); return; } if (BtnInterested.Tag.ToString() == "false") { BtnInterested.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends_pressed); BtnInterested.SetTextColor(Color.ParseColor("#ffffff")); BtnInterested.Text = GetText(Resource.String.Lbl_Interested); BtnInterested.Tag = "true"; } else { BtnInterested.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends); BtnInterested.SetTextColor(Color.ParseColor(AppSettings.MainColor)); BtnInterested.Text = GetText(Resource.String.Lbl_Interested); BtnInterested.Tag = "false"; } var dataEvent = EventMainActivity.GetInstance()?.EventTab.MAdapter.EventList?.FirstOrDefault(a => a.Id == EventData.Id); if (dataEvent != null) { dataEvent.IsInterested = Convert.ToBoolean(BtnInterested.Tag.ToString()); } PollyController.RunRetryPolicyFunction(new List <Func <Task> > { () => RequestsAsync.Event.Interest_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); } }
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.Create_Event(TxtEventName.Text, TxtLocation.Text, TxtDescription.Text, TxtStartDate.Text.Replace("/", "-"), TxtEndDate.Text.Replace("/", ""), TxtStartTime.Text.Replace("AM", "").Replace("PM", "").Replace(" ", ""), TxtEndTime.Text.Replace(" ", "-").Replace("AM", "").Replace("PM", ""), EventPathImage); if (apiStatus == 200) { if (respond is CreateEvent result) { AndHUD.Shared.ShowSuccess(this); Toast.MakeText(this, GetText(Resource.String.Lbl_CreatedSuccessfully), ToastLength.Short)?.Show(); //wael //Add new item to my Event list var user = ListUtils.MyProfileList?.FirstOrDefault(); EventDataObject data = new EventDataObject { Id = result.EventId.ToString(), Description = TxtDescription.Text, Cover = EventPathImage, EndDate = TxtEndDate.Text, EndTime = TxtEndTime.Text, IsOwner = true, Location = TxtLocation.Text, Name = TxtEventName.Text, StartDate = TxtStartDate.Text, StartTime = TxtStartTime.Text, UserData = user, }; if (EventMainActivity.GetInstance()?.MyEventTab?.MAdapter?.EventList != null) { EventMainActivity.GetInstance()?.MyEventTab.MAdapter?.EventList?.Insert(0, data); EventMainActivity.GetInstance()?.MyEventTab.MAdapter?.NotifyItemInserted(EventMainActivity.GetInstance().MyEventTab.MAdapter.EventList.IndexOf(data)); } if (EventMainActivity.GetInstance()?.EventTab?.MAdapter?.EventList != null) { EventMainActivity.GetInstance()?.EventTab.MAdapter?.EventList?.Insert(0, data); EventMainActivity.GetInstance()?.EventTab.MAdapter?.NotifyItemInserted(EventMainActivity.GetInstance().EventTab.MAdapter.EventList.IndexOf(data)); } Finish(); } } else { Methods.DisplayAndHudErrorResult(this, respond); } } } } catch (Exception exception) { Methods.DisplayReportResultTrack(exception); AndHUD.Shared.Dismiss(this); } }