Example #1
0
        private MeetingComment(
            MeetingId meetingId,
            MemberId authorId,
            string comment,
            MeetingCommentingConfiguration meetingCommentingConfiguration,
            MeetingCommentId inReplyToCommentId)
        {
            this.CheckRule(new CommentTextMustBeProvidedRule(comment));
            this.CheckRule(new CommentCanBeCreatedOnlyIfCommentingForMeetingEnabledRule(meetingCommentingConfiguration));

            this.Id    = new MeetingCommentId(Guid.NewGuid());
            _meetingId = meetingId;
            _authorId  = authorId;
            _comment   = comment;

            _inReplyToCommentId = inReplyToCommentId;

            _createDate = SystemClock.Now;
            _editDate   = null;

            _isRemoved       = false;
            _removedByReason = null;

            this.AddDomainEvent(new MeetingCommentCreatedDomainEvent(Id));
        }
 internal CreateMeetingPaymentCommand(Guid id, PayerId payerId, MeetingId meetingId, decimal value, string currency) : base(id)
 {
     PayerId   = payerId;
     MeetingId = meetingId;
     Value     = value;
     Currency  = currency;
 }
Example #3
0
        private MeetingCommentingConfiguration(MeetingId meetingId)
        {
            this.Id                   = new MeetingCommentingConfigurationId(Guid.NewGuid());
            this._meetingId           = meetingId;
            this._isCommentingEnabled = true;

            this.AddDomainEvent(new MeetingCommentingConfigurationCreatedDomainEvent(this._meetingId, this._isCommentingEnabled));
        }
Example #4
0
        public void MeetingPayment_WhenFeeIsNotGreaterThanZero_CannotBeCreated()
        {
            var payerId   = new PayerId(Guid.NewGuid());
            var meetingId = new MeetingId(Guid.NewGuid());
            var fee       = new MoneyValue(0, "EUR");

            AssertBrokenRule <MeetingPaymentFeeMustBeGreaterThanZeroRule>(() =>
            {
                MeetingPayment.CreatePaymentForMeeting(payerId, meetingId, fee);
            });
        }
Example #5
0
 internal static MeetingComment Create(
     MeetingId meetingId,
     MemberId authorId,
     string comment,
     MeetingGroup meetingGroup,
     MeetingCommentingConfiguration meetingCommentingConfiguration)
 => new MeetingComment(
     meetingId,
     authorId,
     comment,
     inReplyToCommentId: null,
     meetingCommentingConfiguration,
     meetingGroup);
Example #6
0
        public void MeetingPayment_WhenFeeIsGreaterThanZero_IsCreated()
        {
            var payerId   = new PayerId(Guid.NewGuid());
            var meetingId = new MeetingId(Guid.NewGuid());
            var fee       = new MoneyValue(100, "EUR");

            var meetingPayment = MeetingPayment.CreatePaymentForMeeting(payerId, meetingId, fee);

            var meetingCreated = GetPublishedDomainEvent <MeetingPaymentCreatedDomainEvent>(meetingPayment);

            Assert.That(meetingCreated.PayerId, Is.EqualTo(payerId));
            Assert.That(meetingCreated.MeetingId, Is.EqualTo(meetingId));
            Assert.That(meetingCreated.Fee, Is.EqualTo(fee));
        }
Example #7
0
        public void MarkPaymentAsPayed_WhenIsPayedAlready_CannotBePayedTwice()
        {
            var payerId   = new PayerId(Guid.NewGuid());
            var meetingId = new MeetingId(Guid.NewGuid());
            var fee       = new MoneyValue(100, "EUR");

            var meetingPayment = MeetingPayment.CreatePaymentForMeeting(payerId, meetingId, fee);

            meetingPayment.MarkIsPayed();

            AssertBrokenRule <MeetingPaymentCannotBePayedTwiceRule>(() =>
            {
                meetingPayment.MarkIsPayed();
            });
        }
 public MeetingAttendeeAddedDomainEvent(
     MeetingId meetingId,
     MemberId attendeeId,
     DateTime rsvpDate,
     MeetingAttendeeRole role,
     int guestsNumber,
     MoneyValue fee)
 {
     MeetingId    = meetingId;
     AttendeeId   = attendeeId;
     RSVPDate     = rsvpDate;
     Role         = role;
     GuestsNumber = guestsNumber;
     Fee          = fee;
 }
Example #9
0
        private MeetingComment(MeetingId meetingId, MemberId authorId, string comment, MeetingCommentId?inReplyToCommentId)
        {
            this.CheckRule(new CommentTextMustBeProvidedRule(comment));

            this.Id    = new MeetingCommentId(Guid.NewGuid());
            _meetingId = meetingId;
            _authorId  = authorId;
            _comment   = comment;

            _inReplyToCommentId = inReplyToCommentId;

            _createDate = SystemClock.Now;
            _editDate   = null;

            this.AddDomainEvent(new MeetingCommentCreatedDomainEvent(Id));
        }
