Skip to content

Commit f21bff5

Browse files
.NET 8 (#125)
* Features/upgrate to dotnet 6 (#108) * Moved files to src; Adapted C# code to a more modern approach; Minor refactoring everywhere * Removed old project folders/files * Removed temporary old solution * Refactored code; Set some members to nullable * Changed usage on TryUpdateModelAsync * Features/fix email bugs (#110) * Moved files to src; Adapted C# code to a more modern approach; Minor refactoring everywhere * Removed old project folders/files * Removed temporary old solution * Refactored code; Set some members to nullable * Changed usage on TryUpdateModelAsync * Fixed e-mail issues * Features/fix email bugs (#112) * Moved files to src; Adapted C# code to a more modern approach; Minor refactoring everywhere * Removed old project folders/files * Removed temporary old solution * Refactored code; Set some members to nullable * Changed usage on TryUpdateModelAsync * Fixed e-mail issues * Feature/fix email send issues (#114) * Removed development files * Updated .gitignore * Added MailKit library * Implemented e-mail sender with MailKit * Feature/minor changes (#116) * Updated nuget packages * Improved HtmlHelperExtensions logic and added possibility to use with slugs * Added "About me" menu item * Feature/code improvements (#117) * Add possibility to use global.json * Add global.json file with targeting SDK 6.0.403 * Removed warnings * Add exclusion of generated code * Exclude Identity pages from null check * Update packages; Add ardalis.GuardClauses * Remove warnings * Remove null warnings; Minor code improvements * Fixed post not being saved * Fixed post not being saved * Add filter to prevent articles to appear before publishing time * Add filter to prevent articles to appear before publishing time * Add about me and subscribe; Reorder menu * Add Author partial view * Change DateTime format * Add SASS package * Reduce padding; Add max-height of 100% * Minor improvements (#118) * Develop (#113) * Features/upgrate to dotnet 6 (#108) * Moved files to src; Adapted C# code to a more modern approach; Minor refactoring everywhere * Removed old project folders/files * Removed temporary old solution * Refactored code; Set some members to nullable * Changed usage on TryUpdateModelAsync * Features/fix email bugs (#110) * Moved files to src; Adapted C# code to a more modern approach; Minor refactoring everywhere * Removed old project folders/files * Removed temporary old solution * Refactored code; Set some members to nullable * Changed usage on TryUpdateModelAsync * Fixed e-mail issues * Features/fix email bugs (#112) * Moved files to src; Adapted C# code to a more modern approach; Minor refactoring everywhere * Removed old project folders/files * Removed temporary old solution * Refactored code; Set some members to nullable * Changed usage on TryUpdateModelAsync * Fixed e-mail issues * Bugfix for e-mail sending (#115) * Features/upgrate to dotnet 6 (#108) * Moved files to src; Adapted C# code to a more modern approach; Minor refactoring everywhere * Removed old project folders/files * Removed temporary old solution * Refactored code; Set some members to nullable * Changed usage on TryUpdateModelAsync * Features/fix email bugs (#110) * Moved files to src; Adapted C# code to a more modern approach; Minor refactoring everywhere * Removed old project folders/files * Removed temporary old solution * Refactored code; Set some members to nullable * Changed usage on TryUpdateModelAsync * Fixed e-mail issues * Features/fix email bugs (#112) * Moved files to src; Adapted C# code to a more modern approach; Minor refactoring everywhere * Removed old project folders/files * Removed temporary old solution * Refactored code; Set some members to nullable * Changed usage on TryUpdateModelAsync * Fixed e-mail issues * Feature/fix email send issues (#114) * Removed development files * Updated .gitignore * Added MailKit library * Implemented e-mail sender with MailKit * Feature/remove contact form (#120) * Add empty connection strings * Removed Contact form and references * Redirected contact route to index * Feature/fix merge issues (#121) * Remove duplicate subscribe link * Feature/optimizations (#123) * Remove dotnet-tools * Remove .config folder * Set CmsEngine.Ui to run out of process * Upgrade to .NET 7 * Code refactor * Code refactor * Make repository and services disposable * Feature/upgrade to dotnet 8 (#124) * .NET upgrade * Code refactor
1 parent 8044fb7 commit f21bff5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+513
-616
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -260,4 +260,5 @@ package-lock.json
260260
*.Development.json
261261
[Rr]eadme.md
262262
CmsEngine.Ui/_logs
263-
global.json
263+
global.json
264+
.config/

global.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"sdk": {
3-
"version": "6.0.403"
3+
"version": "8.0.100"
44
}
55
}
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Ardalis.GuardClauses" Version="4.0.1" />
11-
<PackageReference Include="MailKit" Version="3.4.3" />
12-
<PackageReference Include="Microsoft.AspNetCore.Authentication.Abstractions" Version="2.2.0" />
13-
<PackageReference Include="Microsoft.AspNetCore.Mvc.ViewFeatures" Version="2.2.0" />
14-
<PackageReference Include="System.Drawing.Common" Version="6.0.0" />
10+
<PackageReference Include="Ardalis.GuardClauses" Version="4.2.0" />
11+
<PackageReference Include="MailKit" Version="4.3.0" />
12+
<PackageReference Include="System.Drawing.Common" Version="8.0.0" />
1513
</ItemGroup>
1614

1715
<ItemGroup>
1816
<ProjectReference Include="..\CmsEngine.Core\CmsEngine.Core.csproj" />
1917
<ProjectReference Include="..\CmsEngine.Data\CmsEngine.Data.csproj" />
2018
</ItemGroup>
2119

20+
<ItemGroup>
21+
<FrameworkReference Include="Microsoft.AspNetCore.App" />
22+
</ItemGroup>
2223
</Project>

src/CmsEngine.Application/Extensions/EnumerableExtensions.cs

+5-11
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,12 @@ public static class EnumerableExtensions
44
{
55
public static Expression<Func<T, bool>>? GetSearchExpression<T>(this IEnumerable<T> element, string searchValue, IEnumerable<PropertyInfo> properties)
66
{
7-
var expressionFilter = new List<ExpressionFilter>();
8-
9-
foreach (var property in properties)
7+
var expressionFilter = properties.Select(property => new ExpressionFilter
108
{
11-
expressionFilter.Add(new ExpressionFilter
12-
{
13-
PropertyName = property.Name,
14-
Operation = Operation.Contains,
15-
Value = searchValue
16-
});
17-
}
18-
9+
PropertyName = property.Name,
10+
Operation = Operation.Contains,
11+
Value = searchValue
12+
}).ToList();
1913
return ExpressionBuilder.GetExpression<T>(expressionFilter, LogicalOperator.Or);
2014
}
2115

src/CmsEngine.Application/Extensions/Mapper/ApplicationUserExtension.cs

+8-15
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ public static UserEditModel MapToEditModel(this ApplicationUser item)
1414
VanityId = Guid.Parse(item.Id),
1515
Name = item.Name,
1616
Surname = item.Surname,
17-
Email = item.Email,
18-
UserName = item.UserName
17+
Email = item.Email ?? string.Empty,
18+
UserName = item.UserName ?? string.Empty
1919
};
2020
}
2121

@@ -43,20 +43,13 @@ public static UserViewModel MapToViewModel(this ApplicationUser item)
4343
/// <returns></returns>
4444
public static IEnumerable<UserViewModel> MapToViewModelSimple(this IEnumerable<ApplicationUser> users)
4545
{
46-
var viewModels = new List<UserViewModel>();
47-
48-
foreach (var item in users)
46+
return users.Select(item => new UserViewModel
4947
{
50-
viewModels.Add(new UserViewModel
51-
{
52-
Name = item.Name,
53-
Surname = item.Surname,
54-
Email = item.Email,
55-
UserName = item.UserName
56-
});
57-
}
58-
59-
return viewModels;
48+
Name = item.Name,
49+
Surname = item.Surname,
50+
Email = item.Email,
51+
UserName = item.UserName
52+
}).ToList();
6053
}
6154

6255
/// <summary>

src/CmsEngine.Application/Extensions/Mapper/CategoryExtensions.cs

+38-73
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,14 @@ public static Category MapToModel(this CategoryEditModel item, Category category
6060
/// <returns></returns>
6161
public static IEnumerable<CategoryTableViewModel> MapToTableViewModel(this IEnumerable<Category> categories)
6262
{
63-
var tableViewModel = new List<CategoryTableViewModel>();
64-
65-
foreach (var item in categories)
63+
return categories.Select(item => new CategoryTableViewModel
6664
{
67-
tableViewModel.Add(new CategoryTableViewModel
68-
{
69-
Id = item.Id,
70-
VanityId = item.VanityId,
71-
Name = item.Name,
72-
Description = item.Description,
73-
Slug = item.Slug
74-
});
75-
}
76-
77-
return tableViewModel;
65+
Id = item.Id,
66+
VanityId = item.VanityId,
67+
Name = item.Name,
68+
Description = item.Description,
69+
Slug = item.Slug
70+
}).ToList();
7871
}
7972

