public void OnClick(MaterialDialog p0, DialogAction p1)
        {
            try
            {
                if (DialogType == "Delete")
                {
                    if (p1 == DialogAction.Positive)
                    {
                        // Send Api delete

                        if (Methods.CheckConnectivity())
                        {
                            var adapterGlobal = WRecyclerView.GetInstance()?.NativeFeedAdapter;
                            var diff          = adapterGlobal?.ListDiffer;
                            var dataGlobal    = diff?.Where(a => a.PostData?.PostId == DataInfoObject?.PostId);
                            if (dataGlobal != null)
                            {
                                foreach (var postData in dataGlobal)
                                {
                                    WRecyclerView.GetInstance()?.RemoveByRowIndex(postData);
                                }
                            }

                            var recycler    = TabbedMainActivity.GetInstance()?.NewsFeedTab?.MainRecyclerView;
                            var dataGlobal2 = recycler?.NativeFeedAdapter.ListDiffer?.Where(a => a.PostData?.PostId == DataInfoObject?.PostId);
                            if (dataGlobal2 != null)
                            {
                                foreach (var postData in dataGlobal2)
                                {
                                    recycler.RemoveByRowIndex(postData);
                                }
                            }

                            var dataJob = JobList?.FirstOrDefault(a => a.Id == DataInfoObject.Id);
                            if (dataJob != null)
                            {
                                JobList.Remove(dataJob);
                                NotifyItemRemoved(JobsActivity.GetInstance().MAdapter.JobList.IndexOf(dataJob));
                            }

                            Toast.MakeText(ActivityContext, ActivityContext.GetText(Resource.String.Lbl_postSuccessfullyDeleted), ToastLength.Short).Show();
                            PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                                () => RequestsAsync.Global.Post_Actions(DataInfoObject.PostId, "delete")
                            });
                        }
                        else
                        {
                            Toast.MakeText(ActivityContext, ActivityContext.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                        }
                    }
                    else if (p1 == DialogAction.Negative)
                    {
                        p0.Dismiss();
                    }
                }
                else
                {
                    if (p1 == DialogAction.Positive)
                    {
                    }
                    else if (p1 == DialogAction.Negative)
                    {
                        p0.Dismiss();
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
示例#2
0
        private async void TxtSaveOnClick(object sender, EventArgs e)
        {
            try
            {
                if (Methods.CheckConnectivity())
                {
                    if (string.IsNullOrEmpty(TxtName.Text) || string.IsNullOrEmpty(TxtPhone.Text) || string.IsNullOrEmpty(TxtLocation.Text) ||
                        string.IsNullOrEmpty(TxtWork.Text) || string.IsNullOrEmpty(TxtDescription.Text) || string.IsNullOrEmpty(TxtFromDate.Text))
                    {
                        Toast.MakeText(this, GetText(Resource.String.Lbl_Please_enter_your_data), ToastLength.Short).Show();
                        return;
                    }

                    if (CurrentlyWork == "off" && string.IsNullOrEmpty(TxtToDate.Text))
                    {
                        Toast.MakeText(this, GetText(Resource.String.Lbl_Please_enter_your_data), ToastLength.Short).Show();
                        return;
                    }

                    var check = Methods.FunString.IsEmailValid(TxtEmail.Text.Replace(" ", ""));
                    if (!check)
                    {
                        Toast.MakeText(this, GetText(Resource.String.Lbl_IsEmailValid), ToastLength.Short).Show();
                        return;
                    }

                    //Show a progress
                    AndHUD.Shared.Show(this, GetText(Resource.String.Lbl_Loading));

                    var dictionary = new Dictionary <string, string>
                    {
                        { "job_id", DataInfoObject.Id },
                        { "user_name", TxtName.Text },
                        { "phone_number", TxtPhone.Text },
                        { "location", TxtLocation.Text },
                        { "email", TxtEmail.Text },
                        { "where_did_you_work", TxtWork.Text },
                        { "Position", TxtPosition.Text },
                        { "experience_description", TxtDescription.Text },
                        { "experience_start_date", TxtFromDate.Text },
                        { "experience_end_date", TxtToDate.Text },
                        { "i_currently_work", CurrentlyWork },
                        { "question_one_answer", QuestionOneAnswer },
                        { "question_two_answer", QuestionTwoAnswer },
                        { "question_three_answer", QuestionThreeAnswer },
                    };

                    var(apiStatus, respond) = await RequestsAsync.Jobs.ApplyJob(dictionary);

                    if (apiStatus == 200)
                    {
                        if (respond is MessageJobObject result)
                        {
                            Console.WriteLine(result.MessageData);
                            Toast.MakeText(this, "You have successfully applied to this job", ToastLength.Short).Show();
                            AndHUD.Shared.Dismiss(this);

                            var data = JobsActivity.GetInstance()?.MAdapter?.JobList?.FirstOrDefault(a => a.Id == DataInfoObject.Id);
                            if (data != null)
                            {
                                data.Apply = "true";
                                JobsActivity.GetInstance().MAdapter.NotifyItemChanged(JobsActivity.GetInstance().MAdapter.JobList.IndexOf(data));
                            }

                            SetResult(Result.Ok);
                            Finish();
                        }
                    }
                    else
                    {
                        Methods.DisplayReportResult(this, respond);
                    }

                    AndHUD.Shared.Dismiss(this);
                }
                else
                {
                    Toast.MakeText(this, GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
                AndHUD.Shared.Dismiss(this);
            }
        }