Skip to content

Commit 7129626

Browse files
committed
Migrating to BlazorToolkit nuget package
1 parent 6be5266 commit 7129626

File tree

14 files changed

+107
-153
lines changed

14 files changed

+107
-153
lines changed

DevInstance.DevCoreApp.sln

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EmailProcessor", "src\Serve
3535
EndProject
3636
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shared.Services", "src\Shared\Services\Shared.Services.csproj", "{92C1A160-4F63-4B6A-897E-2088EEC67F7A}"
3737
EndProject
38-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DevInstance.BlazorToolkit", "..\..\..\..\devinstance\BlazorToolkit\DevInstance.BlazorToolkit.csproj", "{7E2FFB83-B6BD-4FA8-ACF6-8DAF812F51BD}"
39-
EndProject
4038
Global
4139
GlobalSection(SolutionConfigurationPlatforms) = preSolution
4240
Debug|Any CPU = Debug|Any CPU
@@ -133,14 +131,6 @@ Global
133131
{92C1A160-4F63-4B6A-897E-2088EEC67F7A}.Release|Any CPU.Build.0 = Release|Any CPU
134132
{92C1A160-4F63-4B6A-897E-2088EEC67F7A}.ServiceMoqs|Any CPU.ActiveCfg = Debug|Any CPU
135133
{92C1A160-4F63-4B6A-897E-2088EEC67F7A}.ServiceMoqs|Any CPU.Build.0 = Debug|Any CPU
136-
{7E2FFB83-B6BD-4FA8-ACF6-8DAF812F51BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
137-
{7E2FFB83-B6BD-4FA8-ACF6-8DAF812F51BD}.Debug|Any CPU.Build.0 = Debug|Any CPU
138-
{7E2FFB83-B6BD-4FA8-ACF6-8DAF812F51BD}.NetApiMoqs|Any CPU.ActiveCfg = NetApiMoqs|Any CPU
139-
{7E2FFB83-B6BD-4FA8-ACF6-8DAF812F51BD}.NetApiMoqs|Any CPU.Build.0 = NetApiMoqs|Any CPU
140-
{7E2FFB83-B6BD-4FA8-ACF6-8DAF812F51BD}.Release|Any CPU.ActiveCfg = Release|Any CPU
141-
{7E2FFB83-B6BD-4FA8-ACF6-8DAF812F51BD}.Release|Any CPU.Build.0 = Release|Any CPU
142-
{7E2FFB83-B6BD-4FA8-ACF6-8DAF812F51BD}.ServiceMoqs|Any CPU.ActiveCfg = ServiceMoqs|Any CPU
143-
{7E2FFB83-B6BD-4FA8-ACF6-8DAF812F51BD}.ServiceMoqs|Any CPU.Build.0 = ServiceMoqs|Any CPU
144134
EndGlobalSection
145135
GlobalSection(SolutionProperties) = preSolution
146136
HideSolutionNode = FALSE
@@ -159,7 +149,6 @@ Global
159149
{29CA0DBB-3B16-41DA-9F75-10CD1F820B65} = {0F781128-F35F-4891-B0C5-D7EDCAB6582F}
160150
{7609E010-1A0A-4181-A840-84C6723EC47F} = {0F781128-F35F-4891-B0C5-D7EDCAB6582F}
161151
{92C1A160-4F63-4B6A-897E-2088EEC67F7A} = {C8D232B9-D9F5-49EF-94E6-62D4D286D0D5}
162-
{7E2FFB83-B6BD-4FA8-ACF6-8DAF812F51BD} = {B7DBCFFA-D9E5-4E4D-A8AF-37800E9F6E6E}
163152
EndGlobalSection
164153
GlobalSection(ExtensibilityGlobals) = postSolution
165154
SolutionGuid = {90D2632F-45AE-4664-8699-41C525356109}

src/Client/Client.Services/CRUDService.cs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@ public CRUDService(IApiContext<T> api)
2222
{
2323
using (var log = Log.TraceScope())
2424
{
25-
return await ServiceUtils.HandleWebApiCallAsync(log,
25+
return await ServiceUtils.HandleWebApiCallAsync(
2626
async (l) =>
2727
{
2828
var api = Api.Get(id);
2929

3030
return await api.ExecuteAsync();
31-
}
31+
},
32+
log
3233
);
3334
}
3435
}
@@ -42,7 +43,7 @@ public void SetDataUpdate(T item)
4243
{
4344
using (var log = Log.TraceScope())
4445
{
45-
return await ServiceUtils.HandleWebApiCallAsync(log,
46+
return await ServiceUtils.HandleWebApiCallAsync(
4647
async (l) =>
4748
{
4849
var response = await Api.Post(item).ExecuteAsync();
@@ -51,7 +52,8 @@ public void SetDataUpdate(T item)
5152
OnDataUpdate?.Invoke(response);
5253
}
5354
return response;
54-
}
55+
},
56+
log
5557
);
5658
}
5759
}
@@ -60,7 +62,7 @@ public void SetDataUpdate(T item)
6062
{
6163
using (var log = Log.TraceScope())
6264
{
63-
return await ServiceUtils.HandleWebApiCallAsync(log,
65+
return await ServiceUtils.HandleWebApiCallAsync(
6466
async (l) =>
6567
{
6668
var response = await Api.Put(item.Id, item).ExecuteAsync();
@@ -69,7 +71,8 @@ public void SetDataUpdate(T item)
6971
OnDataUpdate?.Invoke(response);
7072
}
7173
return response;
72-
}
74+
},
75+
log
7376
);
7477
}
7578
}
@@ -78,7 +81,7 @@ public async Task<ServiceActionResult<bool>> RemoveAsync(T item)
7881
{
7982
using (var log = Log.TraceScope())
8083
{
81-
return await ServiceUtils.HandleWebApiCallAsync(log,
84+
return await ServiceUtils.HandleWebApiCallAsync(
8285
async (l) =>
8386
{
8487
var response = await Api.Delete(item.Id).ExecuteAsync();
@@ -87,7 +90,8 @@ public async Task<ServiceActionResult<bool>> RemoveAsync(T item)
8790
OnDataUpdate?.Invoke(default(T));
8891
}
8992
return true;
90-
}
93+
},
94+
log
9195
);
9296
}
9397
}