8073
/// <summary>
@@ -84,22 +77,15 @@ public static IEnumerable<CategoryTableViewModel> MapToTableViewModel(this IEnum
8477
/// <returns></returns>
8578
public static IEnumerable<CategoryViewModel> MapToViewModel(this IEnumerable<Category> categories, string dateFormat)
8679
{
87-
var viewModel = new List<CategoryViewModel>();
88-
89-
foreach (var item in categories)
80+
return categories.Select(item => new CategoryViewModel
9081
{
91-
viewModel.Add(new CategoryViewModel
92-
{
93-
Id = item.Id,
94-
VanityId = item.VanityId,
95-
Name = item.Name,
96-
Description = item.Description,
97-
Slug = item.Slug,
98-
Posts = item.PostCategories?.Select(x => x.Post).MapToViewModel(dateFormat)
99-
});
100-
}
101-
102-
return viewModel;
82+
Id = item.Id,
83+
VanityId = item.VanityId,
84+
Name = item.Name,
85+
Description = item.Description,
86+
Slug = item.Slug,
87+
Posts = item.PostCategories?.Select(x => x.Post).MapToViewModel(dateFormat)
88+
}).ToList();
10389
}
10490

10591
/// <summary>
@@ -109,19 +95,12 @@ public static IEnumerable<CategoryViewModel> MapToViewModel(this IEnumerable<Cat
10995
/// <returns></returns>
11096
public static IEnumerable<CategoryViewModel> MapToViewModelSimple(this IEnumerable<Category> categories)
11197
{
112-
var viewModel = new List<CategoryViewModel>();
113-
114-
foreach (var item in categories)
98+
return categories.Select(item => new CategoryViewModel
11599
{
116-
viewModel.Add(new CategoryViewModel
117-
{
118-
VanityId = item.VanityId,
119-
Name = item.Name,
120-
Slug = item.Slug
121-
});
122-
}
123-
124-
return viewModel;
100+
VanityId = item.VanityId,
101+
Name = item.Name,
102+
Slug = item.Slug
103+
}).ToList();
125104
}
126105

127106
/// <summary>
@@ -131,20 +110,13 @@ public static IEnumerable<CategoryViewModel> MapToViewModelSimple(this IEnumerab
131110
/// <returns></returns>
132111
public static IEnumerable<CategoryViewModel> MapToViewModelWithPostCount(this IEnumerable<Category> categories)
133112
{
134-
var viewModel = new List<CategoryViewModel>();
135-
136-
foreach (var item in categories)
113+
return categories.Select(item => new CategoryViewModel
137114
{
138-
viewModel.Add(new CategoryViewModel
139-
{
140-
VanityId = item.VanityId,
141-
Name = item.Name,
142-
Slug = item.Slug,
143-
PostCount = item.PostCount
144-
});
145-
}
146-
147-
return viewModel;
115+
VanityId = item.VanityId,
116+
Name = item.Name,
117+
Slug = item.Slug,
118+
PostCount = item.PostCount
119+
}).ToList();
148120
}
149121

150122
/// <summary>
@@ -154,26 +126,19 @@ public static IEnumerable<CategoryViewModel> MapToViewModelWithPostCount(this IE
154126
/// <returns></returns>
155127
public static IEnumerable<CategoryViewModel> MapToViewModelWithPost(this IEnumerable<Category> categories, string dateFormat)
156128
{
157-
var viewModel = new List<CategoryViewModel>();
158-
159-
foreach (var item in categories)
129+
return categories.Select(item => new CategoryViewModel
160130
{
161-
viewModel.Add(new CategoryViewModel
131+
VanityId = item.VanityId,
132+
Name = item.Name,
133+
Slug = item.Slug,
134+
Posts = item.Posts.Select(p => new PostViewModel
162135
{
163-
VanityId = item.VanityId,
164-
Name = item.Name,
165-
Slug = item.Slug,
166-
Posts = item.Posts.Select(p => new PostViewModel
167-
{
168-
VanityId = p.VanityId,
169-
Title = p.Title,
170-
Description = p.Description,
171-
Slug = p.Slug,
172-
PublishedOn = p.PublishedOn.ToString(dateFormat)
173-
})
174-
});
175-
}
176-
177-
return viewModel;
136+
VanityId = p.VanityId,
137+
Title = p.Title,
138+
Description = p.Description,
139+
Slug = p.Slug,
140+
PublishedOn = p.PublishedOn.ToString(dateFormat)
141+
})
142+
}).ToList();
178143
}
179144
}

src/CmsEngine.Application/Extensions/Mapper/ContactFormExtension.cs

