private async Task DeleteTask(TaskDto task)
        {
            var result = await MatDialogService.AskAsync("Are you sure you want to delete this task?", new[] { "Yes", "Cancel" });

            if (result == "Cancel")
            {
                return;
            }
            await Http.PostAsJsonAsync <TaskDto>($"api/task/delete/{task.Id}", task);

            NavigationManager.NavigateTo("/alltasks", true);
        }
Beispiel #2
0
        private async Task DeleteEmployee(EmployeeDto employee)
        {
            var result = await MatDialogService.AskAsync("Are you sure you want to delete this employee?", new[] { "Yes", "Cancel" });

            if (result == "Cancel")
            {
                return;
            }
            await Http.PostAsJsonAsync <EmployeeDto>($"api/employee/delete/{employee.Id}", employee);

            NavigationManager.NavigateTo("/allemployees", true);
        }
Beispiel #3
0
        protected async Task Borrar(string dni)
        {
            try
            {
                var result = await MatDialogService.AskAsync("¿Estás seguro de que quieres borrar esta persona?", new string[] { "Sí", "No" });

                if (result == "Sí")
                {
                    await Http.DeleteAsync("api/persona/" + dni);
                    await FetchData();

                    StateHasChanged();
                    Toaster.Add("Persona borrada!", MatToastType.Success, "Exito", MatIconNames.Check_circle);
                }
            }
            catch
            {
                Toaster.Add("Fallo al borrar persona", MatToastType.Danger, "Error", MatIconNames.Clear);
            }
        }
Beispiel #4
0
        protected async Task OpenConfirmServiceRemove(AspNetUsersItemViewModel item)
        {
            var result = await MatDialogService.AskAsync($"Möchten Sie den Datensatz {item.UserName} wirklich löschen?", new string[] { "Löschen", "Abbrechen" });

            if (result == "Löschen")
            {
                try
                {
                    Service.Delete(item);
                    Model.Remove(item);
                }
                catch (Exception e)
                {
                    Logger.LogError(e, $"{GetUserName()}*Error: AspNetUsers/OpenConfirmServiceRemove");
                    ErrorModel.IsOpen       = true;
                    ErrorModel.ErrorContext = e.StackTrace;
                    ErrorModel.ErrorMessage = e.Message;
                    IsFailed = true;
                    StateHasChanged();
                }
            }
        }
Beispiel #5
0
        protected async Task OpenConfirmServiceRemove(KundeItemViewModel item)
        {
            var result = await MatDialogService.AskAsync("Are you sure?", new string[] { "Yes", "No" });

            if (result == "Yes")
            {
                try
                {
                    Service.Delete(item);
                    Model.Remove(item);
                }

                catch (Exception e)
                {
                    Logger.LogError(e, $"{GetUserName()}*Error: KundePage/Remove");
                    ErrorModel.IsOpen       = true;
                    ErrorModel.ErrorContext = e.StackTrace;
                    ErrorModel.ErrorMessage = e.Message;
                    IsFailed = true;
                    StateHasChanged();
                }
            }
        }
        /// <summary>
        /// Runs a prompt with the given message.
        /// </summary>
        /// <param name="message">The message which is shown to the user.</param>
        /// <returns>True if the user confirmed the action. False otherwise.</returns>
        private async Task <bool> RunPrompt(string message)
        {
            string result = await MatDialogService.AskAsync(message, dialogOptions);

            return(UserClickedConfirm(result));
        }