Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
dae1d90
completed
Sep 18, 2025
cbaf8c0
Add table usercc & cohort_course, update cohort and course table
SnorreAldstedt Sep 18, 2025
4ea0227
Edit Cohort & Course
SnorreAldstedt Sep 18, 2025
823d8af
completed
Sep 18, 2025
c2533a9
fixed build errors
Sep 18, 2025
2a43a39
Add DateTime to StartDate
SnorreAldstedt Sep 18, 2025
d9cb145
Update files with right table-names and correct foreign keys
SnorreAldstedt Sep 18, 2025
83c027d
Merge pull request #44 from boolean-uk/course_cohort_models_snorreaa
johanreitan Sep 18, 2025
57451e8
Merge pull request #45 from boolean-uk/changing_models_trym
johanreitan Sep 18, 2025
1df7f56
Updated and added new models for Post, Comment and Like
Stianforren Sep 18, 2025
4af2121
Merge branch 'temp_main' of github.com:boolean-uk/csharp-team-dev-ser…
Stianforren Sep 18, 2025
7ebc58a
deleted old userInfo and created new model User
monaeikli Sep 18, 2025
46f9cd4
deleted old userInfo and created new model User
monaeikli Sep 18, 2025
fecec2d
Merge pull request #49 from boolean-uk/changingUserModel
johanreitan Sep 18, 2025
b7fd782
did it
Stianforren Sep 18, 2025
1ecc499
Merge pull request #46 from boolean-uk/temp_main_post
johanreitan Sep 18, 2025
8294a9f
Add a list of CourseModules to Course
SnorreAldstedt Sep 18, 2025
028e47d
seeder done
johanreitan Sep 18, 2025
30408ac
Fixed the filepaths for the changed User model
monaeikli Sep 18, 2025
d48637f
Update Module.cs
johanreitan Sep 18, 2025
7147b9e
Merge pull request #50 from boolean-uk/fixing_seeder
johanreitan Sep 18, 2025
6f438cb
Merge branch 'temp_main' into changingUserModel
johanreitan Sep 18, 2025
5e32c6e
Merge pull request #51 from boolean-uk/changingUserModel
johanreitan Sep 18, 2025
145dd43
fixedSeeder
johanreitan Sep 18, 2025
3455ad0
Merge pull request #52 from boolean-uk/fixedErrorsInSeeder
johanreitan Sep 18, 2025
4b1ee6d
cleanedUpSeeder + made one endpoint
johanreitan Sep 18, 2025
d62ff1a
Merge pull request #53 from boolean-uk/fixedErrorsInSeeder
johanreitan Sep 18, 2025
115cd8f
added added fils
johanreitan Sep 18, 2025
0a0aa39
Merge pull request #55 from boolean-uk/fixedErrorsInSeeder
johanreitan Sep 18, 2025
86863dc
Added findById for posts
Stianforren Sep 18, 2025
aa60599
small fixes
johanreitan Sep 18, 2025
9cfeb43
added create cohort endpoint
Sep 18, 2025
a38d9e4
Merge pull request #56 from boolean-uk/fixedErrorsInSeeder
johanreitan Sep 18, 2025
58f2c7d
Updated PostDTO to version 2. Made PsotEndpoint utilize new getterfun…
Stianforren Sep 18, 2025
68e887d
Merge branch 'temp_main' into 41-api-create-new-cohort-and-get-a-coho…
598115 Sep 18, 2025
fb34e9b
Update UserEndpoints.cs
598115 Sep 18, 2025
5272a06
Update appsettings.json
598115 Sep 18, 2025
e567e00
Update exercise.wwwapi.csproj
598115 Sep 18, 2025
b290b3f
Delete exercise.wwwapi/DTOs/Course/CourseDTO.cs
598115 Sep 18, 2025
4c48861
finished
Sep 18, 2025
7529149
completed again
Sep 18, 2025
b4f2daa
added exerciseEndpoints
johanreitan Sep 18, 2025
58f446f
Merge pull request #58 from boolean-uk/ExerciseEndpoint
johanreitan Sep 18, 2025
33453c7
Merge pull request #57 from boolean-uk/41-api-create-new-cohort-and-g…
johanreitan Sep 19, 2025
911bb3f
starting point for new endpoints
johanreitan Sep 19, 2025
d85e268
Merge pull request #63 from boolean-uk/ExerciseEndpoint
johanreitan Sep 19, 2025
3e77f52
updated the Comment endpoint
Stianforren Sep 19, 2025
5bf99b3
removed unused lines
Stianforren Sep 19, 2025
34c096d
updated rule for comments. Are now able to create a comment that is 1…
Stianforren Sep 19, 2025
e2e491b
updated rules for post- create and update. and comment -update. can n…
Stianforren Sep 19, 2025
afbbecd
completed
Sep 19, 2025
e56e655
Merge pull request #65 from boolean-uk/60-api-create-course-endpoints
johanreitan Sep 19, 2025
e9c4376
Created the cohort-endpoints
monaeikli Sep 19, 2025
cc4f7de
made likeEndpoint --> users are now able to like/unlike posts
Stianforren Sep 19, 2025
e6264b2
merged temp_main into temp_main_post
Stianforren Sep 19, 2025
02b739c
New cohort-endpoints after fixes
monaeikli Sep 19, 2025
c62a6e5
Merge pull request #66 from boolean-uk/62-api-create-cohortendpoints
johanreitan Sep 19, 2025
eab694d
user done
johanreitan Sep 19, 2025
fb2f0d2
Clarify data fetching in Login method
johanreitan Sep 19, 2025
7b8f9a3
Merge pull request #68 from boolean-uk/79-api-refactor-userendpoints-…
johanreitan Sep 19, 2025
12421e0
added functionality for teacher to update others post
Stianforren Sep 19, 2025
c542d18
automatic authenthication in swagger during development
Sep 19, 2025
30cb2a6
updated getbyidfunction in commentendpoint
Stianforren Sep 19, 2025
9424977
added functionallity for teachers to delete all posts
Stianforren Sep 19, 2025
c8ab449
Merge pull request #70 from boolean-uk/swagger-auto-auth
johanreitan Sep 19, 2025
0a56d86
Merge branch 'temp_main' of github.com:boolean-uk/csharp-team-dev-ser…
Stianforren Sep 19, 2025
e93284a
Merge pull request #67 from boolean-uk/temp_main_post
johanreitan Sep 22, 2025
1311819
failing tests, but working endpoints
johanreitan Sep 22, 2025
8038d64
Update UserEndpoints.cs
johanreitan Sep 22, 2025
a39bcc9
Improve user filtering in UserEndpoints
johanreitan Sep 22, 2025
1aa4836
Merge pull request #71 from boolean-uk/79-api-refactor-userendpoints-…
johanreitan Sep 22, 2025
e88b921
done
Sep 22, 2025
5f62369
updated endpoints so update now gives name instead of id, updated DTO…
Stianforren Sep 22, 2025
3f3c2e7
Merge branch 'temp_main' into temp_main_post
Stianforren Sep 22, 2025
8a41637
fixed the thing
Sep 22, 2025
87da12e
updated claimsPrincipal to contain users first/last name. updated Pos…
Stianforren Sep 22, 2025
fa57001
updated validator comments
Stianforren Sep 22, 2025
484e01a
ok actually fixed the thing now
Sep 22, 2025
c521340
Merge pull request #73 from boolean-uk/notes-cleanup
johanreitan Sep 22, 2025
f31c580
added new seeder + some changes in program.cs
johanreitan Sep 22, 2025
37ac1f1
Merge pull request #76 from boolean-uk/new_seeder
johanreitan Sep 22, 2025
253a45b
Merge pull request #75 from boolean-uk/temp_main_post
johanreitan Sep 22, 2025
cb5e336
saved userendpoints
johanreitan Sep 22, 2025
5199ba7
Merge pull request #77 from boolean-uk/new_seeder
johanreitan Sep 22, 2025
388771d
done
Sep 22, 2025
b13e810
removed test not working
johanreitan Sep 23, 2025
37bdc10
Merge pull request #79 from boolean-uk/fix_tests
johanreitan Sep 23, 2025
ec0b8b6
Merge pull request #78 from boolean-uk/comments-fix-swaggerAuth-fix
johanreitan Sep 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions api.tests/Notes/GetNotesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using exercise.wwwapi.DTOs.Notes;
using exercise.wwwapi.Endpoints;
using exercise.wwwapi.Models;
using exercise.wwwapi.Models.UserInfo;
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down Expand Up @@ -69,7 +68,7 @@ public async Task GetNoteByIdSuccess()
Assert.That(noteResult.Status, Is.EqualTo("success"));
Assert.That(noteResult.Data, Is.Not.Null);
Assert.That(noteResult.Data.Id, Is.EqualTo(noteId));
Assert.That(noteResult.Data.Title, Is.EqualTo("Title Note 1"));
Assert.That(noteResult.Data.Title, Is.EqualTo("Name Note 1"));
Assert.That(noteResult.Data.Content, Is.EqualTo("note1note1 note1 note1 content"));
}