Example #10
0
        public async Task CreateMeetingPayment_Test()
        {
            PayerId   payerId   = new PayerId(Guid.NewGuid());
            MeetingId meetingId = new MeetingId(Guid.NewGuid());
            decimal   value     = 100;
            string    currency  = "EUR";
            await PaymentsModule.ExecuteCommandAsync(new CreateMeetingPaymentCommand(Guid.NewGuid(),
                                                                                     payerId, meetingId, value, currency));

            var payment = await PaymentsModule.ExecuteQueryAsync(new GetMeetingPaymentQuery(meetingId.Value, payerId.Value));

            Assert.That(payment.PayerId, Is.EqualTo(payerId.Value));
            Assert.That(payment.MeetingId, Is.EqualTo(meetingId.Value));
            Assert.That(payment.FeeValue, Is.EqualTo(value));
            Assert.That(payment.FeeCurrency, Is.EqualTo(currency));
        }
Example #11
0
 public static async Task <MeetingDto> GetMeeting(MeetingId meetingId, IDbConnection connection)
 {
     return(await connection.QuerySingleAsync <MeetingDto>("SELECT " +
                                                           "[Meeting].Id, " +
                                                           "[Meeting].Title, " +
                                                           "[Meeting].Description, " +
                                                           "[Meeting].LocationAddress, " +
                                                           "[Meeting].LocationCity, " +
                                                           "[Meeting].LocationPostalCode, " +
                                                           "[Meeting].TermStartDate, " +
                                                           "[Meeting].TermEndDate " +
                                                           "FROM [meetings].[v_Meetings] AS [Meeting] " +
                                                           "WHERE [Meeting].[Id] = @Id", new
     {
         Id = meetingId.Value
     }));
 }
Example #12
0
 public MeetingAttendeeAddedDomainEvent(
     MeetingId meetingId,
     MemberId attendeeId,
     DateTime rsvpDate,
     MeetingAttendeeRole role,
     int guestsNumber,
     decimal?feeValue,
     string feeCurrency)
 {
     MeetingId    = meetingId;
     AttendeeId   = attendeeId;
     RSVPDate     = rsvpDate;
     Role         = role;
     GuestsNumber = guestsNumber;
     FeeValue     = feeValue;
     FeeCurrency  = feeCurrency;
 }
Example #13
0
        public Meeting Get(MeetingId meetingId)
        {
            SaveToLog("Request started");
            var    remotesecret = meetingId.Secret.ToString();
            string s            = Environment.GetEnvironmentVariable("MeetingsSecret", EnvironmentVariableTarget.Machine);

            if (!string.IsNullOrEmpty(s))
            {
                if (remotesecret != s)
                {
                    throw new Exception("Wrong secret");
                }
            }
            var     partresult = MeetingQueries.GetMeeting(meetingId.Id.Value);
            Meeting result     = this.mapper.Map <Meeting>(partresult);

            SaveToLog("Meetings mapped");
            return(result);
        }
Example #14
0
        public void MarkPaymentAsPayed_WhenIsNotPayed_IsPayed()
        {
            var payerId     = new PayerId(Guid.NewGuid());
            var meetingId   = new MeetingId(Guid.NewGuid());
            var fee         = new MoneyValue(100, "EUR");
            var paymentDate = DateTime.UtcNow;

            SystemClock.Set(paymentDate);

            var meetingPayment = MeetingPayment.CreatePaymentForMeeting(payerId, meetingId, fee);

            meetingPayment.MarkIsPayed();

            var meetingPayed = GetPublishedDomainEvent <MeetingPayedDomainEvent>(meetingPayment);

            Assert.That(meetingPayed.MeetingId, Is.EqualTo(meetingId));
            Assert.That(meetingPayed.PayerId, Is.EqualTo(payerId));
            Assert.That(meetingPayed.PaymentDate, Is.EqualTo(paymentDate));
        }
