Skip to content
This repository was archived by the owner on Jul 10, 2024. It is now read-only.

Commit 76bcc6a

Browse files
committed
Remove redundant EntityExtensions
1 parent 6a41dee commit 76bcc6a

File tree

1 file changed

+0
-75
lines changed

1 file changed

+0
-75
lines changed

docs/2. Build out BackEnd and Refactor.md

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -391,81 +391,6 @@ Okay, now we need to update our `ApplicationDbContext` so Entity Framework knows
391391
1. Copy the following controllers from [the save point folder](/save-points/2-BackEnd-completed/ConferencePlanner/BackEnd/Controllers) into the current project's `BackEnd/Controllers` directory:
392392
- `SessionsController`
393393
- `AttendeesController`
394-
395-
## Update EntityExtensions
396-
1. Update the `EntityExtensions.cs` file to with the following code (adding the `MapSessionResponse` and `MapAttendeeResponse` methods):
397-
```csharp
398-
using BackEnd.Data;
399-
using System;
400-
using System.Collections.Generic;
401-
using System.Linq;
402-
using System.Threading.Tasks;
403-
404-
namespace BackEnd.Data
405-
{
406-
public static class EntityExtensions
407-
{
408-
public static ConferenceDTO.SessionResponse MapSessionResponse(this Session session) =>
409-
new ConferenceDTO.SessionResponse
410-
{
411-
Id = session.Id,
412-
Title = session.Title,
413-
StartTime = session.StartTime,
414-
EndTime = session.EndTime,
415-
Speakers = session.SessionSpeakers?
416-
.Select(ss => new ConferenceDTO.Speaker
417-
{
418-
Id = ss.SpeakerId,
419-
Name = ss.Speaker.Name
420-
})
421-
.ToList(),
422-
TrackId = session.TrackId,
423-
Track = new ConferenceDTO.Track
424-
{
425-
Id = session?.TrackId ?? 0,
426-
Name = session.Track?.Name
427-
},
428-
Abstract = session.Abstract
429-
};
430-
431-
public static ConferenceDTO.SpeakerResponse MapSpeakerResponse(this Speaker speaker) =>
432-
new ConferenceDTO.SpeakerResponse
433-
{
434-
Id = speaker.Id,
435-
Name = speaker.Name,
436-
Bio = speaker.Bio,
437-
WebSite = speaker.WebSite,
438-
Sessions = speaker.SessionSpeakers?
439-
.Select(ss =>
440-
new ConferenceDTO.Session
441-
{
442-
Id = ss.SessionId,
443-
Title = ss.Session.Title
444-
})
445-
.ToList()
446-
};
447-
448-
public static ConferenceDTO.AttendeeResponse MapAttendeeResponse(this Attendee attendee) =>
449-
new ConferenceDTO.AttendeeResponse
450-
{
451-
Id = attendee.Id,
452-
FirstName = attendee.FirstName,
453-
LastName = attendee.LastName,
454-
UserName = attendee.UserName,
455-
Sessions = attendee.SessionsAttendees?
456-
.Select(sa =>
457-
new ConferenceDTO.Session
458-
{
459-
Id = sa.SessionId,
460-
Title = sa.Session.Title,
461-
StartTime = sa.Session.StartTime,
462-
EndTime = sa.Session.EndTime
463-
})
464-
.ToList()
465-
};
466-
}
467-
}
468-
```
469394

470395
## Adding Conference Upload support
471396
1. Copy the `DataLoader.cs` class from [here](/src/BackEnd/Data/DataLoader.cs) into the `Data` directory of the `BackEnd` project.

0 commit comments

Comments
 (0)