Skip to content

Commit d5d35a7

Browse files
committed
updated DTOs
1 parent 934b8c4 commit d5d35a7

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

exercise.wwwapi/DTOs/CohortCourse/GetCohortCourseDTO.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ public class GetCohortCourseDTO
1313

1414
public string CohortName { get; set; }
1515
public string CourseName { get; set; }
16-
public DateTime StartDate { get; set; }
17-
public DateTime EndDate { get; set; }
16+
public string StartDate { get; set; }
17+
public string EndDate { get; set; }
1818
public ICollection<UserDTO> Users { get; set; } = new List<UserDTO>();
1919

2020
public GetCohortCourseDTO() { }
@@ -25,8 +25,8 @@ public GetCohortCourseDTO(Models.CohortCourse model)
2525
CourseId = model.CourseId;
2626
CohortName = model.Cohort.CohortName;
2727
CourseName = model.Course.Name;
28-
StartDate = model.Cohort.StartDate;
29-
EndDate = model.Cohort.EndDate;
28+
StartDate = $"{model.Cohort.StartDate:MMMM} {model.Cohort.StartDate:yyyy}";
29+
EndDate = $"{model.Cohort.EndDate:MMMM} {model.Cohort.EndDate:yyyy}";
3030
Users = model.UserCCs.Select(uc => new UserDTO(uc.User)).ToList();
3131

3232

exercise.wwwapi/DTOs/Users/UserDTO.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public class UserDTO
3535
public Specialism? Specialism { get; set; }
3636

3737
public int? CohortId { get; set; }
38+
public int? CohortCourseId { get; set; }
3839

3940
public DateTime? CurrentStartdate { get; set; }
4041
public DateTime? CurrentEnddate { get; set; }
@@ -63,7 +64,8 @@ public UserDTO(User model)
6364
Mobile = model.Mobile;
6465
Specialism = model.Specialism;
6566
Role = model.Role.ToString();
66-
CohortId = model.User_CC?.LastOrDefault()?.CohortCourse.CohortId; //autofetching the first element of usercc
67+
CohortId = model.User_CC?.LastOrDefault()?.CohortCourse.CohortId;
68+
CohortCourseId = model.User_CC?.LastOrDefault()?.Id; //autofetching the first element of usercc
6769
CurrentStartdate = model.User_CC?.LastOrDefault()?.CohortCourse.Cohort.StartDate; //autofetching the first element of usercc
6870
CurrentEnddate = model.User_CC?.LastOrDefault()?.CohortCourse.Cohort.EndDate; //autofetching the first element of usercc
6971
Notes = model.Notes.Select(n => new NoteDTO(n)).ToList();
@@ -81,7 +83,8 @@ public UserDTO(User model, PrivilegeLevel privilegeLevel)
8183
Mobile = model.Mobile;
8284
Specialism = model.Specialism;
8385
Role = model.Role.ToString();
84-
CohortId = model.User_CC?.LastOrDefault()?.CohortCourse.CohortId; //autofetching the first element of usercc
86+
CohortId = model.User_CC?.LastOrDefault()?.CohortCourse.CohortId;
87+
CohortCourseId = model.User_CC?.LastOrDefault()?.CohortCourse.CohortId; //autofetching the first element of usercc
8588
CurrentStartdate = model.User_CC?.LastOrDefault()?.CohortCourse.Cohort.StartDate; //autofetching the first element of usercc
8689
CurrentEnddate = model.User_CC?.LastOrDefault()?.CohortCourse.Cohort.EndDate; //autofetching the first element of usercc
8790

0 commit comments

Comments
 (0)