Esempio n. 1
0
        public async Task <IActionResult> Delete(string id, string returnUrl)
        {
            ApplicationUser userForDelete = await _userManager.FindByIdAsync(id);

            if (userForDelete != null)
            {
                ApplicationUser admin = await _userManager.FindByNameAsync("admin");

                CommentRepository.DeleteAllUserComments(id);
                RatingRepository.DeleteUserRating(id);
                FanficRepository.SetDefaultUser(id, admin.Id);
                ApplicationUserRepository.DeleteUser(id);
                return(Redirect("/"));
            }
            return(NotFound());
        }
Esempio n. 2
0
        private async void DeleteUser(ApplicationUser applicationUser)
        {
            try
            {
                var confirm = await SweetAlertMessage.ConfirmDialogAsync(Text : $"Delete {applicationUser.Fullname}", ConfirmButtonText : "Delete");

                if (confirm == "Yes")
                {
                    var deleted = await ApplicationUserRepository.DeleteUser(applicationUser.Id);

                    if (deleted)
                    {
                        Users.Remove(applicationUser);
                        StateHasChanged();
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }