private async void btnDelete_Click(object sender, EventArgs e)
        {
            if (this.ValidateChildren())
            {
                var confirmResult = MessageBox.Show("Submit Changes?",
                                                    "Confirm",
                                                    MessageBoxButtons.YesNo);
                if (confirmResult == DialogResult.Yes)
                {
                    string solved = "";
                    if (chbSolved.Checked == true)
                    {
                        solved = "Request solved! Message from admin: \n";
                    }
                    else
                    {
                        solved = "Request denied! Message from admin \n";
                    }
                    NotificationUpsertRequest requestAdd = new NotificationUpsertRequest()
                    {
                        UserId        = _selectedRequest.UserId,
                        NotifDateTime = DateTime.Now,
                        NotifText     = solved + txtNotify.Text
                    };
                    await _notificationService.Insert <Model.Notification>(requestAdd);

                    await _requestService.Delete <Model.Request>(_selectedRequest.RequestId);

                    MessageBox.Show("Task successful");
                    refreshHandler?.Invoke(this, null);
                    this.Close();
                }
            }
        }
Exemple #2
0
        private async void btnDelete_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(txtNotify.Text))
            {
                MessageBox.Show("Please leave a comment about the reason of deletion.");
                return;
            }
            string promptValue = Prompt.ShowDialog("Are you sure you want to remove this review?" +
                                                   " Type your password to confirm.", "Confirm");

            if (APIService.Password == promptValue)
            {
                try
                {
                    await _reviewService.Delete <Model.Review>(_reviewId);

                    NotificationUpsertRequest requestAdd = new NotificationUpsertRequest()
                    {
                        UserId        = _thisUserId,
                        NotifDateTime = DateTime.Now,
                        NotifText     = txtNotify.Text
                    };
                    await _notificationService.Insert <Model.Notification>(requestAdd);

                    refreshHandler?.Invoke(this, null);
                    MessageBox.Show("Task successful");
                    this.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    this.Close();
                }
            }
            else
            {
                MessageBox.Show("Password incorrect");
            }
        }