+1-8
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,7 @@ public static Email MapToModel(this ContactForm item)
2424
/// <returns></returns>
2525
public static IEnumerable<ContactForm> MapToViewModel(this IEnumerable<Email> emails)
2626
{
27-
var viewModel = new List<ContactForm>();
28-
29-
foreach (var item in emails)
30-
{
31-
viewModel.Add(new ContactForm(item.From, item.Subject, item.Message));
32-
}
33-
34-
return viewModel;
27+
return emails.Select(item => new ContactForm(item.From, item.Subject, item.Message)).ToList();
3528
}
3629

3730
}

src/CmsEngine.Application/Extensions/Mapper/PageExtensions.cs

+31-52
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,18 @@ public static PageEditModel MapToEditModel(this Page item)
3030
/// <returns></returns>
3131
public static IEnumerable<PageEditModel> MapToEditModel(this IEnumerable<Page> pages)
3232
{
33-
var editModels = new List<PageEditModel>();
34-
35-
foreach (var item in pages)
33+
return pages.Select(item => new PageEditModel
3634
{
37-
editModels.Add(new PageEditModel
38-
{
39-
Id = item.Id,
40-
VanityId = item.VanityId,
41-
Title = item.Title,
42-
Slug = item.Slug,
43-
Description = item.Description,
44-
DocumentContent = item.DocumentContent,
45-
HeaderImage = item.HeaderImage,
46-
PublishedOn = item.PublishedOn,
47-
Status = item.Status
48-
});
49-
}
50-
51-
return editModels;
35+
Id = item.Id,
36+
VanityId = item.VanityId,
37+
Title = item.Title,
38+
Slug = item.Slug,
39+
Description = item.Description,
40+
DocumentContent = item.DocumentContent,
41+
HeaderImage = item.HeaderImage,
42+
PublishedOn = item.PublishedOn,
43+
Status = item.Status
44+
}).ToList();
5245
}
5346

5447
/// <summary>
@@ -100,23 +93,16 @@ public static Page MapToModel(this PageEditModel item, Page page)
10093
/// <returns></returns>
10194
public static IEnumerable<PageTableViewModel> MapToTableViewModel(this IEnumerable<Page> pages)
10295
{
103-
var tableViewModel = new List<PageTableViewModel>();
104-
105-
foreach (var item in pages)
96+
return pages.Select(item => new PageTableViewModel
10697
{
107-
tableViewModel.Add(new PageTableViewModel
108-
{
109-
VanityId = item.VanityId,
110-
Title = item.Title,
111-
Description = item.Description,
112-
Slug = item.Slug,
113-
PublishedOn = item.PublishedOn.ToString("yyyy-MM-dd HH:mm:ss"),
114-
Status = item.Status,
115-
Author = item.ApplicationUsers.MapToViewModelSimple().Single()
116-
});
117-
}
118-
119-
return tableViewModel;
98+
VanityId = item.VanityId,
99+
Title = item.Title,
100+
Description = item.Description,
101+
Slug = item.Slug,
102+
PublishedOn = item.PublishedOn.ToString("yyyy-MM-dd HH:mm:ss"),
103+
Status = item.Status,
104+
Author = item.ApplicationUsers.MapToViewModelSimple().Single()
105+
}).ToList();
120106
}
121107

122108
/// <summary>
@@ -146,25 +132,18 @@ public static PageViewModel MapToViewModel(this Page item, string dateFormat)
146132
/// <returns></returns>
147133
public static IEnumerable<PageViewModel> MapToViewModel(this IEnumerable<Page> pages, string dateFormat)
148134
{
149-
var editModels = new List<PageViewModel>();
150-
151-
foreach (var item in pages)
135+
return pages.Select(item => new PageViewModel
152136
{
153-
editModels.Add(new PageViewModel
154-
{
155-
Id = item.Id,
156-
VanityId = item.VanityId,
157-
Title = item.Title,
158-
Slug = item.Slug,
159-
Description = item.Description,
160-
DocumentContent = item.DocumentContent,
161-
HeaderImage = item.HeaderImage,
162-
PublishedOn = item.PublishedOn.ToString(dateFormat),
163-
Status = item.Status
164-
});
165-
}
166-
167-
return editModels;
137+
Id = item.Id,
138+
VanityId = item.VanityId,
139+
Title = item.Title,
140+
Slug = item.Slug,
141+
Description = item.Description,
142+
DocumentContent = item.DocumentContent,
143+
HeaderImage = item.HeaderImage,
144+
PublishedOn = item.PublishedOn.ToString(dateFormat),
145+
Status = item.Status
146+
}).ToList();
168147
}
169148

170149
}

0 commit comments

Comments
 (0)