-
Notifications
You must be signed in to change notification settings - Fork 4
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
43 changed files
with
313 additions
and
127 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"sdk": { | ||
"version": "7.0.101" | ||
"version": "7.0.202" | ||
} | ||
} |
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
18 changes: 18 additions & 0 deletions
18
samples/MiruNext/src/MiruNext/Database/Migrations/202303312001_CreateTodos.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,18 @@ | ||
using FluentMigrator; | ||
using Miru.Behaviors.TimeStamp; | ||
using Miru.Databases.Migrations.FluentMigrator; | ||
|
||
namespace Corpo.Skeleton.Database.Migrations; | ||
|
||
[Migration(202303312001)] | ||
public class CreateTodos : AutoReversingMigration | ||
{ | ||
public override void Up() | ||
{ | ||
Create.Table("Todos") | ||
.WithColumn("Id").AsId() | ||
.WithColumn("Name").AsString(64) | ||
.WithColumn("UserId").AsForeignKeyReference("Users") | ||
.WithTimeStamps(); | ||
} | ||
} |
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,8 @@ | ||
using Miru.Domain; | ||
|
||
namespace MiruNext.Domain; | ||
|
||
public class Todo : Entity | ||
{ | ||
public string Name { get; set; } | ||
} |
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,25 @@ | ||
@model MiruNext.Features.Todos.TodoList.Result | ||
|
||
<h3>Todos</h3> | ||
|
||
<div class="my-3"> | ||
@* <a for="@(new TodoEdit)">Add</a> *@ | ||
</div> | ||
|
||
<miru-table x="For(x => x.Todos)"> | ||
<thead> | ||
<tr> | ||
<miru-th x="For(x => x.Todos[0].Id)" /> | ||
<miru-th x="For(x => x.Todos[0].Name)" /> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
@foreach (var (_, i) in Model.Todos.Indexed()) | ||
{ | ||
<tr> | ||
<miru-td x="For(x => x.Todos[i].Id)" /> | ||
<miru-td x="For(x => x.Todos[i].Name)" /> | ||
</tr> | ||
} | ||
</tbody> | ||
</miru-table> |
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,3 @@ | ||
@model MiruNext.Features.Todos.TodoEdit.Command | ||
|
||
<partial name="Edit" model="@Model" /> |
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,82 @@ | ||
using System.Linq; | ||
using Microsoft.EntityFrameworkCore; | ||
using MiruNext.Database; | ||
|
||
namespace MiruNext.Features.Todos; | ||
|
||
public class TodoEdit | ||
{ | ||
public class Query | ||
{ | ||
} | ||
|
||
public class Command | ||
{ | ||
public long TodoId { get; set; } | ||
public string Name { get; set; } | ||
} | ||
|
||
public class Result | ||
{ | ||
public TodoView[] Todos { get; set; } = Array.Empty<TodoView>(); | ||
} | ||
|
||
public class TodoView | ||
{ | ||
public long Id { get; set; } | ||
public string Name { get; set; } | ||
} | ||
|
||
[HttpGet("/todos/{TodoId}")] | ||
public class Edit : Endpoint2<Query> | ||
{ | ||
private readonly AppDbContext _db; | ||
|
||
public Edit(AppDbContext db) => _db = db; | ||
|
||
public override async Task HandleAsync(Query request, CancellationToken ct) | ||
{ | ||
var result = new Result | ||
{ | ||
Todos = await _db.Todos | ||
.Select(x => new TodoView | ||
{ | ||
Id = x.Id, | ||
Name = x.Name | ||
}) | ||
.ToArrayAsync(ct) | ||
}; | ||
|
||
await RespondAsync(result); | ||
} | ||
|
||
// public override async Task HandleAsync(Command request, CancellationToken ct) | ||
// { | ||
// var result = new Result | ||
// { | ||
// Todos = await _db.Todos | ||
// .Select(x => new TodoView | ||
// { | ||
// Id = x.Id, | ||
// Name = x.Name | ||
// }) | ||
// .ToArrayAsync(ct) | ||
// }; | ||
// | ||
// await RespondAsync(result); | ||
// } | ||
} | ||
|
||
[HttpGet("/todos/new")] | ||
public class New : Endpoint2<Query> | ||
{ | ||
// private readonly AppDbContext _db; | ||
// | ||
// public New(AppDbContext db) => _db = db; | ||
|
||
public override async Task HandleAsync(Query request, CancellationToken ct) | ||
{ | ||
await RespondAsync(new Command()); | ||
} | ||
} | ||
} |
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,50 @@ | ||
using System.Linq; | ||
using Microsoft.EntityFrameworkCore; | ||
using MiruNext.Database; | ||
|
||
namespace MiruNext.Features.Todos; | ||
|
||
public class TodoList | ||
{ | ||
public class Query | ||
{ | ||
} | ||
|
||
public class Result | ||
{ | ||
public TodoView[] Todos { get; set; } = Array.Empty<TodoView>(); | ||
} | ||
|
||
public class TodoView | ||
{ | ||
public long Id { get; set; } | ||
public string Name { get; set; } | ||
} | ||
|
||
[HttpGet("/Todos")] | ||
public class List : Endpoint2<Query> | ||
{ | ||
private readonly AppDbContext _db; | ||
|
||
public List(AppDbContext db) | ||
{ | ||
_db = db; | ||
} | ||
|
||
public override async Task HandleAsync(Query request, CancellationToken ct) | ||
{ | ||
var result = new Result | ||
{ | ||
Todos = await _db.Todos | ||
.Select(x => new TodoView | ||
{ | ||
Id = x.Id, | ||
Name = x.Name | ||
}) | ||
.ToArrayAsync(ct) | ||
}; | ||
|
||
await RespondAsync(result); | ||
} | ||
} | ||
} |
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
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
Oops, something went wrong.