Skip to content

Commit 5278dbd

Browse files
committed
Streaming 20 Aug 2021
0 parents  commit 5278dbd

File tree

70 files changed

+1371
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1371
-0
lines changed

.idea/.idea.IOKode.Cloe/.idea/.gitignore

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/.idea.IOKode.Cloe/.idea/encodings.xml

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/.idea.IOKode.Cloe/.idea/indexLayout.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net5.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<ProjectReference Include="..\IOKode.Cloe.Domain\IOKode.Cloe.Domain.csproj" />
10+
</ItemGroup>
11+
12+
</Project>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using System.Threading;
2+
using System.Threading.Tasks;
3+
4+
namespace IOKode.Cloe.Application
5+
{
6+
public interface IUnitOfWork
7+
{
8+
public TRepository GetRepository<TRepository>();
9+
public Task CommitAsync(CancellationToken cancellationToken);
10+
}
11+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using IOKode.Cloe.Domain;
4+
using IOKode.Cloe.Domain.Entities;
5+
6+
namespace IOKode.Cloe.Application.Posts.Models
7+
{
8+
public record CreatePostModel
9+
{
10+
public Id<User> AuthorId { get; set; }
11+
public string Title { get; set; }
12+
public string SearcherTitle { get; set; }
13+
public string SearcherDescription { get; set; }
14+
public string Content { get; set; }
15+
public DateTime? PublishDate { get; set; }
16+
public IEnumerable<string> Keywords { get; set; }
17+
}
18+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
using System.Collections.Generic;
3+
4+
namespace IOKode.Cloe.Application.Posts.Models
5+
{
6+
public record UpdatePostModel
7+
{
8+
public string Title { get; set; }
9+
public string SearcherTitle { get; set; }
10+
public string SearcherDescription { get; set; }
11+
public string Content { get; set; }
12+
public DateTime? PublishDate { get; set; }
13+
public IEnumerable<string> Keywords { get; set; }
14+
}
15+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using System;
2+
using System.Linq;
3+
using System.Threading;
4+
using System.Threading.Tasks;
5+
using IOKode.Cloe.Application.Posts.Models;
6+
using IOKode.Cloe.Application.Repositories;
7+
using IOKode.Cloe.Domain.Entities;
8+
9+
namespace IOKode.Cloe.Application.Posts.UseCases
10+
{
11+
public class CreatePostUseCase
12+
{
13+
private readonly IUnitOfWork _UnitOfWork;
14+
15+
public CreatePostUseCase(IUnitOfWork unitOfWork)
16+
{
17+
_UnitOfWork = unitOfWork;
18+
}
19+
20+
public async Task InvokeAsync(CreatePostModel model, CancellationToken cancellationToken)
21+
{
22+
var post = new Post
23+
{
24+
CreationDate = DateTime.Now,
25+
UpdateDate = DateTime.Now,
26+
Title = model.Title,
27+
SearcherTitle = model.SearcherTitle,
28+
SearcherDescription = model.SearcherDescription,
29+
Content = model.Content,
30+
Keywords = model.Keywords.ToList(),
31+
PublishDate = model.PublishDate,
32+
AuthorId = model.AuthorId
33+
};
34+
35+
var repository = _UnitOfWork.GetRepository<IPostRepository>();
36+
await repository.AddAsync(post, cancellationToken);
37+
await _UnitOfWork.CommitAsync(cancellationToken);
38+
}
39+
}
40+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System.Threading;
2+
using System.Threading.Tasks;
3+
using IOKode.Cloe.Application.Repositories;
4+
using IOKode.Cloe.Domain;
5+
using IOKode.Cloe.Domain.Entities;
6+
7+
namespace IOKode.Cloe.Application.Posts.UseCases
8+
{
9+
public class DeletePostUseCase
10+
{
11+
private readonly IUnitOfWork _UnitOfWork;
12+
13+
public DeletePostUseCase(IUnitOfWork unitOfWork)
14+
{
15+
_UnitOfWork = unitOfWork;
16+
}
17+
18+
public async Task InvokeAsync(Id<Post> id, CancellationToken cancellationToken)
19+
{
20+
var repository = _UnitOfWork.GetRepository<IPostRepository>();
21+
await repository.DeleteAsync(id, cancellationToken);
22+
23+
await _UnitOfWork.CommitAsync(cancellationToken);
24+
}
25+
}
26+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using System;
2+
using System.Linq;
3+
using System.Threading;
4+
using System.Threading.Tasks;
5+
using IOKode.Cloe.Application.Posts.Models;
6+
using IOKode.Cloe.Application.Repositories;
7+
using IOKode.Cloe.Domain;
8+
using IOKode.Cloe.Domain.Entities;
9+
10+
namespace IOKode.Cloe.Application.Posts.UseCases
11+
{
12+
public class UpdatePostUseCase
13+
{
14+
private readonly IUnitOfWork _UnitOfWork;
15+
16+
public UpdatePostUseCase(IUnitOfWork unitOfWork)
17+
{
18+
_UnitOfWork = unitOfWork;
19+
}
20+
21+
public async Task InvokeAsync(Id<Post> id, UpdatePostModel model, CancellationToken cancellationToken)
22+
{
23+
var repository = _UnitOfWork.GetRepository<IPostRepository>();
24+
var post = await repository.GetByIdAsync(id, cancellationToken);
25+
26+
post.Title = model.Title;
27+
post.SearcherTitle = model.SearcherTitle;
28+
post.SearcherDescription = model.SearcherDescription;
29+
post.Content = model.Content;
30+
post.PublishDate = model.PublishDate;
31+
post.UpdateDate = DateTime.Now;
32+
post.Keywords = model.Keywords.ToList();
33+
34+
await _UnitOfWork.CommitAsync(cancellationToken);
35+
}
36+
}
37+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System.Threading;
2+
using System.Threading.Tasks;
3+
using IOKode.Cloe.Domain;
4+
using IOKode.Cloe.Domain.Entities;
5+
6+
namespace IOKode.Cloe.Application.Repositories
7+
{
8+
public interface IPostRepository
9+
{
10+
public Task AddAsync(Post post, CancellationToken cancellationToken);
11+
public Task<Post> GetByIdAsync(Id<Post> id, CancellationToken cancellationToken);
12+
public Task DeleteAsync(Id<Post> id, CancellationToken cancellationToken);
13+
14+
public async Task DeleteAsync(Post post, CancellationToken cancellationToken)
15+
{
16+
await DeleteAsync(post.Id, cancellationToken);
17+
}
18+
}
19+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// <autogenerated />
2+
using System;
3+
using System.Reflection;
4+
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v5.0", FrameworkDisplayName = "")]
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//------------------------------------------------------------------------------
2+
// <auto-generated>
3+
// This code was generated by a tool.
4+
//
5+
// Changes to this file may cause incorrect behavior and will be lost if
6+
// the code is regenerated.
7+
// </auto-generated>
8+
//------------------------------------------------------------------------------
9+
10+
using System;
11+
using System.Reflection;
12+
13+
[assembly: System.Reflection.AssemblyCompanyAttribute("IOKode.Cloe.Application")]
14+
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
15+
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
16+
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
17+
[assembly: System.Reflection.AssemblyProductAttribute("IOKode.Cloe.Application")]
18+
[assembly: System.Reflection.AssemblyTitleAttribute("IOKode.Cloe.Application")]
19+
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
20+
21+
// Generated by the MSBuild WriteCodeFragment class.
22+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1c6057558c509f0da419fab669a823c665258e44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
is_global = true
2+
build_property.TargetFramework = net5.0
3+
build_property.TargetPlatformMinVersion =
4+
build_property.UsingMicrosoftNETSdkWeb =
5+
build_property.ProjectTypeGuids =
6+
build_property.InvariantGlobalization =
7+
build_property.PlatformNeutralAssembly =
8+
build_property._SupportedPlatformList = Linux,macOS,Windows
9+
build_property.RootNamespace = IOKode.Cloe.Application
10+
build_property.ProjectDir = /Users/monty/RiderProjects/IOKode.Cloe/IOKode.Cloe.Application/
Binary file not shown.
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
{
2+
"format": 1,
3+
"restore": {
4+
"/Users/monty/RiderProjects/IOKode.Cloe/IOKode.Cloe.Application/IOKode.Cloe.Application.csproj": {}
5+
},
6+
"projects": {
7+
"/Users/monty/RiderProjects/IOKode.Cloe/IOKode.Cloe.Application/IOKode.Cloe.Application.csproj": {
8+
"version": "1.0.0",
9+
"restore": {
10+
"projectUniqueName": "/Users/monty/RiderProjects/IOKode.Cloe/IOKode.Cloe.Application/IOKode.Cloe.Application.csproj",
11+
"projectName": "IOKode.Cloe.Application",
12+
"projectPath": "/Users/monty/RiderProjects/IOKode.Cloe/IOKode.Cloe.Application/IOKode.Cloe.Application.csproj",
13+
"packagesPath": "/Users/monty/.nuget/packages/",
14+
"outputPath": "/Users/monty/RiderProjects/IOKode.Cloe/IOKode.Cloe.Application/obj/",
15+
"projectStyle": "PackageReference",
16+
"configFilePaths": [
17+
"/Users/monty/.nuget/NuGet/NuGet.Config"
18+
],
19+
"originalTargetFrameworks": [
20+
"net5.0"
21+
],
22+
"sources": {
23+
"/usr/local/share/dotnet/library-packs": {},
24+
"https://api.nuget.org/v3/index.json": {}
25+
},
26+
"frameworks": {
27+
"net5.0": {
28+
"targetAlias": "net5.0",
29+
"projectReferences": {
30+
"/Users/monty/RiderProjects/IOKode.Cloe/IOKode.Cloe.Domain/IOKode.Cloe.Domain.csproj": {
31+
"projectPath": "/Users/monty/RiderProjects/IOKode.Cloe/IOKode.Cloe.Domain/IOKode.Cloe.Domain.csproj"
32+
}
33+
}
34+
}
35+
},
36+
"warningProperties": {
37+
"warnAsError": [
38+
"NU1605"
39+
]
40+
}
41+
},
42+
"frameworks": {
43+
"net5.0": {
44+
"targetAlias": "net5.0",
45+
"imports": [
46+
"net461",
47+
"net462",
48+
"net47",
49+
"net471",
50+
"net472",
51+
"net48"
52+
],
53+
"assetTargetFallback": true,
54+
"warn": true,
55+
"frameworkReferences": {
56+
"Microsoft.NETCore.App": {
57+
"privateAssets": "all"
58+
}
59+
},
60+
"runtimeIdentifierGraphPath": "/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/RuntimeIdentifierGraph.json"
61+
}
62+
}
63+
},
64+
"/Users/monty/RiderProjects/IOKode.Cloe/IOKode.Cloe.Domain/IOKode.Cloe.Domain.csproj": {
65+
"version": "1.0.0",
66+
"restore": {
67+
"projectUniqueName": "/Users/monty/RiderProjects/IOKode.Cloe/IOKode.Cloe.Domain/IOKode.Cloe.Domain.csproj",
68+
"projectName": "IOKode.Cloe.Domain",
69+
"projectPath": "/Users/monty/RiderProjects/IOKode.Cloe/IOKode.Cloe.Domain/IOKode.Cloe.Domain.csproj",
70+
"packagesPath": "/Users/monty/.nuget/packages/",
71+
"outputPath": "/Users/monty/RiderProjects/IOKode.Cloe/IOKode.Cloe.Domain/obj/",
72+
"projectStyle": "PackageReference",
73+
"configFilePaths": [
74+
"/Users/monty/.nuget/NuGet/NuGet.Config"
75+
],
76+
"originalTargetFrameworks": [
77+
"net5.0"
78+
],
79+
"sources": {
80+
"/usr/local/share/dotnet/library-packs": {},
81+
"https://api.nuget.org/v3/index.json": {}
82+
},
83+
"frameworks": {
84+
"net5.0": {
85+
"targetAlias": "net5.0",
86+
"projectReferences": {}
87+
}
88+
},
89+
"warningProperties": {
90+
"warnAsError": [
91+
"NU1605"
92+
]
93+
}
94+
},
95+
"frameworks": {
96+
"net5.0": {
97+
"targetAlias": "net5.0",
98+
"imports": [
99+
"net461",
100+
"net462",
101+
"net47",
102+
"net471",
103+
"net472",
104+
"net48"
105+
],
106+
"assetTargetFallback": true,
107+
"warn": true,
108+
"frameworkReferences": {
109+
"Microsoft.NETCore.App": {
110+
"privateAssets": "all"
111+
}
112+
},
113+
"runtimeIdentifierGraphPath": "/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/RuntimeIdentifierGraph.json"
114+
}
115+
}
116+
}
117+
}
118+
}

0 commit comments

Comments
 (0)