diff --git a/CS/.idea/.idea.InstantFeedback/.idea/.gitignore b/CS/.idea/.idea.InstantFeedback/.idea/.gitignore new file mode 100644 index 0000000..38eed0c --- /dev/null +++ b/CS/.idea/.idea.InstantFeedback/.idea/.gitignore @@ -0,0 +1,15 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Rider ignored files +/.idea.InstantFeedback.iml +/projectSettingsUpdater.xml +/modules.xml +/contentModel.xml +# Ignored default folder with query files +/queries/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/CS/.idea/.idea.InstantFeedback/.idea/.name b/CS/.idea/.idea.InstantFeedback/.idea/.name new file mode 100644 index 0000000..f2b9612 --- /dev/null +++ b/CS/.idea/.idea.InstantFeedback/.idea/.name @@ -0,0 +1 @@ +InstantFeedback \ No newline at end of file diff --git a/CS/.idea/.idea.InstantFeedback/.idea/indexLayout.xml b/CS/.idea/.idea.InstantFeedback/.idea/indexLayout.xml new file mode 100644 index 0000000..7b08163 --- /dev/null +++ b/CS/.idea/.idea.InstantFeedback/.idea/indexLayout.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/CS/.idea/.idea.InstantFeedback/.idea/vcs.xml b/CS/.idea/.idea.InstantFeedback/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/CS/.idea/.idea.InstantFeedback/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/CS/InstantFeedback.csproj b/CS/InstantFeedback.csproj index bf047da..d99ccfb 100644 --- a/CS/InstantFeedback.csproj +++ b/CS/InstantFeedback.csproj @@ -5,7 +5,7 @@ enable - + diff --git a/CS/Pages/Grid.razor b/CS/Pages/Grid.razor index 4b9457b..91fbd2f 100644 --- a/CS/Pages/Grid.razor +++ b/CS/Pages/Grid.razor @@ -3,23 +3,32 @@ @using InstantFeedback.Models; - - - - - - + + + + + + @{ + var issue = (ServerMode.IssueWithUser)context.EditModel; + } + + - - - + + + @@ -30,5 +39,5 @@ public object Issues { get; set; } [Parameter] - public IEnumerable Users { get; set; } + public IEnumerable Users { get; set; } } diff --git a/CS/Pages/LocalData.razor b/CS/Pages/LocalData.razor deleted file mode 100644 index c80dc59..0000000 --- a/CS/Pages/LocalData.razor +++ /dev/null @@ -1,17 +0,0 @@ -@page "/localdata" -@using InstantFeedback.Models; -@using Microsoft.EntityFrameworkCore; -@inject IssuesContext Context - - - -@code { - IEnumerable issues { get; set; } - IEnumerable users; - - protected override void OnInitialized() - { - issues = Context.Issues.ToList(); - users = Context.Users.ToList(); - } -} \ No newline at end of file diff --git a/CS/Pages/ServerMode.razor b/CS/Pages/ServerMode.razor index a7b8fa8..188d2dc 100644 --- a/CS/Pages/ServerMode.razor +++ b/CS/Pages/ServerMode.razor @@ -8,21 +8,43 @@ @code { - EntityInstantFeedbackSource instantFeedbackSource { get; set; } - IEnumerable users; + GridDevExtremeDataSource instantFeedbackSource { get; set; } + IEnumerable users; - protected override void OnInitialized() - { - instantFeedbackSource = new EntityInstantFeedbackSource(e => - { - e.KeyExpression = "Id"; - e.QueryableSource = Context.Issues; + protected override void OnInitialized() { + var userQuery = Context.Issues.Include("User").Select(i => new IssueWithUser { + Id = i.Id, + Subject = i.Subject, + User = new UserInfo { + Id = i.UserId, + FullName = i.User.FirstName + " " + i.User.LastName, + }, + Created = i.Created, + Votes = i.Votes, + Priority = i.Priority, + }); + instantFeedbackSource = new GridDevExtremeDataSource(userQuery); + users = Context.Users.Select(u => new UserInfo { + Id = u.Id, + FullName = u.FullName }); - users = Context.Users.ToList(); } public void Dispose() { - instantFeedbackSource?.Dispose(); } + public class IssueWithUser { + public int Id { get; set; } + public string Subject { get; set; } + public UserInfo User { get; set; } + public DateTime Created { get; set; } + public int Votes { get; set; } + public Priority Priority { get; set; } + } + public class UserInfo { + public int Id { get; set; } + public string FullName { get; set; } + } + } + diff --git a/CS/Program.cs b/CS/Program.cs index 9660510..f143535 100644 --- a/CS/Program.cs +++ b/CS/Program.cs @@ -13,13 +13,13 @@ options.SizeMode = DevExpress.Blazor.SizeMode.Medium; }); -//builder.Services.AddDbContext((sp, options) => -//{ -// var env = sp.GetRequiredService(); -// var dbPath = Path.Combine(env.ContentRootPath, "Issues.mdf"); -// options.UseSqlServer("Server=(localdb)\\MSSQLLocalDB;Integrated Security=true;AttachDbFileName=" + dbPath); -//}, contextLifetime: ServiceLifetime.Transient); -builder.Services.AddDbContext((sp, options) => options.UseInMemoryDatabase("Issues"), contextLifetime: ServiceLifetime.Transient); +builder.Services.AddDbContext((sp, options) => +{ + var env = sp.GetRequiredService(); + var dbPath = Path.Combine(env.ContentRootPath, "Issues.mdf"); + options.UseSqlServer("Server=(localdb)\\MSSQLLocalDB;Integrated Security=true;AttachDbFileName=" + dbPath); +}, contextLifetime: ServiceLifetime.Transient); +// builder.Services.AddDbContext((sp, options) => options.UseInMemoryDatabase("Issues"), contextLifetime: ServiceLifetime.Transient); builder.Services.AddTransient(); diff --git a/CS/appsettings.Development.json b/CS/appsettings.Development.json index 770d3e9..f760d7b 100644 --- a/CS/appsettings.Development.json +++ b/CS/appsettings.Development.json @@ -3,7 +3,9 @@ "Logging": { "LogLevel": { "Default": "Information", - "Microsoft.AspNetCore": "Warning" + "Microsoft.AspNetCore": "Warning", + "Microsoft.EntityFrameworkCore.Database.Command": "Information", + "Microsoft.EntityFrameworkCore": "Information" } } }