public async Task <IActionResult> DeleteApp(DeleteAppAddressModel model) { var appid = _tokenManager.ValidateAccessToken(model.AccessToken); if (appid != model.AppId) { return(Json(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) { _dbContext.Channels.Delete(t => t.AppId == target.Id); _dbContext.Apps.Remove(target); await _dbContext.SaveChangesAsync(); return(Json(new AiurProtocol { Code = ErrorType.Success, Message = "Successfully deleted that app and all channels." })); } return(Json(new AiurProtocol { Code = ErrorType.HasDoneAlready, Message = "That app do not exists in our database." })); }
public async Task <IActionResult> DeleteApp(DeleteAppAddressModel model) { var app = await _appRepo.GetApp(model.AccessToken); if (app.AppId != model.AppId) { return(this.Protocol(ErrorType.Unauthorized, "The app you try to delete is not the access token you granted!")); } await _appRepo.DeleteApp(app); return(this.Protocol(ErrorType.HasDoneAlready, "That app do not exists in our database.")); }
public async Task <IActionResult> DeleteApp(DeleteAppAddressModel model) { var appid = _tokenManager.ValidateAccessToken(model.AccessToken); if (appid != model.AppId) { return(this.Protocol(ErrorType.Unauthorized, "The app you try to delete is not the access token you granted!")); } _dbContext.ErrorLogs.Delete(t => t.AppId == appid); await _dbContext.SaveChangesAsync(); return(this.Protocol(ErrorType.Success, "App deleted.")); }
public async Task <JsonResult> DeleteApp(DeleteAppAddressModel model) { var app = await APIService.ValidateAccessTokenAsync(model.AccessToken); if (app.AppId != model.AppId) { return(Json(new AiurProtocal { code = ErrorType.Unauthorized, message = "The app you try to delete is not the accesstoken you granted!" })); } _dbContext.OSSFile.RemoveRange(_dbContext.OSSFile.Include(t => t.BelongingBucket).Where(t => t.BelongingBucket.BelongingAppId == app.AppId)); _dbContext.Bucket.RemoveRange(_dbContext.Bucket.Where(t => t.BelongingAppId == app.AppId)); _dbContext.Apps.Remove(await _dbContext.Apps.FindAsync(app.AppId)); await _dbContext.SaveChangesAsync(); return(Json(new AiurProtocal { code = ErrorType.Success, message = "Successfully deleted that app and all files." })); }
public async Task <IActionResult> DeleteApp(DeleteAppAddressModel model) { var appid = _tokenManager.ValidateAccessToken(model.AccessToken); if (appid != model.AppId) { return(this.Protocol(ErrorType.Unauthorized, "The app you try to delete is not the access token you granted!")); } var target = await _dbContext.Apps.FindAsync(appid); if (target != null) { _dbContext.Folders.Delete(t => target.Sites.Select(p => p.FolderId).Contains(t.Id)); _dbContext.Sites.Delete(t => t.AppId == appid); _dbContext.Apps.Remove(target); await _dbContext.SaveChangesAsync(); return(this.Protocol(ErrorType.Success, "Successfully deleted that app and all sites.")); } return(this.Protocol(ErrorType.HasDoneAlready, "That app do not exists in our database.")); }
public async Task <JsonResult> DeleteApp(DeleteAppAddressModel model) { var appid = _tokenManager.ValidateAccessToken(model.AccessToken); if (appid != model.AppId) { return(this.Protocol(ErrorType.Unauthorized, "The app you try to delete is not the access token you granted!")); } var target = await _dbContext.Apps.FindAsync(appid); if (target != null) { _dbContext.OSSFile.RemoveRange(_dbContext.OSSFile.Include(t => t.BelongingBucket).Where(t => t.BelongingBucket.BelongingAppId == target.AppId)); _dbContext.Bucket.Delete(t => t.BelongingAppId == target.AppId); _dbContext.Apps.Remove(target); await _dbContext.SaveChangesAsync(); return(this.Protocol(ErrorType.Success, "Successfully deleted that app and all files.")); } return(this.Protocol(ErrorType.HasDoneAlready, "That app do not exists in our database.")); }