diff --git a/exercise.wwwapi/DTOs/Cohort/CourseInCohortDTO.cs b/exercise.wwwapi/DTOs/Cohort/CourseInCohortDTO.cs index 7774b1b..e975129 100644 --- a/exercise.wwwapi/DTOs/Cohort/CourseInCohortDTO.cs +++ b/exercise.wwwapi/DTOs/Cohort/CourseInCohortDTO.cs @@ -5,6 +5,8 @@ namespace exercise.wwwapi.DTOs.Cohort public class CourseInCohortDTO { public string Title { get; set; } + public int Id { get; set; } + public ICollection Students { get; set; } = new List(); public ICollection Teachers { get; set; } = new List(); //public ICollection Students { get; set; } = new List(); diff --git a/exercise.wwwapi/Endpoints/CohortEndpoints.cs b/exercise.wwwapi/Endpoints/CohortEndpoints.cs index 5130962..8405b1b 100644 --- a/exercise.wwwapi/Endpoints/CohortEndpoints.cs +++ b/exercise.wwwapi/Endpoints/CohortEndpoints.cs @@ -17,10 +17,10 @@ public static void ConfigureCohortEndpoints(this WebApplication app) var cohorts = app.MapGroup("cohorts"); cohorts.MapPost("/", CreateCohort).WithSummary("Create a cohort"); cohorts.MapGet("/", GetAllCohorts).WithSummary("Get all cohorts"); - cohorts.MapGet("/{id}", GetCohort).WithSummary("Get a cohort by ID"); + cohorts.MapGet("/cohortId/{cohortId}", GetCohort).WithSummary("Get a cohort by ID"); //cohorts.MapGet("/{userId}", GetCohortByUserId).WithSummary(""); - cohorts.MapPost("/{cohortId}/{userId}/{courseId}", AddUserToCohort).WithSummary("Add a user to a cohort"); - cohorts.MapDelete("/{cohortId}/{userId}/{courseId}", DeleteUserFromCohort).WithSummary("Delete a user from a cohort"); + cohorts.MapPost("/cohortId/{cohortId}/userId/{userId}/courseId/{courseId}", AddUserToCohort).WithSummary("Add a user to a cohort"); + cohorts.MapDelete("/cohortId/{cohortId}/userId/{userId}/courseId/{courseId}", DeleteUserFromCohort).WithSummary("Delete a user from a cohort"); } [ProducesResponseType(StatusCodes.Status200OK)] diff --git a/exercise.wwwapi/Tools/MappingProfile.cs b/exercise.wwwapi/Tools/MappingProfile.cs index ecdc12e..ede4bcb 100644 --- a/exercise.wwwapi/Tools/MappingProfile.cs +++ b/exercise.wwwapi/Tools/MappingProfile.cs @@ -23,6 +23,7 @@ public MappingProfile() .ForMember(dest => dest.Cohort, opt => opt.MapFrom(src => src.Cohort.Title)); CreateMap() + .ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.CourseId)) .ForMember(dest => dest.Title, opt => opt.MapFrom(src => src.Course.Title)) .ForMember(dest => dest.Students, opt => opt.MapFrom( src => src.CohortCourseUsers