Example #1
0
        static async Task RecordAttempt(string email, string ip, int attempts)
        {
            var record = await Database.FirstOrDefault <LogonFailure>(l => l.IP == ip && l.Email == email);

            var attempt = record?.Clone() ?? new LogonFailure();

            attempt.Email    = email;
            attempt.IP       = ip;
            attempt.Attempts = attempts;
            attempt.Date     = LocalTime.Now;

            await Database.Save(attempt);
        }
Example #2
0
        /// <summary>
        /// Sends an email to the specified email(s) using this template and the merge data provided.
        /// Use comma to separate multiple emails.
        /// </summary>
        public void Send(string to, object mergeData, Action <EmailQueueItem> customise = null)
        {
            if (mergeData == null)
            {
                throw new ArgumentNullException(nameof(mergeData));
            }
            if (to.IsEmpty())
            {
                throw new ArgumentNullException(nameof(to));
            }

            var message = new EmailQueueItem
            {
                Html    = true,
                Subject = this.MergeSubject(mergeData),
                Body    = this.MergeBody(mergeData),
                To      = to,
            };

            customise?.Invoke(message);

            Database.Save(message);
        }