66 lines
2.0 KiB
Plaintext
66 lines
2.0 KiB
Plaintext
@page "/"
|
|
@using HopFrame.Testing.Models
|
|
@using Microsoft.EntityFrameworkCore
|
|
|
|
<PageTitle>Home</PageTitle>
|
|
|
|
<h1>Hello, world!</h1>
|
|
|
|
Welcome to your new Fluent Blazor app.
|
|
|
|
@inject DatabaseContext Context
|
|
|
|
@code {
|
|
|
|
protected override async Task OnInitializedAsync() {
|
|
User? user = null;
|
|
for (int i = 0; i < 100; i++) {
|
|
var first = GenerateName(Random.Shared.Next(4, 6));
|
|
var last = GenerateName(Random.Shared.Next(4, 6));
|
|
var username = $"{first}.{last}";
|
|
|
|
user = new() {
|
|
Email = $"{username}-{Random.Shared.Next(0, 20)}@gmail.com",
|
|
Id = Guid.CreateVersion7(),
|
|
FirstName = first,
|
|
LastName = last,
|
|
Username = username,
|
|
Password = GenerateName(Random.Shared.Next(8, 16))
|
|
};
|
|
|
|
Context.Users.Add(user);
|
|
}
|
|
|
|
await Context.SaveChangesAsync();
|
|
|
|
Context.Posts.Add(new() {
|
|
Caption = "Cool Post",
|
|
Content = "This post is cool",
|
|
Author = user
|
|
});
|
|
|
|
await Context.SaveChangesAsync();
|
|
}
|
|
|
|
public static string GenerateName(int len) {
|
|
Random r = new Random();
|
|
string[] consonants = { "b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "l", "n", "p", "q", "r", "s", "sh", "zh", "t", "v", "w", "x" };
|
|
string[] vowels = { "a", "e", "i", "o", "u", "ae", "y" };
|
|
string Name = "";
|
|
Name += consonants[r.Next(consonants.Length)].ToUpper();
|
|
Name += vowels[r.Next(vowels.Length)];
|
|
int b = 2; //b tells how many times a new letter has been added. It's 2 right now because the first two letters are already in the name.
|
|
while (b < len) {
|
|
Name += consonants[r.Next(consonants.Length)];
|
|
b++;
|
|
Name += vowels[r.Next(vowels.Length)];
|
|
b++;
|
|
}
|
|
|
|
return Name;
|
|
}
|
|
|
|
}
|
|
using HopFrame.Testing.Models;
|
|
using System.Runtime.InteropServices;
|