generated from NetCoreTemplates/blazor-vue
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
81 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,37 @@ | ||
using System.Data; | ||
using Microsoft.Extensions.Logging; | ||
using ServiceStack; | ||
using ServiceStack.OrmLite; | ||
using MyApp.Data; | ||
using MyApp.ServiceModel; | ||
using ServiceStack.Jobs; | ||
|
||
namespace MyApp.ServiceInterface.App; | ||
|
||
[Worker(Databases.App)] | ||
[Tag(Tags.Answers)] | ||
public class DeleteAnswersCommand(IDbConnection db) : SyncCommand<DeleteAnswers> | ||
public class DeleteAnswersCommand(ILogger<DeleteAnswersCommand> logger, IBackgroundJobs jobs, IDbConnection db) | ||
: SyncCommand<DeleteAnswers> | ||
{ | ||
protected override void Run(DeleteAnswers request) | ||
{ | ||
var log = Request.CreateJobLogger(jobs,logger); | ||
foreach (var refId in request.Ids) | ||
{ | ||
db.Delete<Vote>(x => x.RefId == refId); | ||
db.DeleteById<Post>(refId); | ||
db.Delete<StatTotals>(x => x.Id == refId); | ||
db.Delete<Notification>(x => x.RefId == refId); | ||
db.Delete<PostEmail>(x => x.RefId == refId); | ||
try | ||
{ | ||
log.LogInformation("Deleting answer {RefId}...", refId); | ||
|
||
db.Delete<Vote>(x => x.RefId == refId); | ||
db.DeleteById<Post>(refId); | ||
db.Delete<StatTotals>(x => x.Id == refId); | ||
db.Delete<Notification>(x => x.RefId == refId); | ||
db.Delete<PostEmail>(x => x.RefId == refId); | ||
} | ||
catch (Exception e) | ||
{ | ||
log.LogError(e, "Failed to delete Answer {RefId}: {Message}", refId, e.Message); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,40 @@ | ||
using System.Data; | ||
using Microsoft.Extensions.Logging; | ||
using ServiceStack; | ||
using ServiceStack.OrmLite; | ||
using MyApp.Data; | ||
using MyApp.ServiceModel; | ||
using ServiceStack.Jobs; | ||
|
||
namespace MyApp.ServiceInterface.App; | ||
|
||
[Worker(Databases.App)] | ||
[Tag(Tags.Database)] | ||
public class DeletePostsCommand(AppConfig appConfig, IDbConnection db) | ||
public class DeletePostsCommand(ILogger<DeleteAnswersCommand> logger, IBackgroundJobs jobs, | ||
AppConfig appConfig, IDbConnection db) | ||
: SyncCommand<DeletePosts> | ||
{ | ||
protected override void Run(DeletePosts request) | ||
{ | ||
var log = Request.CreateJobLogger(jobs,logger); | ||
foreach (var postId in request.Ids) | ||
{ | ||
db.Delete<Vote>(x => x.PostId == postId); | ||
db.DeleteById<Post>(postId); | ||
db.Delete<StatTotals>(x => x.PostId == postId); | ||
db.Delete<Notification>(x => x.PostId == postId); | ||
db.Delete<WatchPost>(x => x.PostId == postId); | ||
db.Delete<PostEmail>(x => x.PostId == postId); | ||
appConfig.ResetInitialPostId(db); | ||
try | ||
{ | ||
log.LogInformation("Deleting Question {Id}...", postId); | ||
|
||
db.Delete<Vote>(x => x.PostId == postId); | ||
db.DeleteById<Post>(postId); | ||
db.Delete<StatTotals>(x => x.PostId == postId); | ||
db.Delete<Notification>(x => x.PostId == postId); | ||
db.Delete<WatchPost>(x => x.PostId == postId); | ||
db.Delete<PostEmail>(x => x.PostId == postId); | ||
appConfig.ResetInitialPostId(db); | ||
} | ||
catch (Exception e) | ||
{ | ||
log.LogError(e, "Failed to delete Question {Id}: {Message}", postId, e.Message); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters