Skip to content

Commit 0b9bdf0

Browse files
Merge pull request #421 from NielsPilgaard/feature/posts
Feature/posts
2 parents d67a9f7 + 8e7b8f5 commit 0b9bdf0

File tree

62 files changed

+3438
-318
lines changed

Some content is hidden

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

62 files changed

+3438
-318
lines changed

.github/workflows/website_frontend_ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ env:
1414
jobs:
1515
playwright:
1616
# Only run this if the workflow that triggered it was successful
17-
if: ${{ github.event.workflow_run.conclusion == 'success' }}
17+
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
1818
runs-on: ubuntu-latest
1919
container:
20-
image: mcr.microsoft.com/playwright/dotnet:v1.50.0-jammy
20+
image: mcr.microsoft.com/playwright/dotnet:v1.54.0-jammy
2121
options: --user 1001
2222
steps:
2323
- name: Checkout

Jordnaer.sln

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,12 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 17
44
VisualStudioVersion = 17.0.31903.59
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{04718F38-85FB-4998-B2FF-AA5B8999BA5D}"
7-
EndProject
86
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{EF8561E8-6A1E-4ED0-851A-913EEC801AFA}"
97
ProjectSection(SolutionItems) = preProject
108
.editorconfig = .editorconfig
119
.gitignore = .gitignore
1210
Directory.Build.props = Directory.Build.props
1311
.github\workflows\github-release.yml = .github\workflows\github-release.yml
14-
.github\workflows\lighthouse.yml = .github\workflows\lighthouse.yml
1512
README.md = README.md
1613
.github\workflows\website_backend_ci.yml = .github\workflows\website_backend_ci.yml
1714
.github\workflows\website_cd.yml = .github\workflows\website_cd.yml
@@ -28,16 +25,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{29332986-7
2825
docs\invite.md = docs\invite.md
2926
EndProjectSection
3027
EndProject
31-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "web", "web", "{7326F14D-ADB6-4CB0-9AE4-2717133CED27}"
32-
EndProject
3328
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "benchmarks", "benchmarks", "{B7172579-75AE-4D50-9328-3B0D80252384}"
3429
EndProject
35-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "web", "web", "{B4EAF579-8327-4B92-8357-8FF12C21755F}"
36-
EndProject
37-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "shared", "shared", "{659DB215-49CE-4C57-8823-56AFAE2DED72}"
38-
EndProject
39-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Jordnaer.Shared.Infrastructure", "src\shared\Jordnaer.Shared.Infrastructure\Jordnaer.Shared.Infrastructure.csproj", "{73928908-776A-4AE3-98A7-AAB82A9A9C19}"
40-
EndProject
4130
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Jordnaer.Shared", "src\shared\Jordnaer.Shared\Jordnaer.Shared.csproj", "{41CAB9C0-E554-4F17-8C8D-AD50EF22B70B}"
4231
EndProject
4332
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Jordnaer.E2E.Tests", "tests\web\Jordnaer.E2E.Tests\Jordnaer.E2E.Tests.csproj", "{D17408FE-1231-4CEC-8C7F-773915B70242}"
@@ -54,10 +43,6 @@ Global
5443
Release|Any CPU = Release|Any CPU
5544
EndGlobalSection
5645
GlobalSection(ProjectConfigurationPlatforms) = postSolution
57-
{73928908-776A-4AE3-98A7-AAB82A9A9C19}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
58-
{73928908-776A-4AE3-98A7-AAB82A9A9C19}.Debug|Any CPU.Build.0 = Debug|Any CPU
59-
{73928908-776A-4AE3-98A7-AAB82A9A9C19}.Release|Any CPU.ActiveCfg = Release|Any CPU
60-
{73928908-776A-4AE3-98A7-AAB82A9A9C19}.Release|Any CPU.Build.0 = Release|Any CPU
6146
{41CAB9C0-E554-4F17-8C8D-AD50EF22B70B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
6247
{41CAB9C0-E554-4F17-8C8D-AD50EF22B70B}.Debug|Any CPU.Build.0 = Debug|Any CPU
6348
{41CAB9C0-E554-4F17-8C8D-AD50EF22B70B}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -83,14 +68,8 @@ Global
8368
HideSolutionNode = FALSE
8469
EndGlobalSection
8570
GlobalSection(NestedProjects) = preSolution
86-
{7326F14D-ADB6-4CB0-9AE4-2717133CED27} = {04718F38-85FB-4998-B2FF-AA5B8999BA5D}
87-
{B4EAF579-8327-4B92-8357-8FF12C21755F} = {3F3B23F8-EA95-44B5-B907-5E772A2660E2}
88-
{659DB215-49CE-4C57-8823-56AFAE2DED72} = {04718F38-85FB-4998-B2FF-AA5B8999BA5D}
89-
{73928908-776A-4AE3-98A7-AAB82A9A9C19} = {659DB215-49CE-4C57-8823-56AFAE2DED72}
90-
{41CAB9C0-E554-4F17-8C8D-AD50EF22B70B} = {659DB215-49CE-4C57-8823-56AFAE2DED72}
91-
{D17408FE-1231-4CEC-8C7F-773915B70242} = {B4EAF579-8327-4B92-8357-8FF12C21755F}
92-
{06B65FD2-ABF3-4D58-9655-375C0C57B3C3} = {7326F14D-ADB6-4CB0-9AE4-2717133CED27}
93-
{26821232-1D4D-4CA8-AA41-7605C42C373A} = {B4EAF579-8327-4B92-8357-8FF12C21755F}
71+
{D17408FE-1231-4CEC-8C7F-773915B70242} = {3F3B23F8-EA95-44B5-B907-5E772A2660E2}
72+
{26821232-1D4D-4CA8-AA41-7605C42C373A} = {3F3B23F8-EA95-44B5-B907-5E772A2660E2}
9473
{3C1DA78A-722B-485E-9D60-CC19ACFDA892} = {B7172579-75AE-4D50-9328-3B0D80252384}
9574
EndGlobalSection
9675
GlobalSection(ExtensibilityGlobals) = postSolution

benchmarks/Jordnaer.Benchmarks/Jordnaer.Benchmarks.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<ItemGroup>
1212
<PackageReference Include="BenchmarkDotNet" Version="0.15.2" />
1313
<PackageReference Include="Bogus" Version="35.6.3" />
14-
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="9.0.7" />
14+
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="9.0.8" />
1515
</ItemGroup>
1616

1717
<ItemGroup>

src/shared/Jordnaer.Shared.Infrastructure/Jordnaer.Shared.Infrastructure.csproj

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/shared/Jordnaer.Shared/Database/GroupCategory.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ namespace Jordnaer.Shared;
22

33
public class GroupCategory
44
{
5-
public required Guid GroupId { get; set; }
5+
public required Guid GroupId { get; set; }
66

7-
public required int CategoryId { get; set; }
7+
public required int CategoryId { get; set; }
88
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System.ComponentModel.DataAnnotations.Schema;
2+
using System.ComponentModel.DataAnnotations;
3+
4+
namespace Jordnaer.Shared;
5+
6+
public class GroupPost
7+
{
8+
9+
[Key]
10+
[DatabaseGenerated(DatabaseGeneratedOption.None)]
11+
public required Guid Id { get; init; }
12+
13+
[StringLength(1000, ErrorMessage = "Opslag må højest være 1000 karakterer lang.")]
14+
[Required(AllowEmptyStrings = false, ErrorMessage = "Opslag skal have mindst 1 karakter.")]
15+
public required string Text { get; init; }
16+
17+
public DateTimeOffset CreatedUtc { get; init; } = DateTimeOffset.UtcNow;
18+
19+
public int? ZipCode { get; set; }
20+
21+
[ForeignKey(nameof(UserProfile))]
22+
public required string UserProfileId { get; init; } = null!;
23+
24+
public UserProfile UserProfile { get; init; } = null!;
25+
26+
[ForeignKey(nameof(Group))]
27+
public required Guid GroupId { get; init; }
28+
29+
public Group Group { get; init; } = null!;
30+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System.ComponentModel.DataAnnotations;
2+
using System.ComponentModel.DataAnnotations.Schema;
3+
using Microsoft.EntityFrameworkCore;
4+
5+
namespace Jordnaer.Shared;
6+
7+
[Index(nameof(ZipCode))]
8+
public class Post
9+
{
10+
[Key]
11+
[DatabaseGenerated(DatabaseGeneratedOption.None)]
12+
public required Guid Id { get; init; }
13+
14+
[StringLength(1000, ErrorMessage = "Opslag må højest være 1000 karakterer lang.")]
15+
[Required(AllowEmptyStrings = false, ErrorMessage = "Opslag skal have mindst 1 karakter.")]
16+
public required string Text { get; set; }
17+
18+
public DateTimeOffset CreatedUtc { get; set; } = DateTimeOffset.UtcNow;
19+
20+
public int? ZipCode { get; set; }
21+
22+
public string? City { get; set; }
23+
24+
[ForeignKey(nameof(UserProfile))]
25+
public required string UserProfileId { get; set; } = null!;
26+
27+
public UserProfile UserProfile { get; init; } = null!;
28+
29+
public List<Category> Categories { get; set; } = [];
30+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace Jordnaer.Shared;
2+
3+
public class PostCategory
4+
{
5+
public required Guid PostId { get; set; }
6+
7+
public required int CategoryId { get; set; }
8+
}
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.ComponentModel.DataAnnotations;
4-
using System.Linq;
1+
using System.ComponentModel.DataAnnotations;
52
using System.Reflection;
6-
using System.Text;
7-
using System.Threading.Tasks;
83

94
namespace Jordnaer.Shared.Extensions;
105
public static class EnumExtensions
116
{
127
public static DisplayAttribute? GetDisplayAttribute(this Enum enumValue)
138
{
149
return enumValue.GetType()
15-
.GetField(enumValue.ToString())?.GetCustomAttribute<DisplayAttribute>();
10+
.GetField(enumValue.ToString())?
11+
.GetCustomAttribute<DisplayAttribute>();
1612
}
17-
13+
1814
public static string GetDisplayName(this Enum enumValue)
1915
{
2016
return enumValue.GetDisplayAttribute()?.Name ?? enumValue.ToString();
2117
}
18+
19+
public static string? ToDisplayName<T>(this T enumValue) where T : Enum =>
20+
enumValue.GetDisplayAttribute()?
21+
.GetName();
2222
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
namespace Jordnaer.Shared;
2+
3+
public static class PostExtensions
4+
{
5+
public static PostDto ToPostDto(this Post post)
6+
{
7+
return new PostDto
8+
{
9+
Id = post.Id,
10+
Text = post.Text,
11+
CreatedUtc = post.CreatedUtc,
12+
Author = new UserSlim
13+
{
14+
Id = post.UserProfileId,
15+
ProfilePictureUrl = post.UserProfile.ProfilePictureUrl,
16+
UserName = post.UserProfile.UserName,
17+
DisplayName = post.UserProfile.DisplayName
18+
},
19+
City = post.City,
20+
ZipCode = post.ZipCode,
21+
Categories = post.Categories.Select(category => category.Name).ToList()
22+
};
23+
}
24+
}

0 commit comments

Comments
 (0)