src/Client/Client.Services/Client.Services.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<PackageReference Include="DevInstance.LogScope" Version="1.4.2" />
1414
<PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="8.0.11" />
1515
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.2" />
16-
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
16+
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.1" />
1717
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="8.0.11" />
1818
</ItemGroup>
1919

src/Client/Client.Services/Net/NetApiRepository.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ public class NetApiRepository : INetApiRepository
1313
public NetApiRepository(IHttpClientFactory factory, NavigationManager navigationManager)
1414
{
1515
httpFactory = factory;
16-
//httpFactory.BaseAddress = new Uri(navigationManager.BaseUri);
1716
}
1817

1918
HttpClient HttpClient => httpFactory.CreateClient("DevInstance.DevCoreApp.ServerAPI");

src/Client/Client.Services/WeatherForecastService.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public WeatherForecastService(INetApiRepository api, IScopeManager lp)
2323
{
2424
using (var log = Log.TraceScope())
2525
{
26-
return await ServiceUtils.HandleWebApiCallAsync(log,
26+
return await ServiceUtils.HandleWebApiCallAsync(
2727
async (l) =>
2828
{
2929
var api = Api.GetWeatherForecastApi().Get();
@@ -41,7 +41,8 @@ public WeatherForecastService(INetApiRepository api, IScopeManager lp)
4141
}
4242

4343
return await api.ListAsync();
44-
}
44+
},
45+
log
4546
);
4647
}
4748
}

src/Client/DevCoreApp.Client/DevCoreApp.Client.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@
1111
</PropertyGroup>
1212

