generated from nventive/Template
-
Notifications
You must be signed in to change notification settings - Fork 10
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
5 changed files
with
68 additions
and
54 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
41 changes: 41 additions & 0 deletions
41
src/app/ApplicationTemplate.Presentation/ViewModels/Posts/PostItemViewModel.cs
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using ApplicationTemplate.Business; | ||
using Chinook.DynamicMvvm; | ||
using Chinook.StackNavigation; | ||
|
||
namespace ApplicationTemplate.Presentation; | ||
|
||
/// <summary> | ||
/// Post item view model. | ||
/// </summary> | ||
public sealed class PostItemViewModel : ViewModel | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="PostItemViewModel"/> class. | ||
/// </summary> | ||
/// <param name="post">The post.</param> | ||
public PostItemViewModel(Post post) | ||
{ | ||
Post = post; | ||
} | ||
|
||
/// <summary> | ||
/// The post. | ||
/// </summary> | ||
public Post Post { get; } | ||
|
||
/// <summary> | ||
/// Deletes the post. | ||
/// </summary> | ||
public IDynamicCommand DeletePost => this.GetCommandFromTask(async (ct) => | ||
{ | ||
await this.GetService<IPostService>().Delete(ct, Post.Id); | ||
}); | ||
|
||
/// <summary> | ||
/// Navigates to the edit post page. | ||
/// </summary> | ||
public IDynamicCommand EditPost => this.GetCommandFromTask(async (ct) => | ||
{ | ||
await this.GetService<IStackNavigator>().Navigate(ct, () => new EditPostPageViewModel(Post)); | ||
}); | ||
} |
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