示例#1
0
        public void Output_Success_ApproveApiSurface()
        {
            // Arrange
            GetEventDetailsOutput output = new GetEventDetailsOutput(
                new Guid("9F3C4AB1-C27A-4A6A-B95A-D83A9251F961"),
                "The Title",
                new Guid("0A3D24CE-FC83-4355-91EF-E593D168FC1A"),
                "John Doe",
                "The Location",
                "The MeetingPoint",
                "The description",
                new DateTime(2019, 10, 5, 19, 0, 0),
                new DateTime(2019, 10, 5, 22, 0, 0),
                false,
                false,
                new List <ParticipantOutput>
            {
                new ParticipantOutput(
                    "Name",
                    "Email",
                    "AvatarId",
                    "Team 1",
                    ParticipantStatus.Accepted,
                    1,
                    "The Note")
            },
                new List <CommentOutput>
            {
                new CommentOutput(
                    new Guid("93F4FAD3-425C-4447-89DE-AEB25E862E02"),
                    new Guid("4F969046-7899-4FBE-8C54-1482C2BF24D0"),
                    "John Doe",
                    "*****@*****.**",
                    "avatarId",
                    new DateTime(2019, 10, 3, 12, 42, 0),
                    new DateTime(2019, 10, 4, 13, 42, 0),
                    "The comment text",
                    true,
                    true)
            },
                true,
                ParticipantStatus.Accepted,
                "The current Note",
                "Current Team 1",
                1);

            // Act
            presenter.Output(output);
            var jsonObject = presenter.GetJsonObject();

            // Assert
            var json = JsonConvert.SerializeObject(jsonObject);

            Approvals.VerifyJson(json);
        }
 public void Output(GetEventDetailsOutput interactorOutput)
 {
     viewModel = new EventViewModel(
         interactorOutput.AllowEdit,
         interactorOutput.EventId,
         interactorOutput.Name,
         interactorOutput.OrganisatorId,
         interactorOutput.OrganisatorFullName,
         interactorOutput.Location,
         interactorOutput.MeetingPoint,
         interactorOutput.Description,
         interactorOutput.StartTime.FormatTimeRange(interactorOutput.EndTime),
         interactorOutput.Comments
         .OrderBy(c => c.CreatedTime)
         .Select(c => new EventCommentViewModel(
                     c.CommentId,
                     c.AuthorId,
                     c.AuthorEmail,
                     c.AuthorName,
                     c.AuthorAvatarId,
                     c.CreatedTime.ToStringSwissDateTime(),
                     c.ModifiedTime?.ToStringSwissDateTime(),
                     c.Text,
                     c.AllowEdit,
                     c.AllowDelete)),
         new EventParticipationViewModel(
             interactorOutput.EventId,
             BuddyTeamNames.Names,
             interactorOutput.Participants
             .OrderBy(p => p.BuddyTeamName)
             .Select(p => new EventParticipantViewModel(
                         p.Name,
                         p.Email,
                         p.AvatarId,
                         p.BuddyTeamName,
                         p.Status.ToString(),
                         p.Status,
                         p.Note,
                         p.CountPeople
                         )),
             interactorOutput.CurrentUserStatus,
             interactorOutput.CurrentUserNote,
             interactorOutput.CurrentUserBuddyTeamName,
             interactorOutput.CurrentUserCountPeople));
 }
示例#3
0
        public void Output([NotNull] GetEventDetailsOutput output)
        {
            if (output == null)
            {
                throw new ArgumentNullException(nameof(output));
            }

            jsonObject = new
            {
                title        = output.Name,
                description  = output.Description,
                location     = output.Location,
                meetingPoint = output.MeetingPoint,
                organisator  = output.OrganisatorFullName,
                allowEdit    = output.AllowEdit,
                canceled     = output.Canceled,
                deleted      = output.Deleted,
                startTime    = output.StartTime.ToString("O"),
                endTime      = output.EndTime?.ToString("O"),
                participants = output.Participants.Select(p => new
                {
                    name          = p.Name,
                    email         = p.Email,
                    note          = p.Note,
                    status        = p.Status.ToString(),
                    avatarId      = p.AvatarId,
                    buddyTeamName = p.BuddyTeamName,
                    countPeople   = p.CountPeople,
                }),
                comments = output.Comments.Select(c => new
                {
                    commentId      = c.CommentId,
                    text           = c.Text,
                    authorId       = c.AuthorId,
                    authorEmail    = c.AuthorEmail,
                    authorName     = c.AuthorName,
                    authorAvatarId = c.AuthorAvatarId,
                    createdTime    = c.CreatedTime.ToString("O"),
                    modifiedTime   = c.ModifiedTime?.ToString("O") ?? null,
                    allowEdit      = c.AllowEdit,
                    allowDelete    = c.AllowDelete,
                })
            };
        }