Added entry saving support

This commit is contained in:
2025-01-15 20:43:57 +01:00
parent d4018cceec
commit 1cf2b44503
11 changed files with 285 additions and 76 deletions

View File

@@ -23,7 +23,8 @@ Welcome to your new Fluent Blazor app.
Id = Guid.CreateVersion7(),
FirstName = first,
LastName = last,
Username = username
Username = username,
Password = GenerateName(Random.Shared.Next(8, 16))
};
Context.Users.Add(user);

View File

@@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace HopFrame.Testing.Models;
@@ -15,5 +16,13 @@ public class Post {
[ForeignKey("author")]
public User? Author { get; set; }
public bool Published { get; set; }
/*public bool Published { get; set; }
public DateTime CreatedAt { get; set; }
public DateOnly Created { get; set; }
public TimeOnly At { get; set; }*/
public ListSortDirection Type { get; set; }
}

View File

@@ -24,7 +24,8 @@ builder.Services.AddHopFrame(options => {
options.AddDbContext<DatabaseContext>(context => {
context.Table<User>(table => {
table.Property(u => u.Password)
.List(false);
.List(false)
.DisplayValue(false);
table.Property(u => u.FirstName)
.SetDisplayName("First Name");
@@ -33,20 +34,17 @@ builder.Services.AddHopFrame(options => {
.SetDisplayName("Last Name");
table.Property(u => u.Id)
.Sortable(false);
.Sortable(false)
.ValueTemplate(Guid.CreateVersion7);
});
/* context.Table<Post>()
.Property(p => p.Author)
.DisplayedProperty(u => u!.Username); */
context.Table<Post>()
.Property(p => p.Author)
.Format(user => $"{user?.FirstName} {user?.LastName}");
context.Table<Post>()
.Property(p => p.Id)
.SetDisplayName("ID")
.Editable(true);
.SetDisplayName("ID");
});
});