Example #15
0
        /// <summary>
        /// Called when the dialog is started and pushed onto the dialog stack.
        /// </summary>
        /// <param name="dc">The <see cref="DialogContext"/> for the current turn of conversation.</param>
        /// <param name="options">Optional, initial information to pass to the dialog.</param>
        /// <param name="cancellationToken">A cancellation token that can be used by other objects
        /// or threads to receive notice of cancellation.</param>
        /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
        public override async Task <DialogTurnResult> BeginDialogAsync(DialogContext dc, object options = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (options is CancellationToken)
            {
                throw new ArgumentException($"{nameof(options)} cannot be a cancellation token");
            }

            if (this.Disabled != null && this.Disabled.GetValue(dc.State))
            {
                return(await dc.EndDialogAsync(cancellationToken : cancellationToken).ConfigureAwait(false));
            }

            if (dc.Context.Activity.ChannelId != Channels.Msteams)
            {
                throw new InvalidOperationException($"{Kind} works only on the Teams channel.");
            }

            string meetingId     = MeetingId.GetValueOrNull(dc.State);
            string participantId = ParticipantId.GetValueOrNull(dc.State);
            string tenantId      = TenantId.GetValueOrNull(dc.State);

            if (participantId == null)
            {
                // TeamsInfo.GetMeetingParticipantAsync will default to retrieving the current meeting's participant
                // if none is provided.  This could lead to unexpected results.  Therefore, GetMeetingParticipant action
                // throws an exception if the expression provided somehow maps to an invalid result.
                throw new InvalidOperationException($"{Kind} could not determine the participant id by expression value provided. {nameof(participantId)} is required.");
            }

            var result = await TeamsInfo.GetMeetingParticipantAsync(dc.Context, meetingId, participantId, tenantId, cancellationToken : cancellationToken).ConfigureAwait(false);

            if (this.Property != null)
            {
                dc.State.SetValue(this.Property.GetValue(dc.State), result);
            }

            return(await dc.EndDialogAsync(result, cancellationToken : cancellationToken).ConfigureAwait(false));
        }
 public MemberSetAsAttendeeDomainEvent(MeetingId meetingId, MemberId hostId)
 {
     MeetingId = meetingId;
     HostId    = hostId;
 }
Example #17
0
 internal static MeetingCommentingConfiguration Create(MeetingId meetingId)
 => new MeetingCommentingConfiguration(meetingId);
        public static async Task <MeetingGroupMemberData> GetMeetingGroupMember(MemberId memberId, MeetingId meetingOfGroupId, IDbConnection connection)
        {
            var result = await connection.QuerySingleAsync <MeetingGroupMemberResponse>(
                "SELECT " +
                $"[MeetingGroupMember].{nameof(MeetingGroupMemberResponse.MeetingGroupId)}, " +
                $"[MeetingGroupMember].{nameof(MeetingGroupMemberResponse.MemberId)} " +
                "FROM [meetings].[v_MeetingGroupMembers] AS [MeetingGroupMember] " +
                "INNER JOIN [meetings].[Meetings] AS [Meeting] ON [Meeting].[MeetingGroupId] = [MeetingGroupMember].[MeetingGroupId] " +
                "WHERE [MeetingGroupMember].[MemberId] = @MemberId AND [Meeting].[Id] = @MeetingId",
                new
            {
                MemberId  = memberId.Value,
                MeetingId = meetingOfGroupId.Value
            });

            return(new MeetingGroupMemberData(
                       new MeetingGroupId(result.MeetingGroupId),
                       new MemberId(result.MemberId)));
        }
Example #19
0
 public MeetingNotAttendeeAddedDomainEvent(MeetingId meetingId, MemberId memberId)
 {
     MeetingId = meetingId;
     MemberId  = memberId;
 }
 public override int GetHashCode()
 {
     return(MeetingId.GetHashCode());
 }
 internal static MeetingComment Create(MeetingId meetingId, MemberId authorId, string comment)
 => new MeetingComment(meetingId, authorId, comment, inReplyToCommentId: null);
 public NewMeetingHostSetDomainEvent(MeetingId meetingId, MemberId hostId)
 {
     MeetingId = meetingId;
     HostId    = hostId;
 }
Example #23
0
 public async Task <Meeting> GetByIdAsync(MeetingId id)
 {
     return(await _meetingsContext.Meetings.FirstOrDefaultAsync(x => x.Id == id));
 }
 public MeetingCommentAddedDomainEvent(MeetingCommentId meetingCommentId, MeetingId meetingId, string comment)
 {
     MeetingCommentId = meetingCommentId;
     MeetingId        = meetingId;
     Comment          = comment;
 }
 public MeetingWaitlistMemberAddedDomainEvent(MeetingId meetingId, MemberId memberId)
 {
     MeetingId = meetingId;
     MemberId  = memberId;
 }
 internal SendMeetingAttendeeAddedEmailCommand(Guid id, MemberId attendeeId, MeetingId meetingId)
     : base(id)
 {
     AttendeeId = attendeeId;
     MeetingId  = meetingId;
 }
Example #27
0
 public MeetingMainAttributesChangedDomainEvent(MeetingId meetingId)
 {
     MeetingId = meetingId;
 }
 public MeetingCommentingConfigurationCreatedDomainEvent(MeetingId meetingId, bool isEnabled)
 {
     MeetingId = meetingId;
     IsEnabled = isEnabled;
 }
Example #29
0
 public async Task <MeetingPayment> GetByIdAsync(PayerId payerId, MeetingId meetingId)
 {
     return(await _paymentsContext.MeetingPayments.FirstOrDefaultAsync(x =>
                                                                       x.PayerId == payerId && x.MeetingId == meetingId));
 }
 public async Task <Meeting> GetByIdAsync(MeetingId id)
 {
     return(await _meetingsContext.Meetings.FindAsync(id));
 }