public void Delete(int id) { if (UserPermissions.IsAuthorized(User, "Folder", id, "Edit")) { Folders.DeleteFolder(id); logger.Log(LogLevel.Information, this, LogFunction.Delete, "Folder Deleted {FolderId}", id); } }
public async Task Delete(int id, string siteid) { int SiteId; User user = _users.GetUser(id); if (user != null && int.TryParse(siteid, out SiteId) && SiteId == _alias.SiteId) { // remove user roles for site foreach (UserRole userrole in _userRoles.GetUserRoles(user.UserId, SiteId).ToList()) { _userRoles.DeleteUserRole(userrole.UserRoleId); _logger.Log(LogLevel.Information, this, LogFunction.Delete, "User Role Deleted {UserRole}", userrole); } // remove user folder for site var folder = _folders.GetFolder(SiteId, Utilities.PathCombine("Users", user.UserId.ToString(), Path.DirectorySeparatorChar.ToString())); if (folder != null) { if (Directory.Exists(_folders.GetFolderPath(folder))) { Directory.Delete(_folders.GetFolderPath(folder), true); } _folders.DeleteFolder(folder.FolderId); _logger.Log(LogLevel.Information, this, LogFunction.Delete, "User Folder Deleted {Folder}", folder); } // delete user if they are not a member of any other sites if (!_userRoles.GetUserRoles(user.UserId, -1).Any()) { // get identity user IdentityUser identityuser = await _identityUserManager.FindByNameAsync(user.Username); if (identityuser != null) { // delete identity user var result = await _identityUserManager.DeleteAsync(identityuser); if (result != null) { // delete user _users.DeleteUser(user.UserId); _logger.Log(LogLevel.Information, this, LogFunction.Delete, "User Deleted {UserId}", user.UserId); } else { _logger.Log(LogLevel.Error, this, LogFunction.Delete, "Error Deleting User {UserId}", user.UserId, result.ToString()); } } } } else { _logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized User Delete Attempt {UserId}", id); HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden; } }
public void Delete(int id) { if (_userPermissions.IsAuthorized(User, EntityNames.Folder, id, PermissionNames.Edit)) { _folders.DeleteFolder(id); _logger.Log(LogLevel.Information, this, LogFunction.Delete, "Folder Deleted {FolderId}", id); } else { _logger.Log(LogLevel.Error, this, LogFunction.Delete, "User Not Authorized To Delete Folder {FolderId}", id); HttpContext.Response.StatusCode = 401; } }
public void Delete(int id) { if (UserPermissions.IsAuthorized(User, "Folder", id, "Edit")) { Folders.DeleteFolder(id); logger.Log(LogLevel.Information, this, LogFunction.Delete, "Folder Deleted {FolderId}", id); } else { logger.Log(LogLevel.Error, this, LogFunction.Delete, "User Not Authorized To Delete Folder {FolderId}", id); HttpContext.Response.StatusCode = 401; } }
public async Task Delete(int id, string siteid) { User user = _users.GetUser(id); if (user != null) { // remove user roles for site foreach (UserRole userrole in _userRoles.GetUserRoles(user.UserId, Int32.Parse(siteid)).ToList()) { _userRoles.DeleteUserRole(userrole.UserRoleId); _logger.Log(LogLevel.Information, this, LogFunction.Delete, "User Role Deleted {UserRole}", userrole); } // remove user folder for site var folder = _folders.GetFolder(Int32.Parse(siteid), Utilities.PathCombine("Users", user.UserId.ToString(), Path.DirectorySeparatorChar.ToString())); if (folder != null) { if (Directory.Exists(_folders.GetFolderPath(folder))) { Directory.Delete(_folders.GetFolderPath(folder), true); } _folders.DeleteFolder(folder.FolderId); _logger.Log(LogLevel.Information, this, LogFunction.Delete, "User Folder Deleted {Folder}", folder); } // delete user if they are not a member of any other sites if (!_userRoles.GetUserRoles(user.UserId, -1).Any()) { // get identity user IdentityUser identityuser = await _identityUserManager.FindByNameAsync(user.Username); if (identityuser != null) { // delete identity user var result = await _identityUserManager.DeleteAsync(identityuser); if (result != null) { // delete user _users.DeleteUser(user.UserId); _logger.Log(LogLevel.Information, this, LogFunction.Delete, "User Deleted {UserId}", user.UserId); } else { _logger.Log(LogLevel.Error, this, LogFunction.Delete, "Error Deleting User {UserId}", user.UserId, result.ToString()); } } } } }
public IActionResult DeleteFolder([FromBody] string folderName) { if (userGet.HaveUser(HttpContext)) { pictureRemover.DeletePicturesForFolder(userGet.GetUser(HttpContext), folderName); Success success = folderRepository.DeleteFolder(userGet.GetUser(HttpContext), folderName); switch (success) { case Success.Successfull: return(Ok()); case Success.FailedByNotExist: return(BadRequest("Folder doesn't exist!")); } } return(Unauthorized()); }
public void Delete(int id) { if (_userPermissions.IsAuthorized(User, EntityNames.Folder, id, PermissionNames.Edit)) { Models.Folder _folder = _folders.GetFolder(id, false); if (Directory.Exists(GetFolderPath(_folder))) { Directory.Delete(GetFolderPath(_folder)); } _folders.DeleteFolder(id); _logger.Log(LogLevel.Information, this, LogFunction.Delete, "Folder Deleted {FolderId}", id); } else { _logger.Log(LogLevel.Error, this, LogFunction.Delete, "User Not Authorized To Delete Folder {FolderId}", id); HttpContext.Response.StatusCode = 401; } }
public void Delete(int id) { var folder = _folders.GetFolder(id, false); if (folder != null && folder.SiteId == _alias.SiteId && _userPermissions.IsAuthorized(User, EntityNames.Folder, id, PermissionNames.Edit)) { if (Directory.Exists(GetFolderPath(folder))) { Directory.Delete(GetFolderPath(folder)); } _folders.DeleteFolder(id); _logger.Log(LogLevel.Information, this, LogFunction.Delete, "Folder Deleted {FolderId}", id); } else { _logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized Folder Delete Attempt {FolderId}", id); HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden; } }
public async Task DeleteFolder(int folderId) { await _folderRepository.DeleteFolder(folderId); }
public List <ScenarioViewModel> DeleteFolder(int folderId) { var trashScenarios = _folderRepository.DeleteFolder(folderId); return(trashScenarios.Select(ScenarioMapper.ToScenarioViewModel).ToList()); }