Exemple #1
0
        private async void TxtSaveOnClick(object sender, EventArgs e)
        {
            try
            {
                if (Methods.CheckConnectivity())
                {
                    if (string.IsNullOrEmpty(TxtTitle.Text) || string.IsNullOrEmpty(TxtLocation.Text) || string.IsNullOrEmpty(TxtMinimum.Text) ||
                        string.IsNullOrEmpty(TxtMaximum.Text) || string.IsNullOrEmpty(TxtSalaryDate.Text) || string.IsNullOrEmpty(TxtJobType.Text) ||
                        string.IsNullOrEmpty(TxtDescription.Text) || string.IsNullOrEmpty(TxtCategory.Text))
                    {
                        Toast.MakeText(this, GetText(Resource.String.Lbl_Please_enter_your_data), ToastLength.Short).Show();
                        return;
                    }

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

                    var(apiStatus, respond) = await RequestsAsync.Jobs.EditJob(DataInfoObject.Id, TxtTitle.Text, TxtDescription.Text, TxtLocation.Text,
                                                                               TxtMinimum.Text, TxtMaximum.Text, SalaryDateId, JobTypeId, CategoryId);

                    if (apiStatus == 200)
                    {
                        if (respond is MessageJobObject result)
                        {
                            Console.WriteLine(result.MessageData);
                            Toast.MakeText(this, GetString(Resource.String.Lbl_jobSuccessfullyEdited), ToastLength.Short).Show();
                            AndHUD.Shared.Dismiss(this);

                            JobInfoObject newInfoObject = new JobInfoObject()
                            {
                                Title       = TxtTitle.Text,
                                Location    = TxtLocation.Text,
                                Minimum     = TxtMinimum.Text,
                                Maximum     = TxtMaximum.Text,
                                SalaryDate  = TxtSalaryDate.Text,
                                JobType     = TxtJobType.Text,
                                Description = TxtDescription.Text,
                                Category    = CategoryId,
                            };

                            JobInfoObject data = JobsActivity.GetInstance()?.MAdapter?.JobList?.FirstOrDefault(a => a.Id == DataInfoObject.Id);
                            if (data != null)
                            {
                                data.Title       = TxtTitle.Text;
                                data.Location    = TxtLocation.Text;
                                data.Minimum     = TxtMinimum.Text;
                                data.Maximum     = TxtMaximum.Text;
                                data.SalaryDate  = TxtSalaryDate.Text;
                                data.JobType     = TxtJobType.Text;
                                data.Description = TxtDescription.Text;
                                data.Category    = CategoryId;
                                JobsActivity.GetInstance().MAdapter.NotifyItemChanged(JobsActivity.GetInstance().MAdapter.JobList.IndexOf(data));
                            }

                            Intent intent = new Intent();
                            intent.PutExtra("JobsItem", JsonConvert.SerializeObject(newInfoObject));
                            SetResult(Result.Ok, intent);
                            Finish();
                        }
                    }
                    else
                    {
                        Methods.DisplayAndHUDErrorResult(this, respond);
                    }
                }
                else
                {
                    Toast.MakeText(this, GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
                AndHUD.Shared.Dismiss(this);
            }
        }
 public override void OnCreate(Bundle savedInstanceState)
 {
     base.OnCreate(savedInstanceState);
     // Create your fragment here
     ContextJobs = (JobsActivity)Activity;
 }
        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);
            }
        }
Exemple #4
0
        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 = JobsActivity.GetInstance()?.MAdapter?.JobList?.FirstOrDefault(a => a.Id == DataInfoObject.Id);
                            if (dataJob != null)
                            {
                                JobsActivity.GetInstance()?.MAdapter?.JobList.Remove(dataJob);
                                JobsActivity.GetInstance().MAdapter.NotifyItemRemoved(JobsActivity.GetInstance().MAdapter.JobList.IndexOf(dataJob));
                            }

                            Toast.MakeText(this, GetText(Resource.String.Lbl_postSuccessfullyDeleted), ToastLength.Short).Show();
                            PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                                () => RequestsAsync.Global.Post_Actions(DataInfoObject.PostId, "delete")
                            });
                        }
                        else
                        {
                            Toast.MakeText(this, 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);
            }
        }