1313
<ItemGroup>
14+
<PackageReference Include="DevInstance.BlazorToolkit" Version="8.0.1" />
1415
<PackageReference Include="DevInstance.LogScope.NET" Version="1.4.2" />
1516
<PackageReference Include="FluentValidation" Version="11.9.2" />
1617
<PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="8.0.11" />
1718
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.11" />
1819
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="8.0.11" />
1920
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.2" />
20-
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
21+
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.1" />
2122
<PackageReference Include="Microsoft.Extensions.Localization" Version="8.0.8" />
2223
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="8.0.11" />
2324
</ItemGroup>
2425

2526
<ItemGroup>
26-
<ProjectReference Include="..\..\..\..\..\..\..\devinstance\BlazorToolkit\DevInstance.BlazorToolkit.csproj" />
2727
<ProjectReference Include="..\Client.Services\Client.Services.csproj" />
2828
</ItemGroup>
2929

src/Server/Database/Core/ApplicationDbContext.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using DevInstance.DevCoreApp.Server.Database.Core.Models;
1+
using DevInstance.BlazorToolkit.Utils;
2+
using DevInstance.DevCoreApp.Server.Database.Core.Models;
23
using DevInstance.DevCoreApp.Shared.Utils;
34
using Microsoft.AspNetCore.Identity;
45
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;

src/Server/Database/Core/Data/Queries/BasicsImplementation/CoreUserProfilesQuery.cs

Lines changed: 82 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -6,106 +6,106 @@
66
using System;
77
using System.Linq;
88
using System.Threading.Tasks;
9+
using DevInstance.BlazorToolkit.Utils;
910

10-
namespace NoCrast.Server.Database.Postgres.Data.Queries
11+
namespace NoCrast.Server.Database.Postgres.Data.Queries;
12+
13+
public class CoreUserProfilesQuery : CoreBaseQuery, IUserProfilesQuery
1114
{
12-
public class CoreUserProfilesQuery : CoreBaseQuery, IUserProfilesQuery
15+
private IQueryable<UserProfile> currentQuery;
16+
17+
private CoreUserProfilesQuery(IQueryable<UserProfile> q, IScopeManager logManager,
18+
ITimeProvider timeProvider,
19+
ApplicationDbContext dB,
20+
UserProfile currentProfile)
21+
: base(logManager, timeProvider, dB, currentProfile)
1322
{
14-
private IQueryable<UserProfile> currentQuery;
23+
currentQuery = q;
24+
}
1525

16-
private CoreUserProfilesQuery(IQueryable<UserProfile> q, IScopeManager logManager,
17-
ITimeProvider timeProvider,
18-
ApplicationDbContext dB,
19-
UserProfile currentProfile)
20-
: base(logManager, timeProvider, dB, currentProfile)
21-
{
22-
currentQuery = q;
23-
}
24-
25-
public CoreUserProfilesQuery(IScopeManager logManager,
26-
ITimeProvider timeProvider,
27-
ApplicationDbContext dB,
28-
UserProfile currentProfile)
29-
: this(from ts in dB.UserProfiles
30-
select ts, logManager, timeProvider, dB, currentProfile)
31-
{
26+
public CoreUserProfilesQuery(IScopeManager logManager,
27+
ITimeProvider timeProvider,
28+
ApplicationDbContext dB,
29+
UserProfile currentProfile)
30+
: this(from ts in dB.UserProfiles
31+
select ts, logManager, timeProvider, dB, currentProfile)
32+
{
3233

33-
}
34+
}
3435

35-
public async Task AddAsync(UserProfile record)
36-
{
37-
DB.UserProfiles.Add(record);
38-
await DB.SaveChangesAsync();
39-
}
36+
public async Task AddAsync(UserProfile record)
37+
{
38+
DB.UserProfiles.Add(record);
39+
await DB.SaveChangesAsync();
40+
}
4041

41-
public IUserProfilesQuery ByName(string name)
42-
{
43-
currentQuery = from pr in currentQuery
44-
where pr.Name == name
45-
select pr;
42+
public IUserProfilesQuery ByName(string name)
43+
{
44+
currentQuery = from pr in currentQuery
45+
where pr.Name == name
46+
select pr;
4647

47-
return this;
48-
}
48+
return this;
49+
}
4950

50-
public IUserProfilesQuery ByPublicId(string id)
51-
{
52-
currentQuery = from pr in currentQuery
53-
where pr.PublicId == id
54-
select pr;
51+
public IUserProfilesQuery ByPublicId(string id)
52+
{
53+
currentQuery = from pr in currentQuery
54+
where pr.PublicId == id
55+
select pr;
5556

56-
return this;
57-
}
57+
return this;
58+
}
5859

59-
public IUserProfilesQuery Clone()
60-
{
61-
return new CoreUserProfilesQuery(currentQuery, LogManager, TimeProvider, DB, CurrentProfile);
62-
}
60+
public IUserProfilesQuery Clone()
61+
{
62+
return new CoreUserProfilesQuery(currentQuery, LogManager, TimeProvider, DB, CurrentProfile);
63+
}
6364

64-
public UserProfile CreateNew()
65-
{
66-
DateTime now = TimeProvider.CurrentTime;
67-
68-
return new UserProfile
69-
{
70-
Id = Guid.NewGuid(),
71-
PublicId = IdGenerator.New(),
72-
CreateDate = now,
73-
UpdateDate = now,
74-
};
75-
}
76-
77-
public async Task RemoveAsync(UserProfile record)
78-
{
79-
DB.UserProfiles.Remove(record);
80-
await DB.SaveChangesAsync();
81-
}
65+
public UserProfile CreateNew()
66+
{
67+
DateTime now = TimeProvider.CurrentTime;
8268

83-
public IQueryable<UserProfile> Select()
69+
return new UserProfile
8470
{
85-
return (from pr in currentQuery select pr);
86-
}
71+
Id = Guid.NewGuid(),
72+
PublicId = IdGenerator.New(),
73+
CreateDate = now,
74+
UpdateDate = now,
75+
};
76+
}
8777

