Example #1
0
        /// <summary>
        /// Implementation of <see cref="ICustomerCommands.LockCustomerAccount(Guid)"/>
        /// </summary>
        /// <param name="customerId">The customer id</param>
        /// <returns></returns>
        public async Task LockCustomerAccount(Guid customerId)
        {
            if (customerId == Guid.Empty)
            {
                throw new ArgumentException("value cannot be empty", nameof(customerId));
            }

            var customer = await Repository.GetByKeyAsync <Customer>(customerId);

            if (customer == null)
            {
                throw new ArgumentOutOfRangeException(nameof(customerId));
            }

            try
            {
                customer.LockAccount();
                await AuthClient.DisableAccount(customer.Account.UserId);

                await Repository.SaveChangesAsync();

                var @event = new CustomerAccountLockedEvent(customerId, customer.Account.UserName);
                EventBus.RaiseEvent(@event);
            }
            catch
            {
                throw;
            }
        }
Example #2
0
        public void ToString_Should_Return_The_Event_Formatted_As_String()
        {
            Guid   customerId = Guid.NewGuid();
            string userName   = "******";

            var ev = new CustomerAccountLockedEvent(customerId, userName);

            string eventAsString = $"Account {userName} locked for customer {customerId}";

            Assert.Equal(eventAsString, ev.ToString());
        }
Example #3
0
        public void Ctor_Should_Set_All_Values_Correctly()
        {
            Guid   customerId = Guid.NewGuid();
            string userName   = "******";

            var ev = new CustomerAccountLockedEvent(customerId, userName);

            Assert.Equal(customerId, ev.CustomerId);
            Assert.Equal(userName, ev.UserName);
            Assert.Equal(customerId, ev.AggregateId);
            Assert.Equal(typeof(Registries.Models.Customer), ev.AggregateType);
        }