Exemplo n.º 1
0
        public ActionResult RemoveUser(RemoveUserModel model)
        {
            string userName = User.Identity.Name;

            if (ModelState.IsValid)
            {
                Membership.DeleteUser(model.UserName, true);

                return(RedirectToAction("Manage", "Account"));
            }

            // If we got this far, something failed, redisplay form
            return(RedirectToAction("Manage", "Account"));
        }
Exemplo n.º 2
0
        public async Task <bool> RemoveUser([FromBody] RemoveUserModel userId)
        {
            var user = await _userManager.Users.Include(x => x.NotificationUserIds).FirstOrDefaultAsync(x => x.Id == userId.UserId);

            try
            {
                await _notification.DeleteRange(user.NotificationUserIds);

                return(true);
            }
            catch (Exception e)
            {
                _log.LogError(e, "Could not delete user notification");
            }

            return(false);
        }
Exemplo n.º 3
0
        public async Task <IActionResult> RemoveUser([FromBody] RemoveUserModel model)
        {
            var user = await userManager.FindByNameAsync(model.Username);

            if (user == null)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, new Response {
                    Status = "Error", Message = "User not found!"
                }));
            }

            await userManager.DeleteAsync(user);

            return(Ok(new Response {
                Status = "Success", Message = "User removed successfully!"
            }));
        }