Skip to content

Commit 42b3a42

Browse files
authored
Merge pull request #110 from boolean-uk/105-backend---request-paths-for-cohort-endpoint
Fixed request URL path
2 parents c7257ee + 2e553b8 commit 42b3a42

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

exercise.wwwapi/DTOs/Cohort/CourseInCohortDTO.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ namespace exercise.wwwapi.DTOs.Cohort
55
public class CourseInCohortDTO
66
{
77
public string Title { get; set; }
8+
public int Id { get; set; }
9+
810
public ICollection<UserBasicDTO> Students { get; set; } = new List<UserBasicDTO>();
911
public ICollection<UserBasicDTO> Teachers { get; set; } = new List<UserBasicDTO>();
1012
//public ICollection<UserCohortDTO> Students { get; set; } = new List<UserCohortDTO>();

exercise.wwwapi/Endpoints/CohortEndpoints.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ public static void ConfigureCohortEndpoints(this WebApplication app)
1717
var cohorts = app.MapGroup("cohorts");
1818
cohorts.MapPost("/", CreateCohort).WithSummary("Create a cohort");
1919
cohorts.MapGet("/", GetAllCohorts).WithSummary("Get all cohorts");
20-
cohorts.MapGet("/{id}", GetCohort).WithSummary("Get a cohort by ID");
20+
cohorts.MapGet("/cohortId/{cohortId}", GetCohort).WithSummary("Get a cohort by ID");
2121
//cohorts.MapGet("/{userId}", GetCohortByUserId).WithSummary("");
22-
cohorts.MapPost("/{cohortId}/{userId}/{courseId}", AddUserToCohort).WithSummary("Add a user to a cohort");
23-
cohorts.MapDelete("/{cohortId}/{userId}/{courseId}", DeleteUserFromCohort).WithSummary("Delete a user from a cohort");
22+
cohorts.MapPost("/cohortId/{cohortId}/userId/{userId}/courseId/{courseId}", AddUserToCohort).WithSummary("Add a user to a cohort");
23+
cohorts.MapDelete("/cohortId/{cohortId}/userId/{userId}/courseId/{courseId}", DeleteUserFromCohort).WithSummary("Delete a user from a cohort");
2424
}
2525

2626
[ProducesResponseType(StatusCodes.Status200OK)]

exercise.wwwapi/Tools/MappingProfile.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public MappingProfile()
2323
.ForMember(dest => dest.Cohort, opt => opt.MapFrom(src => src.Cohort.Title));
2424

2525
CreateMap<CohortCourse, CourseInCohortDTO>()
26+
.ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.CourseId))
2627
.ForMember(dest => dest.Title, opt => opt.MapFrom(src => src.Course.Title))
2728
.ForMember(dest => dest.Students, opt => opt.MapFrom(
2829
src => src.CohortCourseUsers

0 commit comments

Comments
 (0)