Exemplo n.º 1
0
        public static DigestEmailLine AddLine(int emailId, string line)
        {
            using (DB db = new DB(DBHelper.GetConnectionString()))
            {
                DigestEmail email = (from o in db.DigestEmails
                                     where o.Id == emailId
                                     select o).FirstOrDefault();

                if (email != null)
                {
                    email.DigestEmailLines.Load();

                    DigestEmailLine emailLine = (from o in email.DigestEmailLines
                                                 where o.Line == line
                                                 select o).FirstOrDefault();

                    if (emailLine == null)
                    {
                        emailLine = new DigestEmailLine();
                        emailLine.Line = line;
                        emailLine.DigestEmail = email;

                        db.AddToDigestEmailLines(emailLine);

                        db.SaveChanges();

                        return emailLine;
                    }
                }
            }

            return null;
        }