Пример #1
0
            public Task <Response> Handle(Query request, CancellationToken cancellationToken)
            {
                var conf = context.GetByName(request.Name);

                return(Task.FromResult(new Response
                {
                    Conference = new ConferenceModel
                    {
                        Id = conf.Id,
                        Name = conf.Name,
                        Sessions = conf.Sessions.Select(s =>
                                                        new ConferenceModel.SessionModel
                        {
                            Id = s.Id,
                            Name = s.Title
                        }).ToList(),
                        Attendees = conf.GetAttendees().Select(a =>
                                                               new ConferenceModel.AttendeeModel
                        {
                            Id = a.Id,
                            Email = a.EMail,
                            FirstName = a.FirstName,
                            LastName = a.LastName
                        }).ToList()
                    }
                }));
            }
Пример #2
0
            public async Task <Response> Handle(Command command, CancellationToken cancellationToken)
            {
                var conference = context.GetByName(command.ConferenceName);
                var session    = conference?.Sessions.FirstOrDefault(s => s.Id == command.SessionId);

                if (session != null)
                {
                    var newAttendee = new Attendee(command.FirstName, command.LastName, command.EMail);
                    session.Attendees.Add(newAttendee);
                    await context.SaveChangesAsync(cancellationToken);

                    emailSender.NotifyAboutRegistration(newAttendee);
                }

                return(new Response
                {
                    Succeeded = true
                });
            }