Expand All @@ -89,7 +88,7 @@ public async Task TeacherGetNotesOnAStudentSuccess()
{
await AuthenticateAsTeacherAsync();

var userId = 2; // student user id to get notes for
var userId = 1; // student user id to get notes for
var getNotesResponse = await _client.GetAsync($"/users/{userId}/notes");

Assert.That(getNotesResponse.IsSuccessStatusCode, Is.True);
Expand All @@ -102,15 +101,15 @@ public async Task TeacherGetNotesOnAStudentSuccess()
Assert.That(notesResult.Status, Is.EqualTo("success"));
Assert.That(notesResult.Data, Is.Not.Null);
Assert.That(notesResult.Data.Notes, Is.Not.Empty);
Assert.That(notesResult.Data.Notes.Count, Is.EqualTo(1));
Assert.That(notesResult.Data.Notes.Count, Is.EqualTo(4));
}

[Test]
public async Task TeacherGetNotesOnStudentWithNoNotesSuccess()
{
await AuthenticateAsTeacherAsync();

var userId = 5; // student user id to get notes for but user has no notes
var userId = 3; // student user id to get notes for but user has no notes
var getNotesResponse = await _client.GetAsync($"/users/{userId}/notes");

Assert.That(getNotesResponse.IsSuccessStatusCode, Is.True);
Expand Down
2 changes: 0 additions & 2 deletions api.tests/PostEndpointTests/UpdatePostTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ public async Task UpdatePostPassesTest()
Assert.That(updatedResult, Is.Not.Null, "Update Failed");
Assert.That(patchResponse.StatusCode, Is.EqualTo(System.Net.HttpStatusCode.OK));
Assert.That(updatedResult!.Data.Body, Is.EqualTo(newBody));
Assert.That(updatedResult!.Data.Id, Is.EqualTo(1));
Assert.That(updatedResult!.Data.AuthorId, Is.EqualTo(1));
}
}
}
31 changes: 3 additions & 28 deletions api.tests/UserEndpointTests/DeleteUserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,35 +24,10 @@ public void TearDown()
}

[Test]
public async Task DeleteUserPassesTest()
public async Task UPDATEME___DeleteUserPassesTest()
{
const string email = "test1@test1";
const string password = "Test1test1%";

var loginUser = new LoginRequestDTO()
{
Email = email,
Password = password,
};

var contentLogin = new StringContent(
JsonSerializer.Serialize(loginUser),
Encoding.UTF8,
"application/json"
);

var loginResponse = await _client.PostAsync("login", contentLogin);
Assert.That(loginResponse.StatusCode, Is.EqualTo(System.Net.HttpStatusCode.OK));

var jsonResponse = await loginResponse.Content.ReadAsStringAsync();
var result = JsonSerializer.Deserialize<ResponseDTO<LoginSuccessDTO>>(jsonResponse);
Assert.That(result, Is.Not.Null);

_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", result.Data.Token);

var userId = result.Data.User.Id;
var deleteResponse = await _client.DeleteAsync($"users/{userId}");
Assert.That(deleteResponse.StatusCode, Is.EqualTo(System.Net.HttpStatusCode.OK));

Assert.That(true);
}

[Test]
Expand Down
7 changes: 4 additions & 3 deletions api.tests/UserEndpointTests/GetUserTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using exercise.wwwapi.DTOs;
using exercise.wwwapi.DTOs.GetUsers;
using exercise.wwwapi.DTOs.Login;
using exercise.wwwapi.DTOs.Users;
using exercise.wwwapi.Endpoints;
using System.Text.Json;

