Started working on frontend
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
using HopFrame.Core;
|
||||
using HopFrame.Core.EFCore;
|
||||
using HopFrame.Web;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using TestApplication;
|
||||
using TestApplication.Components;
|
||||
using TestApplication.Models;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
@@ -10,13 +11,23 @@ var builder = WebApplication.CreateBuilder(args);
|
||||
builder.Services.AddRazorComponents()
|
||||
.AddInteractiveServerComponents();
|
||||
|
||||
builder.Services.AddEntityFrameworkInMemoryDatabase();
|
||||
builder.Services.AddDbContext<DatabaseContext>(options => {
|
||||
options.UseInMemoryDatabase("testing");
|
||||
});
|
||||
|
||||
builder.Services.AddHopFrame(config => {
|
||||
config.AddDbContext<DatabaseContext>();
|
||||
|
||||
config.Table<User>(table => {
|
||||
table.SetDescription("The user dataset. It contains all information for the users of the application.");
|
||||
|
||||
table.Property(u => u.Password)
|
||||
.Listable(false);
|
||||
});
|
||||
|
||||
config.Table<Post>(table => {
|
||||
table.SetDescription("The posts dataset. It contains all posts sent via the application.");
|
||||
});
|
||||
});
|
||||
|
||||
var app = builder.Build();
|
||||
@@ -28,6 +39,27 @@ if (!app.Environment.IsDevelopment()) {
|
||||
app.UseHsts();
|
||||
}
|
||||
|
||||
await using (var scope = app.Services.CreateAsyncScope()) {
|
||||
var context = scope.ServiceProvider.GetRequiredService<DatabaseContext>();
|
||||
|
||||
foreach (var _ in Enumerable.Range(1, 100)) {
|
||||
var firstName = Faker.Name.First();
|
||||
var lastName = Faker.Name.Last();
|
||||
|
||||
context.Users.Add(new() {
|
||||
Email = $"{firstName}.{lastName}@gmail.com".ToLower(),
|
||||
Username = $"{firstName}.{lastName}".ToLower(),
|
||||
FirstName = firstName,
|
||||
LastName = lastName,
|
||||
Description = Faker.Lorem.Paragraph(),
|
||||
Birth = DateOnly.FromDateTime(Faker.Identification.DateOfBirth()),
|
||||
Password = Faker.RandomNumber.Next(100000L, 99999999999999999L).ToString()
|
||||
});
|
||||
}
|
||||
|
||||
await context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
app.UseStatusCodePagesWithReExecute("/not-found", createScopeForStatusCodePages: true);
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
@@ -35,6 +67,7 @@ app.UseAntiforgery();
|
||||
|
||||
app.MapStaticAssets();
|
||||
app.MapRazorComponents<App>()
|
||||
.AddInteractiveServerRenderMode();
|
||||
.AddInteractiveServerRenderMode()
|
||||
.AddHopFrame();
|
||||
|
||||
app.Run();
|
||||
Reference in New Issue
Block a user