88-
public async Task UpdateAsync(UserProfile record)
89-
{
90-
DateTime now = TimeProvider.CurrentTime;
78+
public async Task RemoveAsync(UserProfile record)
79+
{
80+
DB.UserProfiles.Remove(record);
81+
await DB.SaveChangesAsync();
82+
}
83+
84+
public IQueryable<UserProfile> Select()
85+
{
86+
return (from pr in currentQuery select pr);
87+
}
9188

92-
record.UpdateDate = now;
93-
DB.UserProfiles.Update(record);
94-
await DB.SaveChangesAsync();
95-
}
89+
public async Task UpdateAsync(UserProfile record)
90+
{
91+
DateTime now = TimeProvider.CurrentTime;
9692

97-
public IUserProfilesQuery ByApplicationUserId(Guid id)
98-
{
99-
currentQuery = from pr in currentQuery
100-
where pr.ApplicationUserId == id
101-
select pr;
93+
record.UpdateDate = now;
94+
DB.UserProfiles.Update(record);
95+
await DB.SaveChangesAsync();
96+
}
10297

103-
return this;
104-
}
98+
public IUserProfilesQuery ByApplicationUserId(Guid id)
99+
{
100+
currentQuery = from pr in currentQuery
101+
where pr.ApplicationUserId == id
102+
select pr;
105103

106-
public IUserProfilesQuery Search(string search)
107-
{
108-
throw new NotImplementedException();
109-
}
104+
return this;
105+
}
106+
107+
public IUserProfilesQuery Search(string search)
108+
{
109+
throw new NotImplementedException();
110110
}
111111
}

src/Server/Database/Core/Data/Queries/BasicsImplementation/CoreWeatherForecastQuery.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System;
77
using System.Linq;
88
using System.Threading.Tasks;
9+
using DevInstance.BlazorToolkit.Utils;
910

1011
namespace NoCrast.Server.Database.Postgres.Data.Queries;
1112

src/Server/Database/SqlServer/SqlServer.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
</ItemGroup>
1919

2020
<ItemGroup>
21+
<PackageReference Include="Azure.Identity" Version="1.10.3" />
2122
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.8" />
2223
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.8">
2324
<PrivateAssets>all</PrivateAssets>

0 commit comments

Comments
 (0)