/// <summary> /// Constructor. Construct a mailaudit object based on a mailmessage object. /// </summary> /// <param name="mailMessage"></param> public EmailAuditDal(MailMessage mailMessage, EmailCategory? category, int? userIdSender, int? userIdReceiver, int? attachmentEntityID) { _emailAudit = new emailaudit(); // Copy data from the MailMessage object to the MailAudit object. FromAddress = mailMessage.From.Address; ToAddresses = MailAddressesToString(mailMessage.To); CCAddresses = MailAddressesToString(mailMessage.CC); BccAddresses = MailAddressesToString(mailMessage.Bcc); Subject = mailMessage.Subject; Body = mailMessage.Body; IsHtml = mailMessage.IsBodyHtml; // Initialize the mailstatus to Unsent and set the creation date. EmailStatus = (int) EmailStatus.Unsent; DateCreated = System.DateTime.Now; // Set the mailcateogry and related entity (both can be null) if (category.HasValue) { EmailCategory = category.Value; } if (attachmentEntityID.HasValue) { AttachmentEntityId = attachmentEntityID.Value; } if (userIdReceiver.HasValue) { UserIdReceiver = userIdReceiver.Value; } if (userIdSender.HasValue) { UserIdSender = userIdSender.Value; } }
public void InsertOrUpdate(emailaudit emailaudit) { if (emailaudit.Id == default(int)) { // New entity context.emailaudits.Add(emailaudit); } else { // Existing entity context.Entry(emailaudit).State = EntityState.Modified; } }
public ActionResult Create(emailaudit emailaudit) { if (ModelState.IsValid) { emailauditRepository.InsertOrUpdate(emailaudit); emailauditRepository.Save(); return RedirectToAction("Index"); } else { return View(); } }
/// <summary> /// Constructor. Construct a mailaudit DAL object based on a mailAudit DB object. /// </summary> public EmailAuditDal(emailaudit emailAudit) { _emailAudit = emailAudit; }
/// <summary> /// Create a new emailaudit object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="fromAddress">Initial value of the FromAddress property.</param> /// <param name="emailStatusId">Initial value of the EmailStatusId property.</param> /// <param name="dateCreated">Initial value of the DateCreated property.</param> /// <param name="dateUpdated">Initial value of the DateUpdated property.</param> public static emailaudit Createemailaudit(global::System.Int32 id, global::System.String fromAddress, global::System.Int32 emailStatusId, global::System.DateTime dateCreated, global::System.DateTime dateUpdated) { emailaudit emailaudit = new emailaudit(); emailaudit.Id = id; emailaudit.FromAddress = fromAddress; emailaudit.EmailStatusId = emailStatusId; emailaudit.DateCreated = dateCreated; emailaudit.DateUpdated = dateUpdated; return emailaudit; }
/// <summary> /// Deprecated Method for adding a new object to the emailaudit EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToemailaudit(emailaudit emailaudit) { base.AddObject("emailaudit", emailaudit); }