Expand Down Expand Up @@ -73,7 +74,7 @@ public async Task GetFilteredUsersByFirstNameTest()
[Test]
public async Task GetFilteredUsersByLastNameTest()
{
var getUsersResponse = await _client.GetAsync($"users?searchTerm=Jackson");
var getUsersResponse = await _client.GetAsync($"users?searchTerm=jordan");
var jsonResponse = await getUsersResponse.Content.ReadAsStringAsync();
var result = JsonSerializer.Deserialize<ResponseDTO<UsersSuccessDTO>>(jsonResponse);

Expand All @@ -93,7 +94,7 @@ public async Task GetFilteredUsersTestFails()
[Test]
public async Task GetFilteredUsersByFullNameTest()
{
var getUsersResponse = await _client.GetAsync($"users?searchTerm=Michael%20Jackson");
var getUsersResponse = await _client.GetAsync($"users?searchTerm=Michael%20Jordan");
var jsonResponse = await getUsersResponse.Content.ReadAsStringAsync();
var result = JsonSerializer.Deserialize<ResponseDTO<UsersSuccessDTO>>(jsonResponse);

Expand All @@ -107,7 +108,7 @@ public async Task GetFilteredUsersByLetterTest()
var jsonResponse = await getUsersResponse.Content.ReadAsStringAsync();
var result = JsonSerializer.Deserialize<ResponseDTO<UsersSuccessDTO>>(jsonResponse);

Assert.That(result.Data.Users.Count, Is.EqualTo(3));
Assert.That(result.Data.Users.Count, Is.EqualTo(2));
}

}
6 changes: 3 additions & 3 deletions api.tests/UserEndpointTests/RegistrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ public void TearDown()
[Test]
public async Task RegisterUserExistsTest()
{
const string email = "test1@test1";
const string password = "Test1test1%";
const string username = "TestTestTest";
const string email = "test2@test2";
const string password = "Test2test2%";
const string username = "test2@test2";

var newUser = new RegisterRequestDTO
{
Expand Down
4 changes: 2 additions & 2 deletions api.tests/UserEndpointTests/UpdateUserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public async Task UpdateUserMobileNumberValidationFailsTest()
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", result.Data.Token);
var updateUser = new UpdateUserRequestDTO
{
Phone = phone,
Mobile = phone,
};
var content = new StringContent(
JsonSerializer.Serialize(updateUser),
Expand Down Expand Up @@ -328,7 +328,7 @@ public async Task UpdateUserMobileValidationPassesTest()
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", result.Data.Token);
var updateUser = new UpdateUserRequestDTO
{
Phone = phone,
Mobile = phone,
Username = username,
};
var content = new StringContent(
Expand Down
18 changes: 12 additions & 6 deletions api.tests/api.tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,18 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="9.0.8" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="NUnit" Version="4.2.2" />
<PackageReference Include="NUnit.Analyzers" Version="4.4.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageReference Include="coverlet.collector" Version="6.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="9.0.9" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageReference Include="NUnit" Version="4.4.0" />
<PackageReference Include="NUnit.Analyzers" Version="4.10.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="NUnit3TestAdapter" Version="5.1.0" />
</ItemGroup>

<ItemGroup>
Expand Down
29 changes: 29 additions & 0 deletions exercise.wwwapi/DTOs/Cohorts/CohortDTO.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;
using exercise.wwwapi.DTOs.Courses;
using exercise.wwwapi.DTOs.Exercises;

namespace exercise.wwwapi.Models;

public class CohortDTO
{
public int Id { get; set; }
public int CohortNumber { get; set; }
public string CohortName { get; set; }
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
public List<CourseDTO> Courses { get; set; }

public CohortDTO(){}
public CohortDTO(Cohort model)
{
Id = model.Id;
CohortNumber = model.CohortNumber;
CohortName = model.CohortName;
StartDate = model.StartDate;
EndDate = model.EndDate;
Courses = model.CohortCourses.Select(cc => new CourseDTO(cc)).ToList();
}
}
10 changes: 10 additions & 0 deletions exercise.wwwapi/DTOs/Cohorts/CohortPostDTO.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

using System.Text.Json.Serialization;

public class CohortPostDTO
{
public string CohortName { get; set; }

Check warning on line 6 in exercise.wwwapi/DTOs/Cohorts/CohortPostDTO.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'CohortName' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
}
23 changes: 0 additions & 23 deletions exercise.wwwapi/DTOs/Comments/CommentDTO.cs

This file was deleted.

13 changes: 6 additions & 7 deletions exercise.wwwapi/DTOs/Comments/CommentsSuccessDTO.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using System.Text.Json.Serialization;
using exercise.wwwapi.DTOs.Posts.GetPosts;
using System.Text.Json.Serialization;

namespace exercise.wwwapi.DTOs.Comments

public class CommentsSuccessDTO
{
public class CommentsSuccessDTO
{
[JsonPropertyName("comments")]
public List<CommentDTO> Comments { get; set; } = new();
}
[JsonPropertyName("comments")]
public List<CommentDTO> Comments { get; set; } = new();
}
23 changes: 23 additions & 0 deletions exercise.wwwapi/DTOs/Courses/CourseDTO.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using exercise.wwwapi.Models;
using System.Drawing;

namespace exercise.wwwapi.DTOs.Courses
{
public class CourseDTO
{
public int Id { get; set; }
public string Name { get; set; }
public CourseDTO() { }
public CourseDTO(Course model)
{
Id = model.Id;
Name = model.Name;
}
public CourseDTO(CohortCourse model)
{
Id = model.Course.Id;
Name = model.Course.Name;
}
}

}
9 changes: 9 additions & 0 deletions exercise.wwwapi/DTOs/Courses/CoursePostDTO.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

namespace exercise.wwwapi.DTOs.Courses
{
public class CoursePostDTO
{
public string Name { get; set; }

}
}
20 changes: 20 additions & 0 deletions exercise.wwwapi/DTOs/Courses/GetCourseDTO.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using exercise.wwwapi.Models;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace exercise.wwwapi.DTOs.Courses
{
public class GetCourseDTO
{
public int Id { get; set; }
public string Name { get; set; }
public ICollection<GetCourseModuleDTO> CourseModules { get; set; } = new List<GetCourseModuleDTO>();
public GetCourseDTO(){}
public GetCourseDTO(Course model)
{
Id = model.Id;
Name = model.Name;
CourseModules = model.CourseModules.Select(cm => new GetCourseModuleDTO(cm)).ToList();
}
}
}
23 changes: 23 additions & 0 deletions exercise.wwwapi/DTOs/Courses/GetCourseModuleDTO.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using exercise.wwwapi.DTOs.Exercises;
using exercise.wwwapi.Models;
using System.ComponentModel.DataAnnotations.Schema;

namespace exercise.wwwapi.DTOs.Courses
{
public class GetCourseModuleDTO
{
public int Id { get; set; }
public int CourseId { get; set; }
public int ModuleId { get; set; }
public GetModuleDTO Module { get; set; }

public GetCourseModuleDTO(){}
public GetCourseModuleDTO(CourseModule model)
{
Id = model.Id;
CourseId = model.CourseId;
ModuleId = model.ModuleId;
Module = new GetModuleDTO(model.Module);
}
}
}
26 changes: 26 additions & 0 deletions exercise.wwwapi/DTOs/Exercises/Exercise_noUnit.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using exercise.wwwapi.Repository;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using exercise.wwwapi.Models;

namespace exercise.wwwapi.Models.Exercises;

public class Exercise_noUnit
{
public int Id { get; set; }
public int UnitId { get; set; }
public string Name { get; set; }
public string GitHubLink { get; set; }
public string Description { get; set; }

public Exercise_noUnit(){}

public Exercise_noUnit(Exercise model)
{
Id = model.Id;
UnitId = model.UnitId;
Name = model.Name;
GitHubLink = model.GitHubLink;
Description = model.Description;
}
}
23 changes: 23 additions & 0 deletions exercise.wwwapi/DTOs/Exercises/GetModuleDTO.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using exercise.wwwapi.Models;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace exercise.wwwapi.DTOs.Exercises
{
public class GetModuleDTO
{
public int Id { get; set; }

public string Title { get; set; }
public ICollection<GetUnitDTO> Units { get; set; } = new List<GetUnitDTO>();

public GetModuleDTO(){}

public GetModuleDTO(Module model)
{
Id = model.Id;
Title = model.Title;
Units = model.Units.Select(u => new GetUnitDTO(u)).ToList();
}
}
}
Loading
Loading