示例#1
0
        /// <summary>
        /// Method that deletes a supplier from the system when the confirm button is pressed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private async void ContentDialog_SecondaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            Supplier deletedSupplier = await APIHandler <Supplier> .DeleteOne($"Suppliers/DeleteSupplier/{vm.SupplierToDelete.Id}");

            if (deletedSupplier.Id != -1)
            {
                await VMHandler.SupplierVm.LoadDataAsync();

                VMHandler.SupplierVm.FeedBackText = $"{deletedSupplier.Name} has been deleted";
                VMHandler.SupplierVm.Deselect();
            }
            else
            {
                ErrorTextBlock.Text = "Error: Unable to delete default supplier";
                args.Cancel         = true;
            }
        }
示例#2
0
        /// <summary>
        /// Method that is called when a user clicks on confirm for deleting a user
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private async void ContentDialog_SecondaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            Constants.UserDeleteErorrs error = vm.ErrorCheck();
            ErrorTextBlock.Text = CommonMethods.SetErrorTextOnDeleteForUsersPage(error);
            if (error == Constants.UserDeleteErorrs.OK)
            {
                User user = await APIHandler <User> .DeleteOne($"Users/DeleteUser/{vm.SelectedEmp.Id}");

                VMHandler.EmployeesPageVm.LoadDataAsync();
                VMHandler.EmployeesPageVm.FeedBackText = $"{user.Name} has been deleted";
                VMHandler.EmployeesPageVm.Deselect();
                args.Cancel = false;
            }
            else
            {
                args.Cancel = true;
            }
        }