PollMapper.cs
882 bytes
| 1 | using App.BLL.DTO; |
|---|---|
| 2 | using App.DTO.v1; |
| 3 | |
| 4 | namespace App.DTO.Mappers; |
| 5 | |
| 6 | public static class PollMapper |
| 7 | { |
| 8 | public static PollDto MapToDto(TripPollBllDto poll, Guid currentUserId) |
| 9 | { |
| 10 | return new PollDto |
| 11 | { |
| 12 | Id = poll.Id, |
| 13 | TripId = poll.TripId, |
| 14 | CreatedByUserId = poll.CreatedByUserId, |
| 15 | Question = poll.Question, |
| 16 | AllowMultipleVotes = poll.AllowMultipleVotes, |
| 17 | IsAnonymous = poll.IsAnonymous, |
| 18 | ClosedAt = poll.ClosedAt, |
| 19 | Options = poll.Options?.OrderBy(o => o.DisplayOrder).Select(o => new PollOptionDto |
| 20 | { |
| 21 | Id = o.Id, |
| 22 | Text = o.Text, |
| 23 | VoteCount = o.VoteCount, |
| 24 | VotedByCurrentUser = o.VoterUserIds.Contains(currentUserId), |
| 25 | DisplayOrder = o.DisplayOrder |
| 26 | }).ToList() |
| 27 | }; |
| 28 | } |
| 29 | } |
| 30 | |