private async void MakeGroupChatRead() { var request = new GroupChatreadRequestModel() { user_id = user_id, job_request_id = JobData.job_id }; Chatdetailresponse response; try { MessageEntry = string.Empty; response = await _webApiRestClient.PostAsync <GroupChatreadRequestModel, Chatdetailresponse>(ApiUrl.MakeGroupReadChat, request); } catch (Exception ex) { Console.WriteLine("SendMsgApi_Exception:- " + ex.Message); response = null; return; } }
private async void DeleteChat(ChatUserModel data) { if (data.job_request_id != null && data.job_request_id.Value > 0) { var deleteChatResult = await App.Current.MainPage.DisplayAlert(AppResource.DeleteGroup, AppResource.DeleteGroupConfirm, AppResource.Yes, AppResource.No); if (deleteChatResult) { try { if (Common.CheckConnection()) { await App.Current.MainPage.Navigation.PushPopupAsync(new LoaderPopup()); Chatdetailresponse response; var request = new GroupChatreadRequestModel() { user_id = user_id, job_request_id = data.job_request_id.Value }; try { response = await _webApiRestClient.PostAsync <GroupChatreadRequestModel, Chatdetailresponse>(ApiUrl.DeleteGroupChatRequest, request); } catch (Exception ex) { response = null; LoaderPopup.CloseAllPopup(); IsRefreshing = false; await MaterialDialog.Instance.SnackbarAsync(message : AppResource.error_ServerError, msDuration : 3000); return; } if (response != null) { if (response.status) { await FirebaseChatHelper.DeleteGroupChat("GroupChat", user_id, data.job_request_id.Value); GetChat(); } else { await MaterialDialog.Instance.SnackbarAsync(message : response.message, msDuration : 3000); } } } else { await MaterialDialog.Instance.SnackbarAsync(message : AppResource.error_InternetError, msDuration : 3000); } } catch (Exception ex) { } finally { //await Task.Delay(1500); LoaderPopup.CloseAllPopup(); IsRefreshing = false; } } } else { var deleteChatResult = await App.Current.MainPage.DisplayAlert(AppResource.DeleteChat, AppResource.DeleteChatConfirm, AppResource.Yes, AppResource.No); if (deleteChatResult) { try { if (Common.CheckConnection()) { await App.Current.MainPage.Navigation.PushPopupAsync(new LoaderPopup()); Chatdetailresponse response; var request = new ChatDetailModelApi() { from_user_id = user_id, to_user_id = data.user_id.Value }; try { response = await _webApiRestClient.PostAsync <ChatDetailModelApi, Chatdetailresponse>(ApiUrl.DeleteChatRequest, request); } catch (Exception ex) { response = null; LoaderPopup.CloseAllPopup(); IsRefreshing = false; await MaterialDialog.Instance.SnackbarAsync(message : AppResource.error_ServerError, msDuration : 3000); return; } if (response != null) { if (response.status) { await FirebaseChatHelper.DeleteSingleChat("Chat", user_id, data.user_id.Value); GetChat(); } else { await MaterialDialog.Instance.SnackbarAsync(message : response.message, msDuration : 3000); } } } else { await MaterialDialog.Instance.SnackbarAsync(message : AppResource.error_InternetError, msDuration : 3000); } } catch (Exception ex) { } finally { await Task.Delay(1500); LoaderPopup.CloseAllPopup(); IsRefreshing = false; } } } }