-
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.
Prefer async/await over returning Task
- Loading branch information
1 parent
6a4135d
commit 3b761d3
Showing
9 changed files
with
30 additions
and
18 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,14 +1,18 @@ | ||
using Couple.Client.Data; | ||
using Couple.Client.Model.Issue; | ||
using Microsoft.JSInterop; | ||
|
||
namespace Couple.Client.Services.Synchronizer; | ||
|
||
public class CreateIssueCommand : ICommand | ||
{ | ||
private readonly IJSRuntime _js; | ||
private readonly AppDbContext _dbContext; | ||
private readonly IssueModel _model; | ||
|
||
public CreateIssueCommand(IJSRuntime js, IssueModel model) => (_js, _model) = (js, model); | ||
public CreateIssueCommand(AppDbContext dbContext, IssueModel model) => (_dbContext, _model) = (dbContext, model); | ||
|
||
public Task Execute() => _js.InvokeVoidAsync("createIssue", _model).AsTask(); | ||
public async Task Execute() | ||
{ | ||
_dbContext.Issues.Add(_model); | ||
await _dbContext.SaveChangesAsync(); | ||
} | ||
} |
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,13 +1,17 @@ | ||
using Microsoft.JSInterop; | ||
using Couple.Client.Data; | ||
|
||
namespace Couple.Client.Services.Synchronizer; | ||
|
||
public class DeleteIssueCommand : ICommand | ||
{ | ||
private readonly AppDbContext _dbContext; | ||
private readonly Guid _guid; | ||
private readonly IJSRuntime _js; | ||
|
||
public DeleteIssueCommand(IJSRuntime js, Guid guid) => (_js, _guid) = (js, guid); | ||
public DeleteIssueCommand(AppDbContext dbContext, Guid guid) => (_dbContext, _guid) = (dbContext, guid); | ||
|
||
public Task Execute() => _js.InvokeVoidAsync("deleteIssue", _guid).AsTask(); | ||
public async Task Execute() | ||
{ | ||
_dbContext.Issues.Remove(new() { Id = _guid }); | ||
await _dbContext.SaveChangesAsync(); | ||
} | ||
} |
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,14 +1,18 @@ | ||
using Couple.Client.Data; | ||
using Couple.Client.Model.Issue; | ||
using Microsoft.JSInterop; | ||
|
||
namespace Couple.Client.Services.Synchronizer; | ||
|
||
public class UpdateIssueCommand : ICommand | ||
{ | ||
private readonly IJSRuntime _js; | ||
private readonly AppDbContext _dbContext; | ||
private readonly IssueModel _model; | ||
|
||
public UpdateIssueCommand(IJSRuntime js, IssueModel model) => (_js, _model) = (js, model); | ||
public UpdateIssueCommand(AppDbContext dbContext, IssueModel model) => (_dbContext, _model) = (dbContext, model); | ||
|
||
public Task Execute() => _js.InvokeVoidAsync("updateIssue", _model).AsTask(); | ||
public async Task Execute() | ||
{ | ||
_dbContext.Issues.Update(_model); | ||
await _dbContext.SaveChangesAsync(); | ||
} | ||
} |
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