public EmailSearchDocument(Email email)
 {
     Email = email;
     DatabaseID = email.ID;
     Title = email.Subject;
     Description = String.Empty;
     Type = "EventDescription";
     UniqueID = string.Format("{0}_{1}", Type, email.ID);
 }
Beispiel #2
0
        public bool Create(Email email, out int id)
        {
            using (var cn = Connection)
            {
                using (var transaction = new TransactionScope())
                {
                    cn.Open();
                    AuditService.DbConnect(cn);

                    var success = true;
                    id = -1;

                    const string sql = "INSERT INTO `Emails` (`To`, `CC`, `BCC`, `Subject`, `Body`, `Priority`, `IsBodyHtml`, `Enabled`) Values (@To, @CC, @BCC, @Subject, @Body, @Priority, @IsBodyHtml, @Enabled);";
                    success &= cn.Execute(sql, new
                    {
                        To = email.To,
                        CC = email.CC,
                        BCC = email.BCC,
                        Subject = email.Subject,
                        Body = email.Body,
                        Priority = email.Priority,
                        Enabled = email.Enabled,
                        IsBodyHtml = email.IsBodyHtml
                    }) > 0;

                    var newId = cn.Query<ulong>("SELECT CAST(LAST_INSERT_ID() AS UNSIGNED INTEGER);").SingleOrDefault();
                    id = email.ID = Convert.ToInt32(newId);

                    if (success)
                        AuditService.ObjectAuditLog(ActionType.Create, n => n.ID, email);

                    transaction.Complete();

                    return success | newId > 0;
                }
            }
        }
Beispiel #3
0
        public bool Send(Email email, /*IDictionary<string, string> replacements = null,*/ BinaryAttachment[] binaryAttachments = null)
        {
            var client = new SmtpClient();
            var message = new MailMessage();

            message.To.Add(email.To);
            message.Priority = email.Priority;
              //  message.Attachments = email.Attachments;
            message.From = new MailAddress("*****@*****.**");
            message.Subject = email.Subject;
            message.Body = email.Body;
            message.IsBodyHtml = email.IsBodyHtml;

            if (email.Enabled)
            {
                client.Send(message);
            }

            client.Dispose();
            message.Dispose();

            return true;
        }
Beispiel #4
0
        public bool Update(Email email)
        {
            using (var cn = Connection)
            {
                AuditService.DbConnect(cn);
                const string sql = "UPDATE `Emails` SET `To`=@To, `CC`=@CC, `BCC`=@BCC, `Subject`=@Subject, `Body`=@Body, `Priority`=@Priority, `IsBodyHtml`=@IsBodyHtml, `Enabled`=@Enabled WHERE `ID`=@id;";

                var success = cn.Execute(sql, new
                {
                    To = email.To,
                    CC = email.CC,
                    BCC = email.BCC,
                    Subject = email.Subject,
                    Body = email.Body,
                    Priority = email.Priority,
                    Enabled = email.Enabled,
                    IsBodyHtml = email.IsBodyHtml,
                    Id = email.ID
                }) > 0;

                if (success)
                    AuditService.ObjectAuditLog(ActionType.Update, n => n.ID, email);

                return success;
            }
        }
Beispiel #5
0
 public bool Put(Email email)
 {
     throw new System.NotImplementedException();
 }