Example #1
0
        public async Task <MaskedEmail> ToggleMaskedEmailForwarding(string userId, string email)
        {
            var address = await GetAddressEntityForUpdate(userId, email);

            await(
                address.EnableForwarding
                        ? commands_.DisableMaskedEmailAsync(address.EmailAddress)
                        : commands_.EnableMaskedEmailAsync(address.EmailAddress)
                )
            ;

            address.EnableForwarding = !address.EnableForwarding;
            await context_.SaveChangesAsync();

            return(address.ToModel());
        }
        public static async Task CreateMaskedEmailAsync(this IMaskedEmailCommandService service
                                                        , string address
                                                        , string forwardTo
                                                        , string passwordHash
                                                        , bool forwardingEnabled = true)
        {
            var addCommand = new CreateMaskedEmailCommand
            {
                Address          = address,
                AlternateAddress = forwardTo,
                PasswordHash     = passwordHash,
            };
            await service.QueueCommandAsync(addCommand);

            if (!forwardingEnabled)
            {
                await service.DisableMaskedEmailAsync(address);
            }
        }