Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions exercise.wwwapi/DTOs/Cohort/CourseInCohortDTO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ namespace exercise.wwwapi.DTOs.Cohort
public class CourseInCohortDTO
{
public string Title { get; set; }
public int Id { get; set; }

public ICollection<UserBasicDTO> Students { get; set; } = new List<UserBasicDTO>();
public ICollection<UserBasicDTO> Teachers { get; set; } = new List<UserBasicDTO>();
//public ICollection<UserCohortDTO> Students { get; set; } = new List<UserCohortDTO>();
Expand Down
6 changes: 3 additions & 3 deletions exercise.wwwapi/Endpoints/CohortEndpoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
1 change: 1 addition & 0 deletions exercise.wwwapi/Tools/MappingProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public MappingProfile()
.ForMember(dest => dest.Cohort, opt => opt.MapFrom(src => src.Cohort.Title));

CreateMap<CohortCourse, CourseInCohortDTO>()
.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
Expand Down
Loading