public async Task <IActionResult> HardDelete(HardDeleteUserModel model) { if (!ModelState.IsValid || model.Confirm == false) { this._logger.LogWarning($"Model state for HardDeleteUserModel model is invalid, or model.Confirm propery was not selected"); return(this.View(model)); } var idOfUser = model.Id; var user = await this._usersService .GetUserByIdWithDeletedAsync(idOfUser); if (user == null) { this._logger.LogWarning($"Current user - NOT FOUND"); return(this.NotFound()); } await this._usersService.DeleteAllDataForUserAsync(idOfUser); await this._userManager.DeleteAsync(user); this._logger.LogInformation($"User with id {user.Id} has been successfully removed from the DB with all the relevant data"); TempData["UserRemoved"] = "The user has been removed from the database!"; return(this.RedirectToAction("Index", "Users")); }
public IHttpActionResult Post([FromBody] HardDeleteUserModel user) { var script = _powershellScriptLoader.LoadScript(PowershellScripts.HardDeleteUser); _powerShellUtility.AttachOffice365Credentials(_powerShellManager); _powerShellManager.AttachParameters(user.MapPropertiesToOffice365Parameters()); _powerShellManager.ExecuteScript(script); return(Ok(true)); }
public async Task <IActionResult> HardDelete(string id) { var userFromDb = await this._usersService .GetUserByIdWithDeletedAsync(id); if (userFromDb == null) { this._logger.LogWarning($"Current user - NOT FOUND"); return(this.NotFound()); } var model = new HardDeleteUserModel { Id = userFromDb.Id, FullName = this.FullNameCreator(userFromDb.FirstName, userFromDb.LastName) }; return(this.View(model)); }