-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Exploring storage and persistence options
* starting with BlazorDB
- Loading branch information
Showing
11 changed files
with
179 additions
and
7 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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
@page "/tryblazordb" | ||
|
||
@inject Context Context | ||
|
||
<h1>Try BlazorDB</h1> | ||
|
||
<p><textarea rows="5" cols="80" readonly="readonly" bind="@_accountList"></textarea></p> | ||
|
||
@*<p>Current count: @currentCount</p>*@ | ||
|
||
<button class="btn btn-primary" onclick="@ListAccounts">List Accounts</button> | ||
<button class="btn btn-primary" onclick="@CreateAccount">Create Account</button> | ||
<button class="btn btn-primary" onclick="@CreateAccount">Create Account</button> | ||
|
||
@functions | ||
{ | ||
//int currentCount = 0; | ||
string _accountList; | ||
|
||
void ListAccounts() | ||
{ | ||
var l = ""; | ||
foreach (var acct in Context.Accounts) | ||
{ | ||
l += $"{acct.Id}:{acct.Details.Kid}:{string.Join(",", acct.Details.Payload.Contact)}\r\n"; | ||
} | ||
_accountList = l; | ||
} | ||
|
||
void CreateAccount() | ||
{ | ||
var acct = new BlazorAccount | ||
{ | ||
Details = new AccountDetails | ||
{ | ||
Kid = Guid.NewGuid().ToString(), //"https://acme-staging-v02.api.letsencrypt.org/acme/acct/6440557", | ||
TosLink = "https://www.google.com/", | ||
Payload = new ACMESharp.Protocol.Resources.Account | ||
{ | ||
Id = "6440557", | ||
Contact = new[] | ||
{ | ||
"mailto:[email protected]", | ||
"mailto:[email protected]", | ||
}, | ||
Status = "StillGoing!", | ||
Key = new | ||
{ | ||
kty = "EC", | ||
crv = "P-256", | ||
x = "4yLZoZQdYHrypdiZudPDL649wBDmR4YjG2DHxX7MZEU", | ||
y = "rUvtY-AnB4eihRyFaqwwbDGM6ZNtVjFuepPweFuDp3c", | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
Context.Accounts.Add(acct); | ||
Context.SaveChanges(); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using ACMESharp.Protocol; | ||
|
||
namespace ACMEBlazor.Services | ||
{ | ||
public interface IRepository | ||
{ | ||
Task<AccountDetails> GetAccount(); | ||
} | ||
|
||
public class Repository : IRepository | ||
{ | ||
public async Task<AccountDetails> GetAccount() | ||
{ | ||
return null; | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel.DataAnnotations; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using ACMESharp.Protocol; | ||
|
||
namespace ACMEBlazor.Storage | ||
{ | ||
public class BlazorAccount | ||
{ | ||
public int Id { get; set; } | ||
|
||
[Required] | ||
public AccountDetails Details { 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,20 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel.DataAnnotations; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using ACMESharp.Protocol; | ||
|
||
namespace ACMEBlazor.Storage | ||
{ | ||
public class BlazorOrder | ||
{ | ||
public int Id { get; set; } | ||
|
||
[Required] | ||
public BlazorAccount Account { get; set; } | ||
|
||
[Required] | ||
public OrderDetails Details { 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,15 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using ACMESharp.Protocol; | ||
using BlazorDB; | ||
|
||
namespace ACMEBlazor.Storage | ||
{ | ||
public class Context : StorageContext | ||
{ | ||
public StorageSet<BlazorAccount> Accounts { get; set; } | ||
public StorageSet<BlazorOrder> Orders { 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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
@using System.Net.Http | ||
@using System.Net.Http | ||
@using Microsoft.AspNetCore.Blazor.Layouts | ||
@using Microsoft.AspNetCore.Blazor.Routing | ||
@using ACMEBlazor | ||
@using ACMEBlazor.Shared | ||
@using ACMEBlazor.Storage |