public async Task <IActionResult> DeleteApp(DeleteAppAddressModel model) { var appid = _tokenManager.ValidateAccessToken(model.AccessToken); if (appid != model.AppId) { return(Ok(new AiurProtocol { Code = ErrorType.Unauthorized, Message = "The app you try to delete is not the accesstoken you granted!" })); } var target = await _dbContext.Apps.FindAsync(appid); if (target != null) { _stargateMemory.DeleteChannels(_stargateMemory.GetChannelsUnderApp(appid).Select(t => t.Id)); _dbContext.Apps.Remove(target); await _dbContext.SaveChangesAsync(); return(Ok(new AiurProtocol { Code = ErrorType.Success, Message = "Successfully deleted that app and all channels." })); } return(Ok(new AiurProtocol { Code = ErrorType.HasDoneAlready, Message = "That app do not exists in our database." })); }
private void AllClean(StargateMemory memory) { try { var toDelete = memory.GetDeadChannels(); memory.DeleteChannels(toDelete.Select(t => t.Id)); } catch (Exception e) { _logger.LogError(e, "Cleaner crashed!"); } }